mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
Compare commits
294 commits
Author | SHA1 | Date | |
---|---|---|---|
|
12675f1b61 |
||
|
9584029a25 | ||
|
bb04824902 | ||
|
6d0d3b108b |
||
|
f258548f3c |
||
|
44a6cc0dfc |
||
|
28d15ffed8 |
||
|
14edf41e57 |
||
|
cf267b9ad5 |
||
|
2fc884caca |
||
|
211885bad7 | ||
|
be4f2f13a2 | ||
|
1f0e9a91f9 | ||
|
378910086a | ||
|
0df727b704 |
||
|
94b4e30e26 |
||
|
7b0e6f8b69 |
||
|
8e934fbcc6 | ||
|
863c30f3c8 | ||
|
558404118d | ||
|
935a6a4bd4 | ||
|
c7ad1ebdd3 |
||
|
b4dcbf88d6 | ||
|
fd42e09929 |
||
|
52557179fb |
||
|
ba2516ed3e |
||
|
41cf0f4aed | ||
|
71de7fb158 | ||
|
56d45bcfd0 | ||
|
aecc4e8eec |
||
|
ecc818ff61 | ||
|
632320ae3b |
||
|
95c06a83b3 |
||
|
0ea3d9351e | ||
|
bfe86be11b | ||
|
50b4761791 | ||
|
5422a615bd | ||
|
373e430a3a |
||
|
4e5b3899e5 | ||
|
d37c879612 | ||
|
729d5e50d8 | ||
|
f8daca914c | ||
|
bcf3d692fb | ||
|
0e04149219 | ||
|
b2f7a2274b | ||
|
6a3306a91f | ||
|
5da50e047d | ||
|
0722076351 | ||
|
a86a1be7cc | ||
|
137966e6f8 | ||
|
022836872c | ||
|
b7f25a39c5 | ||
|
25fb5cbdea | ||
|
111b212538 | ||
|
a247dd2e06 | ||
|
c561dfc5e2 | ||
|
e86875b8ed | ||
|
874bf43378 | ||
|
303786dcd5 | ||
|
d8a6f2c436 | ||
|
13ed961d86 | ||
|
b4cae35c52 | ||
|
e8ce5d5ebd | ||
|
1ebfad0dd6 | ||
|
6f1c8c6b63 | ||
|
6823abb2e4 | ||
|
eb2cb7dc60 | ||
|
9fde47651b | ||
|
42d6347dce | ||
|
4b5580cb29 | ||
|
a6da4f1ef0 | ||
|
86e8aa8b00 | ||
|
b6570f0b1b | ||
|
d105afc7fa | ||
|
e214b17945 | ||
|
639626c1b3 | ||
|
8abf9c48c9 | ||
|
297cb64182 | ||
|
b60d0d4f12 | ||
|
848c7ed3be | ||
|
314fbd56da | ||
|
12d09d5b0b | ||
|
7d8237a7a2 | ||
|
a92da8d9a4 | ||
|
f08676e73d | ||
|
9d111dcd91 | ||
|
224a5dc3a4 | ||
|
8402e07019 | ||
|
90ea699848 | ||
|
bb6f987b02 | ||
|
85838625d2 | ||
|
470d74cd72 | ||
|
69ff03508e | ||
|
e560915727 | ||
|
b5b7b192ee | ||
|
2486ba4fc7 | ||
|
cdf5659fa0 |
||
|
ed3928bb01 |
||
|
024d77493c |
||
|
96d37cc490 |
||
|
56da2b408b | ||
|
7b6487de2f | ||
|
5599d24d4a | ||
|
90b067ded3 | ||
|
86aed30789 | ||
|
9f3cb09694 | ||
|
f66833c089 | ||
|
ba29eeaddf | ||
|
d907d000a6 | ||
|
caf83a7d8c | ||
|
d9e45e9825 | ||
|
5e87bd8eb1 | ||
|
ecb8e621c8 | ||
|
b5b102aff5 | ||
|
a3a494f29f | ||
|
fa7096bd78 | ||
|
29871c2eb1 | ||
|
b592515ae4 | ||
|
95dcaff8be | ||
|
4798afa362 | ||
|
f8cb660c51 | ||
|
f09c2e2c31 |
||
|
b034378277 | ||
|
b4b055270e | ||
|
3f09e3ff88 | ||
|
61ea8dd82c |
||
|
436dea47e8 |
||
|
7754ea3691 | ||
|
f85edef386 | ||
|
896c16a6be | ||
|
f755422f81 | ||
|
e4bfd9fe28 | ||
|
11246f6521 | ||
|
892f35aef3 | ||
|
dd41c977ed | ||
|
a514f284e6 | ||
|
90b96a2fed | ||
|
f0657b1dcd | ||
|
8ab77c99e2 | ||
|
5e8c8b983c | ||
|
823a8f69dc | ||
|
37a1ab30cf | ||
|
b9de4591be | ||
|
5bff894ed7 | ||
|
d4ca8b5c97 |
||
|
da2a308d31 |
||
|
c57c0efb73 | ||
|
03f3920383 | ||
|
b3816606f6 | ||
|
7c916828f2 | ||
|
de0ff76c8f | ||
|
5d02a13525 | ||
|
1a5f2d8e67 |
||
|
9b61af0306 |
||
|
43511e09ec | ||
|
ca9beebaea |
||
|
1462e300d6 |
||
|
dd1338ffc4 |
||
|
c6c80d35a9 | ||
|
95f6c97a57 | ||
|
d45409c7f3 | ||
|
f7ac0e3f22 | ||
|
1478486d8f | ||
|
f200dadb97 | ||
|
0b799d64b7 | ||
|
3607c70070 | ||
|
a4b10500a3 | ||
|
f5342d4b96 | ||
|
f89e9df8f0 | ||
|
490d3b42ea | ||
|
6e62ce5416 | ||
|
ec7d798783 | ||
|
6dccd5cbe2 | ||
|
eb413a1fba | ||
|
e35a25de81 | ||
|
7c436bd747 | ||
|
7317192e90 | ||
|
d67b3e0a84 | ||
|
49d961bbb5 | ||
|
0e082e4950 | ||
|
199bb0eb8e |
||
|
be9c13fbc6 | ||
|
86794dafe2 | ||
|
e7939ff0e2 |
||
|
5987b61a55 |
||
|
e85d7efc5e |
||
|
e1b3ef22c9 |
||
|
c67e095eaf | ||
|
9e3d83031e |
||
|
0e1177f398 | ||
|
d25a85c825 | ||
|
8142c71307 | ||
|
a73000ffbe | ||
|
6eda673aaf | ||
|
79d50b1a83 | ||
|
b6b5579f67 | ||
|
d64465e774 | ||
|
19a6c65313 | ||
|
5caa9c90b3 | ||
|
023b49d050 | ||
|
c118a5392e |
||
|
0c6a171a24 | ||
|
150e03e1fd | ||
|
f28bfe307e | ||
|
f23e7282b5 | ||
|
12a9b08f80 | ||
|
884f5e5966 | ||
|
d685091447 | ||
|
481f121f77 | ||
|
9b3f2e0919 | ||
|
e876553790 | ||
|
942e6f670b | ||
|
7ff93ad2da |
||
|
cbe0634f61 | ||
|
fc04ad31f3 | ||
|
39cb29afba | ||
|
d8fbdabc70 | ||
|
663b79ad05 |
||
|
49f9cb00ed |
||
|
f386c53e64 | ||
|
4466f7ec91 | ||
|
f385e2e379 |
||
|
a3d1d9f089 |
||
|
a4aefad0e4 |
||
|
24b9cbc9c3 |
||
|
7481b9a995 |
||
|
b4ae19e8e7 | ||
|
9b4bfa6f86 |
||
|
5522c5b0b2 |
||
|
b15bf65f88 | ||
|
936a681194 | ||
|
ca4a12164d | ||
|
1ba777ade8 | ||
|
67df81eac9 | ||
|
63fdb75664 | ||
|
4fb6a0be9f | ||
|
21f014d43f |
||
|
b7297d452a |
||
|
7256a7987c | ||
|
54a20c3432 | ||
|
dfa133d0b9 |
||
|
37b0ad1579 |
||
|
74933e976b | ||
|
6e65ef39e7 |
||
|
5f9a4156d6 | ||
|
6bf72d4602 |
||
|
ece9e0362f | ||
|
008ca05591 | ||
|
bf792daa96 | ||
|
306e09961f | ||
|
88f4304d5a | ||
|
f61e316788 | ||
|
76eec84c54 |
||
|
c1ace1c80a |
||
|
4021c562e9 |
||
|
8b096444f0 | ||
|
21ec70ad9b | ||
|
fb6719b1ae | ||
|
c194c80e29 | ||
|
e874ac19d7 | ||
|
dd6cbac3ee | ||
|
f3a8d9972c |
||
|
cee676331a |
||
|
107b77df6e | ||
|
6817892575 |
||
|
9e0731d41d |
||
|
cea3c02d60 |
||
|
b5d5420094 | ||
|
2d407393b6 | ||
|
48afd18e5e |
||
|
f1a27ec855 |
||
|
18c964e579 |
||
|
9bfddc5c62 |
||
|
1d24da063f |
||
|
c7f4b16bf3 | ||
|
09541657ef | ||
|
765ffc88eb | ||
|
c3a390f3fe | ||
|
e165fa3a87 | ||
|
1f7ec1b40a | ||
|
e2342aa249 | ||
|
3fe8da313d | ||
|
69d51872a5 | ||
|
0cc377eeb9 | ||
|
8ad7d5967e |
||
|
f752c96daf |
||
|
5fe5db919a | ||
|
f795bb7abc | ||
|
c4b09101e6 | ||
|
dee74d3470 | ||
|
2a68b2947c | ||
|
186ea85cbc | ||
|
8b477b12f9 | ||
|
89387004a3 |
462 changed files with 27075 additions and 6901 deletions
61
.github/workflows/checks.yml
vendored
61
.github/workflows/checks.yml
vendored
|
@ -1,31 +1,60 @@
|
|||
on:
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
- "docs/**"
|
||||
- "examples/**"
|
||||
push:
|
||||
branches: [master]
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
- "docs/**"
|
||||
- "examples/**"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
lint:
|
||||
runs-on: macos-15-xlarge
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/cache@v4
|
||||
id: npm-cache
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
path: "**/node_modules"
|
||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
|
||||
node-version: "22.x"
|
||||
cache: "npm"
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
test:
|
||||
runs-on: macos-15-xlarge
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22.x"
|
||||
cache: "npm"
|
||||
- run: npm ci
|
||||
- run: npm run test
|
||||
|
||||
- name: Test generated source types
|
||||
run: npm run test:src-types
|
||||
|
||||
- name: Test types
|
||||
run: npm run test:types
|
||||
types:
|
||||
runs-on: macos-15-xlarge
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22.x"
|
||||
cache: "npm"
|
||||
- run: npm ci
|
||||
- run: npm run test:src-types
|
||||
- run: npm run test:types
|
||||
|
||||
deploy-docs:
|
||||
if: github.ref == 'refs/heads/master'
|
||||
needs: [lint, test, types]
|
||||
runs-on: macos-15-xlarge
|
||||
steps:
|
||||
- name: Trigger deploy
|
||||
if: github.ref == 'refs/heads/master'
|
||||
env:
|
||||
deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
|
||||
run: |
|
||||
curl "$deploy_url"
|
||||
run: curl -f "$deploy_url"
|
||||
|
|
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
|
@ -5,7 +5,7 @@ on:
|
|||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: macos-latest-xlarge
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
@ -13,7 +13,7 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20.x"
|
||||
node-version: "22.x"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
- name: Install dependencies
|
||||
|
@ -23,7 +23,7 @@ jobs:
|
|||
run: npm run build:docs
|
||||
|
||||
- name: Prune package.json
|
||||
run: node scripts/build-package.js
|
||||
run: npx culls --preserve=svelte
|
||||
|
||||
- name: Publish package (stable)
|
||||
if: ${{ ! contains(github.ref, '-next') }}
|
||||
|
|
|
@ -6,3 +6,4 @@ dist
|
|||
client
|
||||
build
|
||||
*.svx
|
||||
COMPONENT_API.json
|
161
CHANGELOG.md
161
CHANGELOG.md
|
@ -2,6 +2,167 @@
|
|||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [0.89.7](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.89.6...v0.89.7) (2025-09-05)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **combo-box:** address accessibility issues ([#2186](https://github.com/carbon-design-system/carbon-components-svelte/issues/2186)) ([2fc884c](https://github.com/carbon-design-system/carbon-components-svelte/commit/2fc884cacabfffcf7779d6ef9ba01dece0bf5d86)), closes [#2172](https://github.com/carbon-design-system/carbon-components-svelte/issues/2172)
|
||||
- **data-table:** handle dynamic `headers` gracefully ([#2195](https://github.com/carbon-design-system/carbon-components-svelte/issues/2195)) ([6d0d3b1](https://github.com/carbon-design-system/carbon-components-svelte/commit/6d0d3b108bb4595d878fda20736c40b9656d14d7)), closes [#2193](https://github.com/carbon-design-system/carbon-components-svelte/issues/2193)
|
||||
- **overflow-menu:** avoid dynamic style injection for performance ([#2198](https://github.com/carbon-design-system/carbon-components-svelte/issues/2198)) ([14edf41](https://github.com/carbon-design-system/carbon-components-svelte/commit/14edf41e57fea1ddbb2cf24c37e79475849bdea1)), closes [#2197](https://github.com/carbon-design-system/carbon-components-svelte/issues/2197)
|
||||
- **pagination:** `on:change` dispatches with correct value ([#2194](https://github.com/carbon-design-system/carbon-components-svelte/issues/2194)) ([44a6cc0](https://github.com/carbon-design-system/carbon-components-svelte/commit/44a6cc0dfcbd3cdad1b442a760c9f604e58d56e6))
|
||||
|
||||
### [0.89.6](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.89.5...v0.89.6) (2025-08-16)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **toggle:** avoid dispatching `toggle` event on state change ([#2184](https://github.com/carbon-design-system/carbon-components-svelte/issues/2184)) ([0df727b](https://github.com/carbon-design-system/carbon-components-svelte/commit/0df727b704d6cc577681dc682269a6e224ddbb6e))
|
||||
|
||||
### [0.89.5](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.89.4...v0.89.5) (2025-08-05)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **checkbox:** prevent infinite effect loop when binding to same object ([#2178](https://github.com/carbon-design-system/carbon-components-svelte/issues/2178)) ([c7ad1eb](https://github.com/carbon-design-system/carbon-components-svelte/commit/c7ad1ebdd3764235f460abd95cdb7d1d389983d9)), closes [#2177](https://github.com/carbon-design-system/carbon-components-svelte/issues/2177)
|
||||
|
||||
### [0.89.4](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.89.3...v0.89.4) (2025-06-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **multi-select:** forward `on:input` for filterable variant ([#2170](https://github.com/carbon-design-system/carbon-components-svelte/issues/2170)) ([aecc4e8](https://github.com/carbon-design-system/carbon-components-svelte/commit/aecc4e8eec6571515233ec76ca06218814a279a7))
|
||||
|
||||
### [0.89.3](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.89.2...v0.89.3) (2025-06-07)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **combo-box:** "Escape" key clears input value ([#2169](https://github.com/carbon-design-system/carbon-components-svelte/issues/2169)) ([632320a](https://github.com/carbon-design-system/carbon-components-svelte/commit/632320ae3b8d9c602add0f4f7c708fc643cb7ffc)), closes [#2167](https://github.com/carbon-design-system/carbon-components-svelte/issues/2167)
|
||||
- **combo-box:** clear button supports "Space" key ([#2168](https://github.com/carbon-design-system/carbon-components-svelte/issues/2168)) ([95c06a8](https://github.com/carbon-design-system/carbon-components-svelte/commit/95c06a83b3afcbb76acfc0a5efe2f178d333ff19)), closes [#2166](https://github.com/carbon-design-system/carbon-components-svelte/issues/2166)
|
||||
|
||||
### [0.89.2](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.89.1...v0.89.2) (2025-04-28)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **composed-modal:** ignore a11y warning in Svelte 5 ([#2159](https://github.com/carbon-design-system/carbon-components-svelte/issues/2159)) ([024d774](https://github.com/carbon-design-system/carbon-components-svelte/commit/024d77493c93e7823e4781a1a60aaf350d289d52))
|
||||
- **pagination:** use `toLocaleString` for default text formatting ([#2161](https://github.com/carbon-design-system/carbon-components-svelte/issues/2161)) ([cdf5659](https://github.com/carbon-design-system/carbon-components-svelte/commit/cdf5659fa0177da77dc8ea1ccffdec54b746954b))
|
||||
- **pagination:** window `totalItems` for performance ([#2160](https://github.com/carbon-design-system/carbon-components-svelte/issues/2160)) ([ed3928b](https://github.com/carbon-design-system/carbon-components-svelte/commit/ed3928bb01ecca2fa63f551938dbee1c1829a978)), closes [#2156](https://github.com/carbon-design-system/carbon-components-svelte/issues/2156)
|
||||
- **to-hierarchy:** revert to previous implementation ([96d37cc](https://github.com/carbon-design-system/carbon-components-svelte/commit/96d37cc490f28830264c35c84447ee4526256314))
|
||||
|
||||
### [0.89.1](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.89.0...v0.89.1) (2025-04-21)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **toolbar-search:** re-filter rows if `DataTable` rows change ([#2154](https://github.com/carbon-design-system/carbon-components-svelte/issues/2154)) ([f09c2e2](https://github.com/carbon-design-system/carbon-components-svelte/commit/f09c2e2c311c15f633db8dc45930d8e58a4b362d)), closes [#2143](https://github.com/carbon-design-system/carbon-components-svelte/issues/2143)
|
||||
|
||||
### [0.89.0](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.88.4...v0.89.0) (2025-04-18)
|
||||
|
||||
### Features
|
||||
|
||||
- **combo-box:** add `hideLabel` prop ([#2153](https://github.com/carbon-design-system/carbon-components-svelte/issues/2153)) ([436dea4](https://github.com/carbon-design-system/carbon-components-svelte/commit/436dea47e8da35753a257c9b2bd6f33338e95ba5))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **select:** falsy item `text` should fallback to `value` ([#2152](https://github.com/carbon-design-system/carbon-components-svelte/issues/2152)) ([61ea8dd](https://github.com/carbon-design-system/carbon-components-svelte/commit/61ea8dd82c2f9863dfe5f8a882e73624b994d9e5))
|
||||
|
||||
### [0.88.4](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.88.3...v0.88.4) (2025-03-24)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **list-box-selection:** fix `aria-label` for clear button ([#2134](https://github.com/carbon-design-system/carbon-components-svelte/issues/2134)) ([dd1338f](https://github.com/carbon-design-system/carbon-components-svelte/commit/dd1338ffc47926a13e231d4a0f724e923f2219e2))
|
||||
- **list-box:** correct button/description translations based on selection count ([#2139](https://github.com/carbon-design-system/carbon-components-svelte/issues/2139)) ([1a5f2d8](https://github.com/carbon-design-system/carbon-components-svelte/commit/1a5f2d8e67734bfda20272ae6a77d13b3837416d))
|
||||
- **list-box:** set `aria-disabled` if `disabled` ([#2125](https://github.com/carbon-design-system/carbon-components-svelte/issues/2125)) ([#2138](https://github.com/carbon-design-system/carbon-components-svelte/issues/2138)) ([9b61af0](https://github.com/carbon-design-system/carbon-components-svelte/commit/9b61af0306b422acf1e7cdde278e517740f667c5)), closes [#2130](https://github.com/carbon-design-system/carbon-components-svelte/issues/2130)
|
||||
- **radio-button:** forward `focus`, `blur` events ([#2135](https://github.com/carbon-design-system/carbon-components-svelte/issues/2135)) ([1462e30](https://github.com/carbon-design-system/carbon-components-svelte/commit/1462e300d69f0cd7ee5476dfe3a7ea892ac8f4ad)), closes [#2131](https://github.com/carbon-design-system/carbon-components-svelte/issues/2131)
|
||||
- **radio-tile:** allow standalone `RadioTile` usage ([#2136](https://github.com/carbon-design-system/carbon-components-svelte/issues/2136)) ([ca9beeb](https://github.com/carbon-design-system/carbon-components-svelte/commit/ca9beebaeac7eaed8079c010a86a78926b00147f))
|
||||
- **text-area:** allow visually hidden label ([#2137](https://github.com/carbon-design-system/carbon-components-svelte/issues/2137)) ([43511e0](https://github.com/carbon-design-system/carbon-components-svelte/commit/43511e09ecf312c1b8e9339856b9d7d0785036de))
|
||||
|
||||
### [0.88.3](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.88.2...v0.88.3) (2025-03-19)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Revert **list-box:** use `aria-disabled` instead of invalid `disabled` attribute ([#2125](https://github.com/carbon-design-system/carbon-components-svelte/issues/2125)) ([e1b3ef2](https://github.com/carbon-design-system/carbon-components-svelte/commit/e1b3ef22c9ee09474bacadbb0b22b41326566bab))
|
||||
|
||||
### [0.88.2](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.88.1...v0.88.2) (2025-03-19)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **combo-box:** fix typing when refocusing input ([9e3d830](https://github.com/carbon-design-system/carbon-components-svelte/commit/9e3d83031e69889472c4e84be256ea242854cf81))
|
||||
- **list-box:** use `aria-disabled` instead of invalid `disabled` attribute ([#2125](https://github.com/carbon-design-system/carbon-components-svelte/issues/2125)) ([e1b3ef2](https://github.com/carbon-design-system/carbon-components-svelte/commit/e1b3ef22c9ee09474bacadbb0b22b41326566bab))
|
||||
- **multi-select:** fix keyboard navigation for disabled items ([#2129](https://github.com/carbon-design-system/carbon-components-svelte/issues/2129)) ([e7939ff](https://github.com/carbon-design-system/carbon-components-svelte/commit/e7939ff0e21c3430c9eea74c503b7c35f6823445)), closes [#2128](https://github.com/carbon-design-system/carbon-components-svelte/issues/2128)
|
||||
- **notification:** remove invalid `kind` prop from markup ([#2126](https://github.com/carbon-design-system/carbon-components-svelte/issues/2126)) ([e85d7ef](https://github.com/carbon-design-system/carbon-components-svelte/commit/e85d7efc5ed15f5236d074fd7981ae527d9e5ab5))
|
||||
- **theme:** remove invalid `themes` prop from markup ([#2127](https://github.com/carbon-design-system/carbon-components-svelte/issues/2127)) ([5987b61](https://github.com/carbon-design-system/carbon-components-svelte/commit/5987b61a5522fff09468bddd586eed4a537edcc8))
|
||||
|
||||
### [0.88.1](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.88.0...v0.88.1) (2025-03-12)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **select:** falsy item `text` should not override `value` ([#2118](https://github.com/carbon-design-system/carbon-components-svelte/issues/2118)) ([663b79a](https://github.com/carbon-design-system/carbon-components-svelte/commit/663b79ad054d14a91a8bf700feb62dcf50976eb8)), closes [#2117](https://github.com/carbon-design-system/carbon-components-svelte/issues/2117)
|
||||
- **ui-shell:** `HeaderAction` uses dark color scheme ([#2119](https://github.com/carbon-design-system/carbon-components-svelte/issues/2119)) ([7ff93ad](https://github.com/carbon-design-system/carbon-components-svelte/commit/7ff93ad2dac489859d5b4a83c1e359a6507718b4))
|
||||
|
||||
### [0.88.0](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.87.7...v0.88.0) (2025-03-09)
|
||||
|
||||
### Features
|
||||
|
||||
- **data-table:** allow custom `inputName` for radio/checkbox ([#2087](https://github.com/carbon-design-system/carbon-components-svelte/issues/2087)) ([7481b9a](https://github.com/carbon-design-system/carbon-components-svelte/commit/7481b9a995dfbc8c2fbaeaae143c8372cf5fce66)), closes [#2085](https://github.com/carbon-design-system/carbon-components-svelte/issues/2085)
|
||||
- **ui-shell:** `HeaderAction` supports tooltip ([#2111](https://github.com/carbon-design-system/carbon-components-svelte/issues/2111)) ([24b9cbc](https://github.com/carbon-design-system/carbon-components-svelte/commit/24b9cbc9c343537e5e74799ef8289bd29396cf04)), closes [#2110](https://github.com/carbon-design-system/carbon-components-svelte/issues/2110)
|
||||
|
||||
### [0.87.7](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.87.6...v0.87.7) (2025-03-07)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **select:** avoid infinite update loop in Svelte 5 ([#2108](https://github.com/carbon-design-system/carbon-components-svelte/issues/2108)) ([9b4bfa6](https://github.com/carbon-design-system/carbon-components-svelte/commit/9b4bfa6f86e23155516db156cbe1c980f3c699e8)), closes [#2107](https://github.com/carbon-design-system/carbon-components-svelte/issues/2107)
|
||||
|
||||
### [0.87.6](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.87.5...v0.87.6) (2025-02-24)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **overflow-menu:** add `aria-controls` to trigger button ([#2100](https://github.com/carbon-design-system/carbon-components-svelte/issues/2100)) ([b7297d4](https://github.com/carbon-design-system/carbon-components-svelte/commit/b7297d452a7813c02f3c89280787292b1c46acec))
|
||||
|
||||
### [0.87.5](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.87.4...v0.87.5) (2025-02-04)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **tag:** allow `on:close` to work with Svelte 5 ([#2097](https://github.com/carbon-design-system/carbon-components-svelte/issues/2097)) ([6e65ef3](https://github.com/carbon-design-system/carbon-components-svelte/commit/6e65ef39e7ff9a3c0ee25b7945a62584e9b7441e)), closes [#2096](https://github.com/carbon-design-system/carbon-components-svelte/issues/2096)
|
||||
|
||||
### [0.87.4](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.87.3...v0.87.4) (2025-02-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **types:** loosen `icon` prop type to `any` ([#2095](https://github.com/carbon-design-system/carbon-components-svelte/issues/2095)) ([6bf72d4](https://github.com/carbon-design-system/carbon-components-svelte/commit/6bf72d46024ad2ce03651f28fc1a2a95ec03385d))
|
||||
|
||||
### [0.87.3](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.87.2...v0.87.3) (2025-01-30)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **overflow-menu:** support Svelte 5 ([88f4304](https://github.com/carbon-design-system/carbon-components-svelte/commit/88f4304d5a7c9b38b3cabda677233bef48fb9e3a)), closes [#2092](https://github.com/carbon-design-system/carbon-components-svelte/issues/2092)
|
||||
|
||||
### [0.87.2](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.87.1...v0.87.2) (2025-01-22)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **text-area:** counter supports null `value` ([#2089](https://github.com/carbon-design-system/carbon-components-svelte/issues/2089)) ([76eec84](https://github.com/carbon-design-system/carbon-components-svelte/commit/76eec84c5458d07d61d057d9ff06938e244dbb2c))
|
||||
|
||||
### [0.87.1](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.87.0...v0.87.1) (2025-01-19)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **data-table:** improve `expandable` accessibility ([#2086](https://github.com/carbon-design-system/carbon-components-svelte/issues/2086)) ([e874ac1](https://github.com/carbon-design-system/carbon-components-svelte/commit/e874ac19d778a00c0bba9be65d10be7e6c9104dd))
|
||||
- **data-table:** prefix internal ID for radio button, checkbox ([#2082](https://github.com/carbon-design-system/carbon-components-svelte/issues/2082)) ([dd6cbac](https://github.com/carbon-design-system/carbon-components-svelte/commit/dd6cbac3ee1728dbcba5cd1d8faa43941e2a198e)), closes [#2081](https://github.com/carbon-design-system/carbon-components-svelte/issues/2081)
|
||||
- **dropdown:** avoid manual field `blur` ([c194c80](https://github.com/carbon-design-system/carbon-components-svelte/commit/c194c80e29ab36935af71adb9e166e9a16b70910)), closes [#2083](https://github.com/carbon-design-system/carbon-components-svelte/issues/2083)
|
||||
- **multi-select:** avoid manual field `blur` ([fb6719b](https://github.com/carbon-design-system/carbon-components-svelte/commit/fb6719b1aee35aa45004d82e3b923b4ad45dff5d)), closes [#2083](https://github.com/carbon-design-system/carbon-components-svelte/issues/2083)
|
||||
|
||||
### [0.87.0](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.86.2...v0.87.0) (2024-12-09)
|
||||
|
||||
### Features
|
||||
|
||||
- add `toHierarchy` utility to normalize flat data into `nodes` for `TreeView`, `RecursiveList` ([#2072](https://github.com/carbon-design-system/carbon-components-svelte/issues/2072)) ([48afd18](https://github.com/carbon-design-system/carbon-components-svelte/commit/48afd18e5e01c2839024b8ddb31038267bcedeb8))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **tooltip-icon:** `button` should have explicit `type` ([#2071](https://github.com/carbon-design-system/carbon-components-svelte/issues/2071)) ([18c964e](https://github.com/carbon-design-system/carbon-components-svelte/commit/18c964e579a3762b8022751bf0ed5313b78b22ba))
|
||||
|
||||
### [0.86.2](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.86.1...v0.86.2) (2024-11-30)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **multi-select:** fix sorting behavior ([c3a390f](https://github.com/carbon-design-system/carbon-components-svelte/commit/c3a390f3fef072c6b736e33a85a2ae772df12e52)), closes [#2066](https://github.com/carbon-design-system/carbon-components-svelte/issues/2066)
|
||||
|
||||
## [0.86.1](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.86.0...v0.86.1) (2024-11-22)
|
||||
|
||||
### Bug Fixes
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Component Index
|
||||
|
||||
> 165 components exported from carbon-components-svelte@0.86.1.
|
||||
> 165 components exported from carbon-components-svelte@0.89.7.
|
||||
|
||||
## Components
|
||||
|
||||
|
@ -379,7 +379,7 @@ export type BreakpointValue = 320 | 672 | 1056 | 1312 | 1584;
|
|||
| size | No | <code>let</code> | No | <code>"default" | "field" | "small" | "lg" | "xl"</code> | <code>"default"</code> | Specify the size of button |
|
||||
| expressive | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use Carbon's expressive typesetting |
|
||||
| isSelected | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the selected state for an icon-only, ghost button |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render<br />Alternatively, use the named slot "icon" (e.g., `<Icon slot="icon" size="{20}" />`) |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render<br />Alternatively, use the named slot "icon" (e.g., `<Icon slot="icon" size="{20}" />`) |
|
||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the ARIA label for the button icon |
|
||||
| tooltipAlignment | No | <code>let</code> | No | <code>"start" | "center" | "end"</code> | <code>"center"</code> | Set the alignment of the tooltip relative to the icon.<br />Only applies to icon-only buttons |
|
||||
| tooltipPosition | No | <code>let</code> | No | <code>"top" | "right" | "bottom" | "left"</code> | <code>"bottom"</code> | Set the position of the tooltip relative to the icon |
|
||||
|
@ -671,6 +671,7 @@ export interface ComboBoxItem {
|
|||
| size | No | <code>let</code> | No | <code>"sm" | "xl"</code> | <code>undefined</code> | Set the size of the combobox |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the combobox |
|
||||
| titleText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the title text of the combobox |
|
||||
| hideLabel | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to visually hide the label text |
|
||||
| placeholder | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the placeholder text |
|
||||
| helperText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the helper text |
|
||||
| invalidText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the invalid state text |
|
||||
|
@ -847,18 +848,18 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :----------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLLIElement</code> | <code>null</code> | Obtain a reference to the list item HTML element |
|
||||
| selectable | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to enable the selectable variant<br />Automatically set to `true` if `selected` is `true` |
|
||||
| selected | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to use the selected variant |
|
||||
| icon | No | <code>let</code> | Yes | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render<br />Icon is rendered to the left of the label text |
|
||||
| indented | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to indent the label |
|
||||
| kind | No | <code>let</code> | No | <code>"default" | "danger"</code> | <code>"default"</code> | Specify the kind of option |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the disabled state |
|
||||
| labelText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text.<br />Alternatively, use the "labelText" slot (e.g., `<span slot="labelText">...</span>`) |
|
||||
| shortcutText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the shortcut text.<br />Alternatively, use the "shortcutText" slot (e.g., `<span slot="shortcutText">...</span>`) |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Specify the id<br />It's recommended to provide an id as a value to bind to within a selectable/radio menu group |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :----------- | :------- | :--------------- | :------- | -------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLLIElement</code> | <code>null</code> | Obtain a reference to the list item HTML element |
|
||||
| selectable | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to enable the selectable variant<br />Automatically set to `true` if `selected` is `true` |
|
||||
| selected | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to use the selected variant |
|
||||
| icon | No | <code>let</code> | Yes | <code>any</code> | <code>undefined</code> | Specify the icon to render<br />Icon is rendered to the left of the label text |
|
||||
| indented | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to indent the label |
|
||||
| kind | No | <code>let</code> | No | <code>"default" | "danger"</code> | <code>"default"</code> | Specify the kind of option |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the disabled state |
|
||||
| labelText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text.<br />Alternatively, use the "labelText" slot (e.g., `<span slot="labelText">...</span>`) |
|
||||
| shortcutText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the shortcut text.<br />Alternatively, use the "shortcutText" slot (e.g., `<span slot="shortcutText">...</span>`) |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Specify the id<br />It's recommended to provide an id as a value to bind to within a selectable/radio menu group |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -971,30 +972,31 @@ export interface DataTableCell<Row = DataTableRow> {
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------------ | :------- | :--------------- | :------- | ------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
||||
| selectedRowIds | No | <code>let</code> | Yes | <code>ReadonlyArray<DataTableRowId></code> | <code>[]</code> | Specify the row ids to be selected |
|
||||
| selectable | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` for the selectable variant<br />Automatically set to `true` if `radio` or `batchSelection` are `true` |
|
||||
| expandedRowIds | No | <code>let</code> | Yes | <code>ReadonlyArray<DataTableRowId></code> | <code>[]</code> | Specify the row ids to be expanded |
|
||||
| expandable | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` for the expandable variant<br />Automatically set to `true` if `batchExpansion` is `true` |
|
||||
| sortDirection | No | <code>let</code> | Yes | <code>"none" | "ascending" | "descending"</code> | <code>"none"</code> | Specify the sort direction |
|
||||
| sortKey | No | <code>let</code> | Yes | <code>DataTableKey<Row></code> | <code>null</code> | Specify the header key to sort by |
|
||||
| headers | No | <code>let</code> | No | <code>ReadonlyArray<DataTableHeader<Row>></code> | <code>[]</code> | Specify the data table headers |
|
||||
| rows | No | <code>let</code> | No | <code>ReadonlyArray<Row></code> | <code>[]</code> | Specify the rows the data table should render<br />keys defined in `headers` are used for the row ids |
|
||||
| size | No | <code>let</code> | No | <code>"compact" | "short" | "medium" | "tall"</code> | <code>undefined</code> | Set the size of the data table |
|
||||
| title | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the title of the data table |
|
||||
| description | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the description of the data table |
|
||||
| zebra | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use zebra styles |
|
||||
| sortable | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` for the sortable variant |
|
||||
| batchExpansion | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable batch expansion |
|
||||
| nonExpandableRowIds | No | <code>let</code> | No | <code>ReadonlyArray<DataTableRowId></code> | <code>[]</code> | Specify the ids for rows that should not be expandable |
|
||||
| radio | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` for the radio selection variant |
|
||||
| batchSelection | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable batch selection |
|
||||
| nonSelectableRowIds | No | <code>let</code> | No | <code>ReadonlyArray<DataTableRowId></code> | <code>[]</code> | Specify the ids of rows that should not be selectable |
|
||||
| stickyHeader | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable a sticky header |
|
||||
| useStaticWidth | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use static width |
|
||||
| pageSize | No | <code>let</code> | No | <code>number</code> | <code>0</code> | Specify the number of items to display in a page |
|
||||
| page | No | <code>let</code> | No | <code>number</code> | <code>0</code> | Set to `number` to set current page |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------------ | :------- | :--------------- | :------- | ------------------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| selectedRowIds | No | <code>let</code> | Yes | <code>ReadonlyArray<DataTableRowId></code> | <code>[]</code> | Specify the row ids to be selected |
|
||||
| selectable | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` for the selectable variant<br />Automatically set to `true` if `radio` or `batchSelection` are `true` |
|
||||
| expandedRowIds | No | <code>let</code> | Yes | <code>ReadonlyArray<DataTableRowId></code> | <code>[]</code> | Specify the row ids to be expanded |
|
||||
| expandable | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` for the expandable variant<br />Automatically set to `true` if `batchExpansion` is `true` |
|
||||
| sortDirection | No | <code>let</code> | Yes | <code>"none" | "ascending" | "descending"</code> | <code>"none"</code> | Specify the sort direction |
|
||||
| sortKey | No | <code>let</code> | Yes | <code>DataTableKey<Row></code> | <code>null</code> | Specify the header key to sort by |
|
||||
| headers | No | <code>let</code> | No | <code>ReadonlyArray<DataTableHeader<Row>></code> | <code>[]</code> | Specify the data table headers |
|
||||
| rows | No | <code>let</code> | No | <code>ReadonlyArray<Row></code> | <code>[]</code> | Specify the rows the data table should render<br />keys defined in `headers` are used for the row ids |
|
||||
| size | No | <code>let</code> | No | <code>"compact" | "short" | "medium" | "tall"</code> | <code>undefined</code> | Set the size of the data table |
|
||||
| title | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the title of the data table |
|
||||
| description | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the description of the data table |
|
||||
| inputName | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Specify a name attribute for the input elements<br />in a selectable data table (radio or checkbox).<br />When the table is inside a form, this name will<br />be included in the form data on submit. |
|
||||
| zebra | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use zebra styles |
|
||||
| sortable | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` for the sortable variant |
|
||||
| batchExpansion | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable batch expansion |
|
||||
| nonExpandableRowIds | No | <code>let</code> | No | <code>ReadonlyArray<DataTableRowId></code> | <code>[]</code> | Specify the ids for rows that should not be expandable |
|
||||
| radio | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` for the radio selection variant |
|
||||
| batchSelection | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable batch selection |
|
||||
| nonSelectableRowIds | No | <code>let</code> | No | <code>ReadonlyArray<DataTableRowId></code> | <code>[]</code> | Specify the ids of rows that should not be selectable |
|
||||
| stickyHeader | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable a sticky header |
|
||||
| useStaticWidth | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use static width |
|
||||
| pageSize | No | <code>let</code> | No | <code>number</code> | <code>0</code> | Specify the number of items to display in a page |
|
||||
| page | No | <code>let</code> | No | <code>number</code> | <code>0</code> | Set to `number` to set current page |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -1582,19 +1584,19 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :---------------------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLAnchorElement</code> | <code>null</code> | Obtain a reference to the HTML anchor element |
|
||||
| isSideNavOpen | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the side nav |
|
||||
| expandedByDefault | No | <code>let</code> | No | <code>boolean</code> | <code>true</code> | Set to `false` to hide the side nav by default |
|
||||
| uiShellAriaLabel | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the ARIA label for the header |
|
||||
| href | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the `href` attribute |
|
||||
| company | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the company name.<br /><br />Alternatively, use the named slot "company" (e.g., `<span slot="company">...</span>`) |
|
||||
| platformName | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the platform name.<br />Alternatively, use the named slot "platform" (e.g., `<span slot="platform">...</span>`) |
|
||||
| persistentHamburgerMenu | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to persist the hamburger menu |
|
||||
| expansionBreakpoint | No | <code>let</code> | No | <code>number</code> | <code>1056</code> | The window width (px) at which the SideNav is expanded and the hamburger menu is hidden.<br />1056 represents the "large" breakpoint in pixels from the Carbon Design System:<br />- small: 320<br />- medium: 672<br />- large: 1056<br />- x-large: 1312<br />- max: 1584 |
|
||||
| iconMenu | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render for the closed state.<br />Defaults to `<Menu size={20} />` |
|
||||
| iconClose | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render for the opened state.<br />Defaults to `<Close size={20} />` |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :---------------------- | :------- | :--------------- | :------- | ------------------------------------------ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLAnchorElement</code> | <code>null</code> | Obtain a reference to the HTML anchor element |
|
||||
| isSideNavOpen | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the side nav |
|
||||
| expandedByDefault | No | <code>let</code> | No | <code>boolean</code> | <code>true</code> | Set to `false` to hide the side nav by default |
|
||||
| uiShellAriaLabel | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the ARIA label for the header |
|
||||
| href | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the `href` attribute |
|
||||
| company | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the company name.<br /><br />Alternatively, use the named slot "company" (e.g., `<span slot="company">...</span>`) |
|
||||
| platformName | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the platform name.<br />Alternatively, use the named slot "platform" (e.g., `<span slot="platform">...</span>`) |
|
||||
| persistentHamburgerMenu | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to persist the hamburger menu |
|
||||
| expansionBreakpoint | No | <code>let</code> | No | <code>number</code> | <code>1056</code> | The window width (px) at which the SideNav is expanded and the hamburger menu is hidden.<br />1056 represents the "large" breakpoint in pixels from the Carbon Design System:<br />- small: 320<br />- medium: 672<br />- large: 1056<br />- x-large: 1312<br />- max: 1584 |
|
||||
| iconMenu | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render for the closed state.<br />Defaults to `<Menu size={20} />` |
|
||||
| iconClose | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render for the opened state.<br />Defaults to `<Close size={20} />` |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -1615,15 +1617,17 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------------------- | :------- | :--------------- | :------- | ----------------------------------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLButtonElement</code> | <code>null</code> | Obtain a reference to the button HTML element |
|
||||
| isOpen | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the panel |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render when the action panel is closed.<br />Defaults to `<Switcher size={20} />` |
|
||||
| closeIcon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render when the action panel is open.<br />Defaults to `<Close size={20} />` |
|
||||
| text | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the text.<br />Alternatively, use the named slot "text" (e.g., `<div slot="text">...</div>`) |
|
||||
| transition | No | <code>let</code> | No | <code>false | import("svelte/transition").SlideParams</code> | <code>{ duration: 200 }</code> | Customize the panel transition (i.e., `transition:slide`).<br />Set to `false` to disable the transition |
|
||||
| preventCloseOnClickOutside | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to prevent the panel from closing when clicking outside |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------------------- | :------- | :--------------- | :------- | ----------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLButtonElement</code> | <code>null</code> | Obtain a reference to the button HTML element |
|
||||
| isOpen | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the panel |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render when the action panel is closed.<br />Defaults to `<Switcher size={20} />` |
|
||||
| closeIcon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render when the action panel is open.<br />Defaults to `<Close size={20} />` |
|
||||
| text | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the text displayed next to the icon.<br />Alternatively, use the named slot "text" (e.g., `<div slot="text">...</div>`) |
|
||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify an icon tooltip. The tooltip will not be displayed<br />if either the `text` prop or a named slot="text" is used |
|
||||
| tooltipAlignment | No | <code>let</code> | No | <code>"start" | "center" | "end"</code> | <code>"center"</code> | Set the alignment of the tooltip relative to the icon.<br />Only applies when `iconDescription` is provided |
|
||||
| transition | No | <code>let</code> | No | <code>false | import("svelte/transition").SlideParams</code> | <code>{ duration: 200 }</code> | Customize the panel transition (i.e., `transition:slide`).<br />Set to `false` to disable the transition |
|
||||
| preventCloseOnClickOutside | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to prevent the panel from closing when clicking outside |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -1646,12 +1650,12 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :----------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ---------------------- | --------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLAnchorElement</code> | <code>null</code> | Obtain a reference to the HTML anchor element |
|
||||
| linkIsActive | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the active state |
|
||||
| href | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the `href` attribute |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :----------- | :------- | :--------------- | :------- | ------------------------------------------ | ---------------------- | --------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLAnchorElement</code> | <code>null</code> | Obtain a reference to the HTML anchor element |
|
||||
| linkIsActive | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the active state |
|
||||
| href | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the `href` attribute |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -1669,11 +1673,11 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ---------------------- | --------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>HTMLButtonElement</code> | <code>null</code> | Obtain a reference to the HTML button element |
|
||||
| isActive | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the active variant |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------- | :------- | :--------------- | :------- | ------------------------------ | ---------------------- | --------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>HTMLButtonElement</code> | <code>null</code> | Obtain a reference to the HTML button element |
|
||||
| isActive | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the active variant |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -1966,15 +1970,15 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ---------------------- | -------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLAnchorElement</code> | <code>null</code> | Obtain a reference to the top-level HTML element |
|
||||
| size | No | <code>let</code> | No | <code>"sm" | "lg"</code> | <code>undefined</code> | Specify the size of the link |
|
||||
| href | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the href value |
|
||||
| inline | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the inline variant |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render<br />`inline` must be `false` |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the checkbox |
|
||||
| visited | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to allow visited styles |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------- | :------- | :--------------- | :------- | ------------------------------------------ | ---------------------- | -------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLAnchorElement</code> | <code>null</code> | Obtain a reference to the top-level HTML element |
|
||||
| size | No | <code>let</code> | No | <code>"sm" | "lg"</code> | <code>undefined</code> | Specify the size of the link |
|
||||
| href | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the href value |
|
||||
| inline | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the inline variant |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render<br />`inline` must be `false` |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the checkbox |
|
||||
| visited | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to allow visited styles |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -2224,29 +2228,29 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------------------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLDivElement</code> | <code>null</code> | Obtain a reference to the top-level HTML element |
|
||||
| open | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the modal |
|
||||
| size | No | <code>let</code> | No | <code>"xs" | "sm" | "lg"</code> | <code>undefined</code> | Set the size of the modal |
|
||||
| danger | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the danger variant |
|
||||
| alert | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable alert mode |
|
||||
| passiveModal | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the passive variant |
|
||||
| modalHeading | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the modal heading |
|
||||
| modalLabel | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the modal label |
|
||||
| modalAriaLabel | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the ARIA label for the modal |
|
||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>"Close the modal"</code> | Specify the ARIA label for the close icon |
|
||||
| hasForm | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` if the modal contains form elements |
|
||||
| hasScrollingContent | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` if the modal contains scrolling content |
|
||||
| primaryButtonText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the primary button text |
|
||||
| primaryButtonDisabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the primary button |
|
||||
| primaryButtonIcon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the primary button icon |
|
||||
| shouldSubmitOnEnter | No | <code>let</code> | No | <code>boolean</code> | <code>true</code> | Set to `true` for the "submit" and "click:button--primary" events<br />to be dispatched when pressing "Enter" |
|
||||
| secondaryButtonText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the secondary button text |
|
||||
| secondaryButtons | No | <code>let</code> | No | <code>[{ text: string; }, { text: string; }]</code> | <code>[]</code> | 2-tuple prop to render two secondary buttons for a 3 button modal<br />supersedes `secondaryButtonText` |
|
||||
| selectorPrimaryFocus | No | <code>let</code> | No | <code>string</code> | <code>"[data-modal-primary-focus]"</code> | Specify a selector to be focused when opening the modal |
|
||||
| preventCloseOnClickOutside | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to prevent the modal from closing when clicking outside |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the top-level element |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------------------- | :------- | :--------------- | :------- | --------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLDivElement</code> | <code>null</code> | Obtain a reference to the top-level HTML element |
|
||||
| open | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the modal |
|
||||
| size | No | <code>let</code> | No | <code>"xs" | "sm" | "lg"</code> | <code>undefined</code> | Set the size of the modal |
|
||||
| danger | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the danger variant |
|
||||
| alert | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable alert mode |
|
||||
| passiveModal | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the passive variant |
|
||||
| modalHeading | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the modal heading |
|
||||
| modalLabel | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the modal label |
|
||||
| modalAriaLabel | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the ARIA label for the modal |
|
||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>"Close the modal"</code> | Specify the ARIA label for the close icon |
|
||||
| hasForm | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` if the modal contains form elements |
|
||||
| hasScrollingContent | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` if the modal contains scrolling content |
|
||||
| primaryButtonText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the primary button text |
|
||||
| primaryButtonDisabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the primary button |
|
||||
| primaryButtonIcon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the primary button icon |
|
||||
| shouldSubmitOnEnter | No | <code>let</code> | No | <code>boolean</code> | <code>true</code> | Set to `true` for the "submit" and "click:button--primary" events<br />to be dispatched when pressing "Enter" |
|
||||
| secondaryButtonText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the secondary button text |
|
||||
| secondaryButtons | No | <code>let</code> | No | <code>[{ text: string; }, { text: string; }]</code> | <code>[]</code> | 2-tuple prop to render two secondary buttons for a 3 button modal<br />supersedes `secondaryButtonText` |
|
||||
| selectorPrimaryFocus | No | <code>let</code> | No | <code>string</code> | <code>"[data-modal-primary-focus]"</code> | Specify a selector to be focused when opening the modal |
|
||||
| preventCloseOnClickOutside | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to prevent the modal from closing when clicking outside |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the top-level element |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -2295,16 +2299,16 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------------------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------- |
|
||||
| primaryButtonText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the primary button text |
|
||||
| primaryButtonIcon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the primary button icon |
|
||||
| primaryButtonDisabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the primary button |
|
||||
| primaryClass | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a class for the primary button |
|
||||
| secondaryButtonText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the secondary button text |
|
||||
| secondaryButtons | No | <code>let</code> | No | <code>[{ text: string; }, { text: string; }]</code> | <code>[]</code> | 2-tuple prop to render two secondary buttons for a 3 button modal<br />supersedes `secondaryButtonText` |
|
||||
| secondaryClass | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a class for the secondary button |
|
||||
| danger | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the danger variant |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------------------- | :------- | :--------------- | :------- | --------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------- |
|
||||
| primaryButtonText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the primary button text |
|
||||
| primaryButtonIcon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the primary button icon |
|
||||
| primaryButtonDisabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the primary button |
|
||||
| primaryClass | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a class for the primary button |
|
||||
| secondaryButtonText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the secondary button text |
|
||||
| secondaryButtons | No | <code>let</code> | No | <code>[{ text: string; }, { text: string; }]</code> | <code>[]</code> | 2-tuple prop to render two secondary buttons for a 3 button modal<br />supersedes `secondaryButtonText` |
|
||||
| secondaryClass | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a class for the secondary button |
|
||||
| danger | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the danger variant |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -2415,6 +2419,7 @@ export interface MultiSelectItem {
|
|||
| clear | dispatched | <code>null</code> |
|
||||
| blur | dispatched | <code>FocusEvent | CustomEvent<FocusEvent></code> |
|
||||
| keydown | forwarded | -- |
|
||||
| input | forwarded | -- |
|
||||
| keyup | forwarded | -- |
|
||||
| focus | forwarded | -- |
|
||||
| paste | forwarded | -- |
|
||||
|
@ -2444,12 +2449,12 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :--------------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ------------------------- | ----------------------------------- |
|
||||
| notificationType | No | <code>let</code> | No | <code>"toast" | "inline"</code> | <code>"toast"</code> | Set the type of notification |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render |
|
||||
| title | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the title of the icon |
|
||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>"Close icon"</code> | Specify the ARIA label for the icon |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :--------------- | :------- | :--------------- | :------- | ------------------------------------ | ------------------------- | ----------------------------------- |
|
||||
| notificationType | No | <code>let</code> | No | <code>"toast" | "inline"</code> | <code>"toast"</code> | Set the type of notification |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render |
|
||||
| title | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the title of the icon |
|
||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>"Close icon"</code> | Specify the ARIA label for the icon |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -2611,20 +2616,20 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :--------------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ------------------------------------------------ | ----------------------------------------------------------------------------- |
|
||||
| menuRef | No | <code>let</code> | Yes | <code>null | HTMLUListElement</code> | <code>null</code> | Obtain a reference to the overflow menu element |
|
||||
| buttonRef | No | <code>let</code> | Yes | <code>null | HTMLButtonElement</code> | <code>null</code> | Obtain a reference to the trigger button element |
|
||||
| icon | No | <code>let</code> | Yes | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render.<br />Defaults to `<OverflowMenuVertical />` |
|
||||
| open | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the menu |
|
||||
| size | No | <code>let</code> | No | <code>"sm" | "xl"</code> | <code>undefined</code> | Specify the size of the overflow menu |
|
||||
| direction | No | <code>let</code> | No | <code>"top" | "bottom"</code> | <code>"bottom"</code> | Specify the direction of the overflow menu relative to the button |
|
||||
| light | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant |
|
||||
| flipped | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to flip the menu relative to the button |
|
||||
| menuOptionsClass | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the menu options class |
|
||||
| iconClass | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the icon class |
|
||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>"Open and close list of options"</code> | Specify the ARIA label for the icon |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the button element |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :--------------- | :------- | :--------------- | :------- | ------------------------------------------ | ------------------------------------------------ | ----------------------------------------------------------------------------- |
|
||||
| menuRef | No | <code>let</code> | Yes | <code>null | HTMLUListElement</code> | <code>null</code> | Obtain a reference to the overflow menu element |
|
||||
| buttonRef | No | <code>let</code> | Yes | <code>null | HTMLButtonElement</code> | <code>null</code> | Obtain a reference to the trigger button element |
|
||||
| icon | No | <code>let</code> | Yes | <code>any</code> | <code>undefined</code> | Specify the icon to render.<br />Defaults to `<OverflowMenuVertical />` |
|
||||
| open | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the menu |
|
||||
| size | No | <code>let</code> | No | <code>"sm" | "xl"</code> | <code>undefined</code> | Specify the size of the overflow menu |
|
||||
| direction | No | <code>let</code> | No | <code>"top" | "bottom"</code> | <code>"bottom"</code> | Specify the direction of the overflow menu relative to the button |
|
||||
| light | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant |
|
||||
| flipped | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to flip the menu relative to the button |
|
||||
| menuOptionsClass | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the menu options class |
|
||||
| iconClass | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the icon class |
|
||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>"Open and close list of options"</code> | Specify the ARIA label for the icon |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the button element |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -2677,24 +2682,25 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------------------- | :------- | :--------------- | :------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------ |
|
||||
| pageSize | No | <code>let</code> | Yes | <code>number</code> | <code>10</code> | Specify the number of items to display in a page |
|
||||
| page | No | <code>let</code> | Yes | <code>number</code> | <code>1</code> | Specify the current page index |
|
||||
| totalItems | No | <code>let</code> | No | <code>number</code> | <code>0</code> | Specify the total number of items |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the pagination |
|
||||
| forwardText | No | <code>let</code> | No | <code>string</code> | <code>"Next page"</code> | Specify the forward button text |
|
||||
| backwardText | No | <code>let</code> | No | <code>string</code> | <code>"Previous page"</code> | Specify the backward button text |
|
||||
| itemsPerPageText | No | <code>let</code> | No | <code>string</code> | <code>"Items per page:"</code> | Specify the items per page text |
|
||||
| itemText | No | <code>let</code> | No | <code>(min: number, max: number) => string</code> | <code>(min, max) => \`${min}–${max} item${max === 1 ? "" : "s"}\`</code> | Override the item text |
|
||||
| itemRangeText | No | <code>let</code> | No | <code>(min: number, max: number, total: number) => string</code> | <code>(min, max, total) => \`${min}–${max} of ${total} item${max === 1 ? "" : "s"}\`</code> | Override the item range text |
|
||||
| pageInputDisabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the page input |
|
||||
| pageSizeInputDisabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the page size input |
|
||||
| pageSizes | No | <code>let</code> | No | <code>ReadonlyArray<number></code> | <code>[10]</code> | Specify the available page sizes |
|
||||
| pagesUnknown | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` if the number of pages is unknown |
|
||||
| pageText | No | <code>let</code> | No | <code>(page: number) => string</code> | <code>(page) => \`page ${page}\`</code> | Override the page text |
|
||||
| pageRangeText | No | <code>let</code> | No | <code>(current: number, total: number) => string</code> | <code>(current, total) => \`of ${total} page${total === 1 ? "" : "s"}\`</code> | Override the page range text |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the top-level element |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------------------- | :------- | :--------------- | :------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| pageSize | No | <code>let</code> | Yes | <code>number</code> | <code>10</code> | Specify the number of items to display in a page |
|
||||
| page | No | <code>let</code> | Yes | <code>number</code> | <code>1</code> | Specify the current page index |
|
||||
| totalItems | No | <code>let</code> | No | <code>number</code> | <code>0</code> | Specify the total number of items |
|
||||
| pageWindow | No | <code>let</code> | No | <code>number</code> | <code>1000</code> | If `totalItems` is a large number, it can affect the<br />rendering performance of this component since its value<br />is used to calculate the number of pages in the native<br />select dropdown. This value creates a small window of<br />pages rendered around the current page. By default,<br />a maximum of 1000 select items are rendered. |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the pagination |
|
||||
| forwardText | No | <code>let</code> | No | <code>string</code> | <code>"Next page"</code> | Specify the forward button text |
|
||||
| backwardText | No | <code>let</code> | No | <code>string</code> | <code>"Previous page"</code> | Specify the backward button text |
|
||||
| itemsPerPageText | No | <code>let</code> | No | <code>string</code> | <code>"Items per page:"</code> | Specify the items per page text |
|
||||
| itemText | No | <code>let</code> | No | <code>(min: number, max: number) => string</code> | <code>(min, max) => \`${min.toLocaleString()}–${max.toLocaleString()} item${max === 1 ? "" : "s"}\`</code> | Override the item text |
|
||||
| itemRangeText | No | <code>let</code> | No | <code>(min: number, max: number, total: number) => string</code> | <code>(min, max, total) => \`${min.toLocaleString()}–${max.toLocaleString()} of ${total.toLocaleString()} item${max === 1 ? "" : "s"}\`</code> | Override the item range text |
|
||||
| pageInputDisabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the page input |
|
||||
| pageSizeInputDisabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the page size input |
|
||||
| pageSizes | No | <code>let</code> | No | <code>ReadonlyArray<number></code> | <code>[10]</code> | Specify the available page sizes |
|
||||
| pagesUnknown | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` if the number of pages is unknown |
|
||||
| pageText | No | <code>let</code> | No | <code>(page: number) => string</code> | <code>(page) => \`page ${page.toLocaleString()}\`</code> | Override the page text |
|
||||
| pageRangeText | No | <code>let</code> | No | <code>(current: number, total: number) => string</code> | <code>(current, total) => \`of ${total.toLocaleString()} page${total === 1 ? "" : "s"}\`</code> | Override the page range text |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the top-level element |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -2963,6 +2969,8 @@ None.
|
|||
|
||||
| Event name | Type | Detail |
|
||||
| :--------- | :-------- | :----- |
|
||||
| focus | forwarded | -- |
|
||||
| blur | forwarded | -- |
|
||||
| change | forwarded | -- |
|
||||
|
||||
## `RadioButtonGroup`
|
||||
|
@ -3105,24 +3113,24 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLInputElement</code> | <code>null</code> | Obtain a reference to the input HTML element |
|
||||
| expanded | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true to expand the search input |
|
||||
| value | No | <code>let</code> | Yes | <code>any</code> | <code>""</code> | Specify the value of the search input |
|
||||
| size | No | <code>let</code> | No | <code>"sm" | "lg" | "xl"</code> | <code>"xl"</code> | Specify the size of the search input |
|
||||
| searchClass | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the class name passed to the outer div element |
|
||||
| skeleton | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to display the skeleton state |
|
||||
| light | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the search input |
|
||||
| expandable | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the expandable variant |
|
||||
| placeholder | No | <code>let</code> | No | <code>string</code> | <code>"Search..."</code> | Specify the `placeholder` attribute of the search input |
|
||||
| autocomplete | No | <code>let</code> | No | <code>"on" | "off"</code> | <code>"off"</code> | Specify the `autocomplete` attribute |
|
||||
| autofocus | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to auto focus the search element |
|
||||
| closeButtonLabelText | No | <code>let</code> | No | <code>string</code> | <code>"Clear search input"</code> | Specify the close button label text |
|
||||
| labelText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render.<br />Defaults to `<Search />` |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the input element |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------------- | :------- | :--------------- | :------- | ----------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLInputElement</code> | <code>null</code> | Obtain a reference to the input HTML element |
|
||||
| expanded | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true to expand the search input |
|
||||
| value | No | <code>let</code> | Yes | <code>any</code> | <code>""</code> | Specify the value of the search input |
|
||||
| size | No | <code>let</code> | No | <code>"sm" | "lg" | "xl"</code> | <code>"xl"</code> | Specify the size of the search input |
|
||||
| searchClass | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the class name passed to the outer div element |
|
||||
| skeleton | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to display the skeleton state |
|
||||
| light | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the search input |
|
||||
| expandable | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the expandable variant |
|
||||
| placeholder | No | <code>let</code> | No | <code>string</code> | <code>"Search..."</code> | Specify the `placeholder` attribute of the search input |
|
||||
| autocomplete | No | <code>let</code> | No | <code>"on" | "off"</code> | <code>"off"</code> | Specify the `autocomplete` attribute |
|
||||
| autofocus | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to auto focus the search element |
|
||||
| closeButtonLabelText | No | <code>let</code> | No | <code>string</code> | <code>"Clear search input"</code> | Specify the close button label text |
|
||||
| labelText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render.<br />Defaults to `<Search />` |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the input element |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -3215,14 +3223,14 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------- | :------- | :--------------- | :------- | --------------------------------- | ---------------------- | ----------------------------------------- |
|
||||
| value | No | <code>let</code> | No | <code>string | number</code> | <code>""</code> | Specify the option value |
|
||||
| text | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the option text |
|
||||
| hidden | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to hide the option |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the option |
|
||||
| class | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the class of the `option` element |
|
||||
| style | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the style of the `option` element |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------- | :------- | :--------------- | :------- | --------------------------------- | ---------------------- | ---------------------------------------------------------------------------------- |
|
||||
| value | No | <code>let</code> | No | <code>string | number</code> | <code>""</code> | Specify the option value |
|
||||
| text | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the option text<br />If not specified, the value will be used as the text. |
|
||||
| hidden | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to hide the option |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the option |
|
||||
| class | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the class of the `option` element |
|
||||
| style | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the style of the `option` element |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -3367,13 +3375,13 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :--------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ---------------------- | --------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLAnchorElement</code> | <code>null</code> | Obtain a reference to the HTML anchor element |
|
||||
| isSelected | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to select the current link |
|
||||
| href | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the `href` attribute |
|
||||
| text | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the text |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :--------- | :------- | :--------------- | :------- | ------------------------------------------ | ---------------------- | --------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLAnchorElement</code> | <code>null</code> | Obtain a reference to the HTML anchor element |
|
||||
| isSelected | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to select the current link |
|
||||
| href | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the `href` attribute |
|
||||
| text | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the text |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -3392,12 +3400,12 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ---------------------- | --------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLButtonElement</code> | <code>null</code> | Obtain a reference to the HTML button element |
|
||||
| expanded | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to toggle the expanded state |
|
||||
| text | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the text |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------- | :------- | :--------------- | :------- | ------------------------------------------ | ---------------------- | --------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLButtonElement</code> | <code>null</code> | Obtain a reference to the HTML button element |
|
||||
| expanded | No | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to toggle the expanded state |
|
||||
| text | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the text |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -4011,7 +4019,7 @@ None.
|
|||
| interactive | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to render a `button` element instead of a `div` |
|
||||
| skeleton | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to display the skeleton state |
|
||||
| title | No | <code>let</code> | No | <code>string</code> | <code>"Clear filter"</code> | Set the title for the close button in a filterable tag |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the filterable tag |
|
||||
|
||||
### Slots
|
||||
|
@ -4575,7 +4583,7 @@ None.
|
|||
| align | No | <code>let</code> | No | <code>"start" | "center" | "end"</code> | <code>"center"</code> | Set the alignment of the tooltip relative to the icon |
|
||||
| direction | No | <code>let</code> | No | <code>"top" | "right" | "bottom" | "left"</code> | <code>"bottom"</code> | Set the direction of the tooltip relative to the button |
|
||||
| hideIcon | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to hide the tooltip icon |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render for the tooltip button.<br />Default to `<Information />` |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render for the tooltip button.<br />Default to `<Information />` |
|
||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the ARIA label for the tooltip button |
|
||||
| iconName | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the icon name attribute |
|
||||
| tabindex | No | <code>let</code> | No | <code>string</code> | <code>"0"</code> | Set the button tabindex |
|
||||
|
@ -4658,7 +4666,7 @@ None.
|
|||
| :---------- | :------- | :--------------- | :------- | --------------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------ |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLButtonElement</code> | <code>null</code> | Obtain a reference to the button HTML element |
|
||||
| tooltipText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the tooltip text.<br />Alternatively, use the "tooltipText" slot |
|
||||
| icon | No | <code>let</code> | No | <code>typeof import("svelte").SvelteComponent<any></code> | <code>undefined</code> | Specify the icon to render |
|
||||
| icon | No | <code>let</code> | No | <code>any</code> | <code>undefined</code> | Specify the icon to render |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the tooltip icon |
|
||||
| align | No | <code>let</code> | No | <code>"start" | "center" | "end"</code> | <code>"center"</code> | Set the alignment of the tooltip relative to the icon |
|
||||
| direction | No | <code>let</code> | No | <code>"top" | "right" | "bottom" | "left"</code> | <code>"bottom"</code> | Set the direction of the tooltip relative to the icon |
|
||||
|
@ -4691,7 +4699,7 @@ export type TreeNodeId = string | number;
|
|||
export interface TreeNode {
|
||||
id: TreeNodeId;
|
||||
text: any;
|
||||
icon?: typeof import("svelte").SvelteComponent<any>;
|
||||
icon?: any;
|
||||
disabled?: boolean;
|
||||
nodes?: TreeNode[];
|
||||
}
|
||||
|
@ -4699,20 +4707,20 @@ export interface TreeNode {
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------ | :------- | :-------------------- | :------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
|
||||
| expandedIds | No | <code>let</code> | Yes | <code>ReadonlyArray<TreeNodeId></code> | <code>[]</code> | Set the node ids to be expanded |
|
||||
| selectedIds | No | <code>let</code> | Yes | <code>ReadonlyArray<TreeNodeId></code> | <code>[]</code> | Set the node ids to be selected |
|
||||
| activeId | No | <code>let</code> | Yes | <code>TreeNodeId</code> | <code>""</code> | Set the current active node id<br />Only one node can be active |
|
||||
| nodes | No | <code>let</code> | No | <code>Array<TreeNode></code> | <code>[]</code> | Provide an array of nodes to render |
|
||||
| size | No | <code>let</code> | No | <code>"default" | "compact"</code> | <code>"default"</code> | Specify the TreeView size |
|
||||
| labelText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text |
|
||||
| hideLabel | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to visually hide the label text |
|
||||
| expandAll | No | <code>function</code> | No | <code>() => void</code> | <code>() => { expandedIds = [...nodeIds]; }</code> | Programmatically expand all nodes |
|
||||
| collapseAll | No | <code>function</code> | No | <code>() => void</code> | <code>() => { expandedIds = []; }</code> | Programmatically collapse all nodes |
|
||||
| expandNodes | No | <code>function</code> | No | <code>(filterId?: (node: TreeNode) => boolean) => void</code> | <code>() => { expandedIds = flattenedNodes .filter( (node) => filterNode(node) || node.nodes?.some((child) => filterNode(child) && child.nodes), ) .map((node) => node.id); }</code> | Programmatically expand a subset of nodes.<br />Expands all nodes if no argument is provided |
|
||||
| collapseNodes | No | <code>function</code> | No | <code>(filterId?: (node: TreeNode) => boolean) => void</code> | <code>() => { expandedIds = flattenedNodes .filter((node) => expandedIds.includes(node.id) && !filterNode(node)) .map((node) => node.id); }</code> | Programmatically collapse a subset of nodes.<br />Collapses all nodes if no argument is provided |
|
||||
| showNode | No | <code>function</code> | No | <code>(id: TreeNodeId) => void</code> | <code>() => { for (const child of nodes) { const nodes = findNodeById(child, id); if (nodes) { const ids = nodes.map((node) => node.id); const nodeIds = new Set(ids); expandNodes((node) => nodeIds.has(node.id)); const lastId = ids[ids.length - 1]; activeId = lastId; selectedIds = [lastId]; tick().then(() => { ref?.querySelector(\`[id="${lastId}"]\`)?.focus(); }); // Break out of the loop if the node is found. break; } } }</code> | Programmatically show a node by `id`.<br />The matching node will be expanded, selected, and focused |
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------ | :------- | :-------------------- | :------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
|
||||
| expandedIds | No | <code>let</code> | Yes | <code>ReadonlyArray<TreeNodeId></code> | <code>[]</code> | Set the node ids to be expanded |
|
||||
| selectedIds | No | <code>let</code> | Yes | <code>ReadonlyArray<TreeNodeId></code> | <code>[]</code> | Set the node ids to be selected |
|
||||
| activeId | No | <code>let</code> | Yes | <code>TreeNodeId</code> | <code>""</code> | Set the current active node id<br />Only one node can be active |
|
||||
| nodes | No | <code>let</code> | No | <code>Array<TreeNode></code> | <code>[]</code> | Provide an array of nodes to render |
|
||||
| size | No | <code>let</code> | No | <code>"default" | "compact"</code> | <code>"default"</code> | Specify the TreeView size |
|
||||
| labelText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text |
|
||||
| hideLabel | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to visually hide the label text |
|
||||
| expandAll | No | <code>function</code> | No | <code>() => void</code> | <code>() => { expandedIds = [...nodeIds]; }</code> | Programmatically expand all nodes |
|
||||
| collapseAll | No | <code>function</code> | No | <code>() => void</code> | <code>() => { expandedIds = []; }</code> | Programmatically collapse all nodes |
|
||||
| expandNodes | No | <code>function</code> | No | <code>(filterId?: (node: TreeNode) => boolean) => void</code> | <code>() => { expandedIds = flattenedNodes .filter( (node) => filterNode(node) || node.nodes?.some((child) => filterNode(child) && child.nodes), ) .map((node) => node.id); }</code> | Programmatically expand a subset of nodes.<br />Expands all nodes if no argument is provided |
|
||||
| collapseNodes | No | <code>function</code> | No | <code>(filterId?: (node: TreeNode) => boolean) => void</code> | <code>() => { expandedIds = flattenedNodes .filter((node) => expandedIds.includes(node.id) && !filterNode(node)) .map((node) => node.id); }</code> | Programmatically collapse a subset of nodes.<br />Collapses all nodes if no argument is provided |
|
||||
| showNode | No | <code>function</code> | No | <code>(id: TreeNodeId) => void</code> | <code>() => { for (const child of nodes) { const nodes = findNodeById(child, id); if (nodes) { const ids = nodes.map((node) => node.id); const nodeIds = new Set(ids); expandNodes((node) => nodeIds.has(node.id)); const lastId = ids[ids.length - 1]; activeId = lastId; selectedIds = [lastId]; tick().then(() => { ref?.querySelector(\`[id="${lastId}"]\`)?.focus(); }); break; } } }</code> | Programmatically show a node by `id`.<br />The matching node will be expanded, selected, and focused |
|
||||
|
||||
### Slots
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ Design systems facilitate design and development through reuse, consistency, and
|
|||
|
||||
The Carbon Svelte portfolio also includes:
|
||||
|
||||
- **[Carbon Icons Svelte](https://github.com/carbon-design-system/carbon-icons-svelte)**: 2,400+ Carbon icons as Svelte components
|
||||
- **[Carbon Pictograms Svelte](https://github.com/carbon-design-system/carbon-pictograms-svelte)**: 1,100+ Carbon pictograms as Svelte components
|
||||
- **[Carbon Charts Svelte](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/svelte)**: 20+ charts, powered by d3
|
||||
- **[Carbon Icons Svelte](https://github.com/carbon-design-system/carbon-icons-svelte)**: 2,500+ Carbon icons as Svelte components
|
||||
- **[Carbon Pictograms Svelte](https://github.com/carbon-design-system/carbon-pictograms-svelte)**: 1,300+ Carbon pictograms as Svelte components
|
||||
- **[Carbon Charts Svelte](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/svelte)**: 25+ charts, powered by d3
|
||||
- **[Carbon Preprocess Svelte](https://github.com/carbon-design-system/carbon-preprocess-svelte)**: Collection of Svelte preprocessors for Carbon
|
||||
|
||||
## [Documentation](https://svelte.carbondesignsystem.com)
|
||||
|
|
191
docs/package-lock.json
generated
191
docs/package-lock.json
generated
|
@ -8,7 +8,7 @@
|
|||
"@sveltech/routify": "^1.9.10",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||
"carbon-components-svelte": "file:..",
|
||||
"carbon-icons-svelte": "^12.13.0",
|
||||
"carbon-icons-svelte": "^13.3.0",
|
||||
"clipboard-copy": "^4.0.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"mdsvex": "^0.12.3",
|
||||
|
@ -17,15 +17,15 @@
|
|||
"prettier": "^2.8.8",
|
||||
"prettier-plugin-svelte": "^2.10.1",
|
||||
"prism-svelte": "^0.5.0",
|
||||
"prismjs": "^1.29.0",
|
||||
"prismjs": "^1.30.0",
|
||||
"remark-slug": "^6.1.0",
|
||||
"svelte": "^4.2.19",
|
||||
"vite": "^5.4.9"
|
||||
"vite": "^5.4.19"
|
||||
}
|
||||
},
|
||||
"..": {
|
||||
"name": "carbon-components-svelte",
|
||||
"version": "0.85.4",
|
||||
"version": "0.89.4",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
|
@ -34,19 +34,27 @@
|
|||
"flatpickr": "4.6.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^10.4.8",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@testing-library/svelte": "^5.2.8",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"carbon-components": "10.58.12",
|
||||
"carbon-icons-svelte": "^12.1.0",
|
||||
"postcss": "^8.4.16",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier-plugin-svelte": "^3.2.8",
|
||||
"carbon-icons-svelte": "^13.4.0",
|
||||
"carbon-preprocess-svelte": "^0.11.11",
|
||||
"culls": "^0.1.1",
|
||||
"jsdom": "^26.1.0",
|
||||
"postcss": "^8.5.5",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-svelte": "^3.4.0",
|
||||
"sass": "^1.49.11",
|
||||
"standard-version": "^9.5.0",
|
||||
"sveld": "^0.22.0",
|
||||
"svelte": "^4.2.10",
|
||||
"svelte-check": "^4.0.6",
|
||||
"tinyglobby": "^0.2.10",
|
||||
"typescript": "^5.6.3"
|
||||
"sveld": "^0.22.1",
|
||||
"svelte": "^4.2.20",
|
||||
"svelte-check": "^4.2.1",
|
||||
"tinyglobby": "^0.2.14",
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^3.2.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@ampproject/remapping": {
|
||||
|
@ -1027,14 +1035,28 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/carbon-components-svelte": {
|
||||
"resolved": "..",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/carbon-icons-svelte": {
|
||||
"version": "12.13.0",
|
||||
"resolved": "https://registry.npmjs.org/carbon-icons-svelte/-/carbon-icons-svelte-12.13.0.tgz",
|
||||
"integrity": "sha512-Tkp5Aa34GgAIQ5XSpD0JIKZTqiTUgtIt43SZxXuSDYvQjQ+HQVKNgYiDZ3oAA5etdcGT4O8+vDsVdGeL90Eezg==",
|
||||
"version": "13.3.0",
|
||||
"resolved": "https://registry.npmjs.org/carbon-icons-svelte/-/carbon-icons-svelte-13.3.0.tgz",
|
||||
"integrity": "sha512-pwOVRMYyct0KyzLPCwB7BdeO50lo3I3FclasSPgJiADm49YjYClewHnBsQOM2luu2JCLTdBnadtbVvWSpv+k+Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
|
@ -1389,6 +1411,21 @@
|
|||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"gopd": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/error-ex": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
|
||||
|
@ -1459,13 +1496,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
|
||||
"integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"get-intrinsic": "^1.2.4"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
|
@ -1480,10 +1515,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz",
|
||||
"integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==",
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
},
|
||||
|
@ -1492,14 +1528,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/es-set-tostringtag": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.3.tgz",
|
||||
"integrity": "sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==",
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
|
||||
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"get-intrinsic": "^1.2.4",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.6",
|
||||
"has-tostringtag": "^1.0.2",
|
||||
"hasown": "^2.0.1"
|
||||
"hasown": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
|
@ -1646,14 +1684,17 @@
|
|||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.2.tgz",
|
||||
"integrity": "sha512-sJe+TQb2vIaIyO783qN6BlMYWMw3WBOHA1Ay2qxsnjuafEOQFJ2JakedOQirT6D5XPRxDvS7AHYyem9fTpb4LQ==",
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.4.tgz",
|
||||
"integrity": "sha512-f0cRzm6dkyVYV3nPoooP8XlccPQukegwhAnpoLcXy+X+A8KfpGOoXwDr9FLZd3wzgLaBGQBE3lY93Zm/i1JvIQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
"es-set-tostringtag": "^2.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"mime-types": "^2.1.35"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
|
@ -1725,16 +1766,22 @@
|
|||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
|
||||
"integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"es-define-property": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.1.1",
|
||||
"function-bind": "^1.1.2",
|
||||
"has-proto": "^1.0.1",
|
||||
"has-symbols": "^1.0.3",
|
||||
"hasown": "^2.0.0"
|
||||
"get-proto": "^1.0.1",
|
||||
"gopd": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"math-intrinsics": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
|
@ -1743,6 +1790,20 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
"es-object-atoms": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/get-symbol-description": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.2.tgz",
|
||||
|
@ -1783,12 +1844,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
|
||||
"integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"get-intrinsic": "^1.1.3"
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
|
@ -1843,10 +1905,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
|
||||
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
|
@ -2409,6 +2472,16 @@
|
|||
"@jridgewell/sourcemap-codec": "^1.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/mdast-util-to-string": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-1.1.0.tgz",
|
||||
|
@ -2501,9 +2574,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.7",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
|
||||
"integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==",
|
||||
"version": "3.3.8",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz",
|
||||
"integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
|
@ -2953,10 +3026,11 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/prismjs": {
|
||||
"version": "1.29.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz",
|
||||
"integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==",
|
||||
"version": "1.30.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz",
|
||||
"integrity": "sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
|
@ -3700,10 +3774,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "5.4.9",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.9.tgz",
|
||||
"integrity": "sha512-20OVpJHh0PAM0oSOELa5GaZNWeDjcAvQjGXy2Uyr+Tp+/D2/Hdz6NLgpJLsarPTA2QJ6v8mX2P1ZfbsSKvdMkg==",
|
||||
"version": "5.4.19",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.19.tgz",
|
||||
"integrity": "sha512-qO3aKv3HoQC8QKiNSTuUM1l9o/XX3+c+VTgLHbJWHZGeTPVAg2XwazI9UWzoxjIJCGCV2zU60uqMzjeLZuULqA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.21.3",
|
||||
"postcss": "^8.4.43",
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"@sveltech/routify": "^1.9.10",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||
"carbon-components-svelte": "file:..",
|
||||
"carbon-icons-svelte": "^12.13.0",
|
||||
"carbon-icons-svelte": "^13.3.0",
|
||||
"clipboard-copy": "^4.0.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"mdsvex": "^0.12.3",
|
||||
|
@ -22,10 +22,10 @@
|
|||
"prettier": "^2.8.8",
|
||||
"prettier-plugin-svelte": "^2.10.1",
|
||||
"prism-svelte": "^0.5.0",
|
||||
"prismjs": "^1.29.0",
|
||||
"prismjs": "^1.30.0",
|
||||
"remark-slug": "^6.1.0",
|
||||
"svelte": "^4.2.19",
|
||||
"vite": "^5.4.9"
|
||||
"vite": "^5.4.19"
|
||||
},
|
||||
"routify": {
|
||||
"routifyDir": ".routify",
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,6 +7,7 @@
|
|||
typedefs: [],
|
||||
};
|
||||
|
||||
import { onMount } from "svelte";
|
||||
import {
|
||||
OutboundLink,
|
||||
StructuredList,
|
||||
|
@ -17,10 +18,16 @@
|
|||
UnorderedList,
|
||||
ListItem,
|
||||
Tag,
|
||||
CodeSnippet,
|
||||
} from "carbon-components-svelte";
|
||||
import InlineSnippet from "./InlineSnippet.svelte";
|
||||
|
||||
let AsyncPreviewTypeScript;
|
||||
|
||||
onMount(async () => {
|
||||
AsyncPreviewTypeScript = (await import("./PreviewTypeScript.svelte"))
|
||||
.default;
|
||||
});
|
||||
|
||||
const mdn_api = "https://developer.mozilla.org/en-US/docs/Web/API/";
|
||||
const typeMap = {
|
||||
string: "string",
|
||||
|
@ -55,13 +62,22 @@
|
|||
<StructuredListRow head>
|
||||
<StructuredListCell head>Prop name</StructuredListCell>
|
||||
<StructuredListCell head>Type</StructuredListCell>
|
||||
<StructuredListCell head noWrap>Default value</StructuredListCell>
|
||||
<StructuredListCell head>Description</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
</StructuredListHead>
|
||||
<StructuredListBody>
|
||||
{#each component.props.sort((a, b) => {
|
||||
if (a.reactive > b.reactive) return -1;
|
||||
// Sort props so required props are listed first, then reactive props.
|
||||
|
||||
if (a.isRequired !== b.isRequired) {
|
||||
return b.isRequired ? 1 : -1;
|
||||
}
|
||||
|
||||
if (a.reactive !== b.reactive) {
|
||||
return b.reactive ? 1 : -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}) as prop (prop.name)}
|
||||
<StructuredListRow>
|
||||
<StructuredListCell noWrap>
|
||||
|
@ -95,18 +111,29 @@
|
|||
{type}
|
||||
</OutboundLink>
|
||||
{:else if type in typeMap}
|
||||
<code class="code-01">{typeMap[type]}</code>
|
||||
{:else if type.startsWith("(")}
|
||||
<code class="code-01">{type}</code>
|
||||
<div
|
||||
style="display: inline-flex; max-width: 220px; word-break: break-word;"
|
||||
>
|
||||
<svelte:component
|
||||
this={AsyncPreviewTypeScript}
|
||||
type="inline"
|
||||
code={typeMap[type]}
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
<InlineSnippet code={type} />
|
||||
<div
|
||||
style="display: inline-flex; max-width: 220px; word-break: break-word;"
|
||||
>
|
||||
<svelte:component
|
||||
this={AsyncPreviewTypeScript}
|
||||
type="inline"
|
||||
code={type}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</StructuredListCell>
|
||||
<StructuredListCell
|
||||
><code class="code-01">{prop.value}</code></StructuredListCell
|
||||
>
|
||||
<StructuredListCell>
|
||||
{#if prop.description}
|
||||
{#each prop.description.split("\n") as line}
|
||||
|
@ -117,9 +144,27 @@
|
|||
.replace(/`(.*?)`/g, "<code>$1</code>")}.
|
||||
</div>
|
||||
{/each}
|
||||
{:else}
|
||||
<div class="description">No description available.</div>
|
||||
{/if}
|
||||
<div
|
||||
style:margin-top="var(--cds-layout-02)"
|
||||
style:margin-bottom="var(--cds-spacing-03)"
|
||||
>
|
||||
<strong>Default value</strong>
|
||||
</div>
|
||||
<div
|
||||
style:margin-bottom="var(--cds-layout-01)"
|
||||
style:max-width="85%"
|
||||
>
|
||||
{#if prop.value === undefined}
|
||||
<em>undefined</em>
|
||||
{:else}
|
||||
<svelte:component
|
||||
this={AsyncPreviewTypeScript}
|
||||
type={/\n/.test(prop.value) ? "multi" : "inline"}
|
||||
code={prop.value}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
{/each}
|
||||
|
@ -133,23 +178,42 @@
|
|||
<h2 id="typedefs">Typedefs</h2>
|
||||
|
||||
{#if component.typedefs.length > 0}
|
||||
<CodeSnippet
|
||||
style="margin-top: var(--cds-spacing-08)"
|
||||
class="my-layout-01-03"
|
||||
type="multi"
|
||||
code="{component.typedefs.map((t) => t.ts).join(';\n\n')};"
|
||||
/>
|
||||
<div class="my-layout-01-03">
|
||||
<svelte:component
|
||||
this={AsyncPreviewTypeScript}
|
||||
code={component.typedefs.map((t) => t.ts).join("\n")}
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
<p class="my-layout-01-03">No typedefs.</p>
|
||||
{/if}
|
||||
|
||||
<h2 id="slots">Slots</h2>
|
||||
{#if component.slots.length > 0}
|
||||
<UnorderedList class="my-layout-01-03">
|
||||
{#each component.slots as slot (slot.name)}
|
||||
<ListItem>{slot.default ? "default" : slot.name}</ListItem>
|
||||
{/each}
|
||||
</UnorderedList>
|
||||
<StructuredList class="my-layout-01-03">
|
||||
<StructuredListHead>
|
||||
<StructuredListRow>
|
||||
<StructuredListCell>Slot name</StructuredListCell>
|
||||
<StructuredListCell>Slot detail</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
</StructuredListHead>
|
||||
<StructuredListBody>
|
||||
{#each component.slots as slot (slot.name)}
|
||||
<StructuredListRow>
|
||||
<StructuredListCell>
|
||||
<strong>{slot.default ? "default" : slot.name}</strong>
|
||||
</StructuredListCell>
|
||||
<StructuredListCell>
|
||||
<svelte:component
|
||||
this={AsyncPreviewTypeScript}
|
||||
type={/\n/.test(slot.slot_props) ? "multi" : "inline"}
|
||||
code={slot.slot_props}
|
||||
/>
|
||||
</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
{/each}
|
||||
</StructuredListBody>
|
||||
</StructuredList>
|
||||
{:else}
|
||||
<p class="my-layout-01-03">No slots.</p>
|
||||
{/if}
|
||||
|
@ -173,7 +237,7 @@
|
|||
<StructuredListHead>
|
||||
<StructuredListRow>
|
||||
<StructuredListCell>Event name</StructuredListCell>
|
||||
<StructuredListCell><code>event.detail</code> type</StructuredListCell>
|
||||
<StructuredListCell>Event detail</StructuredListCell>
|
||||
{#if hasDescription}
|
||||
<StructuredListCell>Description</StructuredListCell>
|
||||
{/if}
|
||||
|
@ -186,7 +250,11 @@
|
|||
<strong>on:{event.name}</strong>
|
||||
</StructuredListCell>
|
||||
<StructuredListCell>
|
||||
<code>{event.detail}</code>
|
||||
<svelte:component
|
||||
this={AsyncPreviewTypeScript}
|
||||
type={/\n/.test(event.detail) ? "multi" : "inline"}
|
||||
code={event.detail}
|
||||
/>
|
||||
</StructuredListCell>
|
||||
<StructuredListCell>
|
||||
{event.description ?? ""}
|
||||
|
@ -217,6 +285,7 @@
|
|||
<style>
|
||||
.description {
|
||||
margin-bottom: var(--cds-spacing-04);
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.cell {
|
||||
|
@ -244,7 +313,11 @@
|
|||
word-break: break-word;
|
||||
}
|
||||
|
||||
:global(.cell .bx--snippet--inline code, .bx--snippet--single pre) {
|
||||
:global(
|
||||
.cell .bx--snippet--inline code,
|
||||
.cell .bx--snippet--single pre,
|
||||
.bx--snippet--inline code
|
||||
) {
|
||||
white-space: pre-wrap !important;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
{/if}
|
||||
<div class="preview-viewer" class:framed>
|
||||
{#if framed}
|
||||
<iframe title={src.split("/").pop()} src={themedSrcUrl}></iframe>
|
||||
<iframe loading="lazy" title={src.split("/").pop()} src={themedSrcUrl}
|
||||
></iframe>
|
||||
{:else}
|
||||
<slot />
|
||||
{/if}
|
||||
|
|
29
docs/src/components/PreviewTypeScript.svelte
Normal file
29
docs/src/components/PreviewTypeScript.svelte
Normal file
|
@ -0,0 +1,29 @@
|
|||
<script>
|
||||
export let code = "";
|
||||
export let type = "multi";
|
||||
|
||||
import { CodeSnippet } from "carbon-components-svelte";
|
||||
import { highlight } from "prismjs";
|
||||
import "prismjs/components/prism-typescript";
|
||||
import copy from "clipboard-copy";
|
||||
|
||||
$: highlightedCode = highlight(
|
||||
code,
|
||||
Prism.languages.typescript,
|
||||
"typescript",
|
||||
);
|
||||
</script>
|
||||
|
||||
{#if type === "multi"}
|
||||
<div class="code-override">
|
||||
<CodeSnippet type="multi" {code} {copy}>
|
||||
{@html highlightedCode}
|
||||
</CodeSnippet>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if type === "inline"}
|
||||
<CodeSnippet type="inline" class="code-override-inline" {code} {copy}>
|
||||
{@html highlightedCode}
|
||||
</CodeSnippet>
|
||||
{/if}
|
|
@ -2,12 +2,19 @@ html[theme="g90"] .code-override {
|
|||
border: 1px solid var(--cds-ui-03);
|
||||
}
|
||||
|
||||
.prose > pre,
|
||||
.code-override .bx--snippet {
|
||||
/** Docs code snippet is always dark mode */
|
||||
color-scheme: dark;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.prose > pre {
|
||||
padding: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.prose > pre,
|
||||
.code-override .bx--copy-btn,
|
||||
.code-override .bx--snippet,
|
||||
.code-override button.bx--btn.bx--snippet-btn--expand {
|
||||
|
@ -24,6 +31,7 @@ html[theme="g90"] .code-override {
|
|||
fill: #f4f4f4;
|
||||
}
|
||||
|
||||
.prose > pre,
|
||||
.code-override .bx--snippet-container pre {
|
||||
font-size: var(--cds-code-02-font-size);
|
||||
line-height: var(--cds-code-02-line-height);
|
||||
|
@ -45,6 +53,18 @@ html[theme="g90"] .code-override {
|
|||
color: #6ea6ff;
|
||||
}
|
||||
|
||||
/* Override syntax highlighting for light theme inline code .*/
|
||||
[theme="white"] .code-override-inline .token,
|
||||
[theme="g10"] .code-override-inline .token {
|
||||
color: var(--cds-text-01, #161616);
|
||||
}
|
||||
|
||||
/** Gray 80 is the "lighted" dark theme. Ensure the background is dark. */
|
||||
[theme="g80"] .code-override-inline {
|
||||
background-color: #262626;
|
||||
}
|
||||
|
||||
.token.builtin,
|
||||
.token.attr-name {
|
||||
color: #3ddbd9; /* teal 30 */
|
||||
}
|
||||
|
|
|
@ -10,8 +10,15 @@ components: ["Accordion", "AccordionItem", "AccordionSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Accordion` creates a vertically stacked list of expandable sections that show or hide content. It supports custom titles, different sizes, and various states including disabled and skeleton loading.
|
||||
|
||||
## Default
|
||||
|
||||
Use the `Accordion` and `AccordionItem` components to compose a collapsible list of
|
||||
items.
|
||||
|
||||
By default, the chevron icon is on the right side of the accordion item.
|
||||
|
||||
<Accordion>
|
||||
<AccordionItem title="Natural Language Classifier">
|
||||
<p>Natural Language Classifier uses advanced natural language processing and machine learning techniques to create custom classification models. Users train their data and the service predicts the appropriate category for the inputted text.
|
||||
|
@ -27,6 +34,10 @@ components: ["Accordion", "AccordionItem", "AccordionSkeleton"]
|
|||
|
||||
## Left-aligned chevron
|
||||
|
||||
The chevron icon can be aligned to the left side of the accordion item by setting
|
||||
the `align` prop to "start". This provides an alternative visual style while
|
||||
maintaining the same functionality.
|
||||
|
||||
<Accordion align="start">
|
||||
<AccordionItem title="Natural Language Classifier">
|
||||
<p>Natural Language Classifier uses advanced natural language processing and machine learning techniques to create custom classification models. Users train their data and the service predicts the appropriate category for the inputted text.
|
||||
|
@ -42,6 +53,9 @@ components: ["Accordion", "AccordionItem", "AccordionSkeleton"]
|
|||
|
||||
## Custom title slot
|
||||
|
||||
Customize the title content by using the `title` slot instead of the `title` prop.
|
||||
This allows for more complex title layouts with multiple elements.
|
||||
|
||||
<Accordion>
|
||||
<AccordionItem>
|
||||
<svelte:fragment slot="title">
|
||||
|
@ -69,6 +83,9 @@ components: ["Accordion", "AccordionItem", "AccordionSkeleton"]
|
|||
|
||||
## First item open
|
||||
|
||||
Set the `open` prop on an `AccordionItem` to have it expanded by default when the
|
||||
accordion is first rendered.
|
||||
|
||||
<Accordion>
|
||||
<AccordionItem open title="Natural Language Classifier">
|
||||
<p>Natural Language Classifier uses advanced natural language processing and machine learning techniques to create custom classification models. Users train their data and the service predicts the appropriate category for the inputted text.
|
||||
|
@ -84,12 +101,18 @@ components: ["Accordion", "AccordionItem", "AccordionSkeleton"]
|
|||
|
||||
## Programmatic example
|
||||
|
||||
This example demonstrates how a list of items can be programmatically expanded and collapsed.
|
||||
This example demonstrates how to programmatically control the accordion items using
|
||||
the `bind:open` directive. Expand and collapse items based on user
|
||||
interactions or application state.
|
||||
|
||||
<FileSource src="/framed/Accordion/ExpandableAccordion" />
|
||||
|
||||
## Extra-large size
|
||||
|
||||
The accordion can be displayed in an extra-large size by setting the `size` prop to
|
||||
"xl". This provides more visual emphasis and is suitable for prominent content
|
||||
sections.
|
||||
|
||||
<Accordion size="xl">
|
||||
<AccordionItem title="Natural Language Classifier">
|
||||
<p>Natural Language Classifier uses advanced natural language processing and machine learning techniques to create custom classification models. Users train their data and the service predicts the appropriate category for the inputted text.
|
||||
|
@ -105,6 +128,10 @@ This example demonstrates how a list of items can be programmatically expanded a
|
|||
|
||||
## Small size
|
||||
|
||||
For more compact layouts, set the `size` prop to "sm" to display the accordion in a
|
||||
smaller size. This is useful when space is limited or when the accordion is used as
|
||||
a secondary UI element.
|
||||
|
||||
<Accordion size="sm">
|
||||
<AccordionItem title="Natural Language Classifier">
|
||||
<p>Natural Language Classifier uses advanced natural language processing and machine learning techniques to create custom classification models. Users train their data and the service predicts the appropriate category for the inputted text.
|
||||
|
@ -120,6 +147,9 @@ This example demonstrates how a list of items can be programmatically expanded a
|
|||
|
||||
## Disabled
|
||||
|
||||
Set the `disabled` prop on the `Accordion` component to disable all items at once.
|
||||
This prevents users from expanding or collapsing any items in the accordion.
|
||||
|
||||
<Accordion disabled>
|
||||
<AccordionItem title="Natural Language Classifier">
|
||||
<p>Natural Language Classifier uses advanced natural language processing and machine learning techniques to create custom classification models. Users train their data and the service predicts the appropriate category for the inputted text.
|
||||
|
@ -135,6 +165,10 @@ This example demonstrates how a list of items can be programmatically expanded a
|
|||
|
||||
## Disabled (item)
|
||||
|
||||
Individual accordion items can be disabled by setting the `disabled` prop on
|
||||
specific `AccordionItem` components. This allows for more granular control over
|
||||
which items are interactive.
|
||||
|
||||
<Accordion>
|
||||
<AccordionItem disabled title="Natural Language Classifier">
|
||||
<p>Natural Language Classifier uses advanced natural language processing and machine learning techniques to create custom classification models. Users train their data and the service predicts the appropriate category for the inputted text.
|
||||
|
@ -150,25 +184,45 @@ This example demonstrates how a list of items can be programmatically expanded a
|
|||
|
||||
## Skeleton
|
||||
|
||||
The skeleton state provides a loading placeholder for the accordion. It displays a
|
||||
simplified version of the component while content is being loaded.
|
||||
|
||||
<Accordion skeleton />
|
||||
|
||||
## Skeleton (left-aligned chevron)
|
||||
|
||||
The skeleton state can be combined with the left-aligned chevron style by setting
|
||||
both the `skeleton` and `align="start"` props.
|
||||
|
||||
<Accordion skeleton align="start" />
|
||||
|
||||
## Skeleton (custom count)
|
||||
|
||||
By default, the skeleton state displays 4 items.
|
||||
|
||||
Specify the number of skeleton items to display using the `count` prop. This is
|
||||
useful when you know the exact number of items that will be loaded.
|
||||
|
||||
<Accordion skeleton count={3} />
|
||||
|
||||
## Skeleton (closed)
|
||||
|
||||
By default, the first skeleton item is open. The skeleton state can be displayed
|
||||
in a collapsed state by setting `open={false}`.
|
||||
|
||||
<Accordion skeleton open={false} />
|
||||
|
||||
## Skeleton (extra-large)
|
||||
|
||||
The skeleton state supports the extra-large size variant, maintaining visual
|
||||
consistency with the active component states.
|
||||
|
||||
<Accordion skeleton size="xl" />
|
||||
|
||||
## Skeleton (small)
|
||||
|
||||
The skeleton state also supports the small size variant, providing a compact
|
||||
loading placeholder for space-constrained layouts.
|
||||
|
||||
<Accordion skeleton size="sm" />
|
||||
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
The `AspectRatio` component is useful for constraining fluid content within an aspect ratio. To demo this, resize your browser for the examples below.
|
||||
The `AspectRatio` component maintains consistent proportions for content across different screen sizes. It's particularly useful for images, videos, and other media that need to preserve their aspect ratio when resizing.
|
||||
|
||||
Supported aspect ratios include `"2x1"`, `"2x3"`, `"16x9"`, `"4x3"`, `"1x1"`, `"3x4"`, `"3x2"`, `"9x16"` and `"1x2"`.
|
||||
|
||||
## Default (2x1)
|
||||
## Default
|
||||
|
||||
Display a 2:1 aspect ratio container by default.
|
||||
|
||||
<AspectRatio>
|
||||
2x1
|
||||
|
|
|
@ -12,8 +12,12 @@ components: ["Breadcrumb", "BreadcrumbItem"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Breadcrumb` displays a hierarchical navigation trail that shows users their current location within an application. It supports current page indication, trailing slash customization, and overflow handling for long navigation paths.
|
||||
|
||||
## Default
|
||||
|
||||
Display a hierarchical navigation trail with slashes between items. Mark the current page with `isCurrentPage`.
|
||||
|
||||
<Breadcrumb>
|
||||
<BreadcrumbItem href="/">Dashboard</BreadcrumbItem>
|
||||
<BreadcrumbItem href="/reports">Annual reports</BreadcrumbItem>
|
||||
|
@ -22,6 +26,8 @@ components: ["Breadcrumb", "BreadcrumbItem"]
|
|||
|
||||
## No trailing slash
|
||||
|
||||
Remove the trailing slash from the last breadcrumb item using `noTrailingSlash`.
|
||||
|
||||
<Breadcrumb noTrailingSlash>
|
||||
<BreadcrumbItem href="/">Home</BreadcrumbItem>
|
||||
<BreadcrumbItem href="/profile" isCurrentPage>Profile</BreadcrumbItem>
|
||||
|
@ -29,6 +35,8 @@ components: ["Breadcrumb", "BreadcrumbItem"]
|
|||
|
||||
## Overflow menu
|
||||
|
||||
Add an `OverflowMenu` to handle long breadcrumb trails. Use `OverflowMenuItem` components for menu options.
|
||||
|
||||
<Breadcrumb>
|
||||
<BreadcrumbItem href="/">Home</BreadcrumbItem>
|
||||
<BreadcrumbItem href="/api">API documentation</BreadcrumbItem>
|
||||
|
@ -47,4 +55,6 @@ components: ["Breadcrumb", "BreadcrumbItem"]
|
|||
|
||||
## Skeleton
|
||||
|
||||
Display a loading state with `skeleton` prop. Use `count` to specify the number of items.
|
||||
|
||||
<Breadcrumb noTrailingSlash skeleton count={3} />
|
|
@ -1,12 +1,12 @@
|
|||
|
||||
<script>
|
||||
import {
|
||||
Breakpoint, UnorderedList, ListItem
|
||||
UnorderedList, ListItem
|
||||
} from "carbon-components-svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
The [Carbon Design System grid implementation](https://carbondesignsystem.com/guidelines/2x-grid/implementation#responsive-options) defines five responsive breakpoints:
|
||||
The Carbon Design System [grid implementation](https://carbondesignsystem.com/guidelines/2x-grid/implementation#responsive-options) defines five responsive breakpoints:
|
||||
|
||||
<UnorderedList svx-ignore style="margin-bottom: var(--cds-spacing-08)">
|
||||
<ListItem><strong>Small</strong>: less than 672px</ListItem>
|
||||
|
@ -28,8 +28,8 @@ The `"on:change"` event will fire when the size is initially determined and when
|
|||
|
||||
## Store and Breakpoint Values
|
||||
|
||||
As an alternative to the component, `breakpointObserver` can be used to get the current size as a Svelte store. The store has two additional functions which create derived stores that return a `boolean` indicating whether the size is smaller/larger than a certain breakpoint.
|
||||
Use `breakpointObserver` as an alternative to the component to get the current size as a Svelte store. The store provides two additional functions that create derived stores returning a `boolean` indicating whether the size is smaller/larger than a certain breakpoint.
|
||||
|
||||
There also exists a `breakpoints` dictionary mapping from `BreakpointSize` to `BreakpointValue`.
|
||||
Access the `breakpoints` dictionary to map from `BreakpointSize` to `BreakpointValue`.
|
||||
|
||||
<FileSource src="/framed/Breakpoint/BreakpointObserver" />
|
||||
|
|
|
@ -4,57 +4,73 @@
|
|||
import TrashCan from "carbon-icons-svelte/lib/TrashCan.svelte";
|
||||
import Login from "carbon-icons-svelte/lib/Login.svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
|
||||
let index = 1;
|
||||
</script>
|
||||
|
||||
Buttons trigger actions in the interface. Use them to submit forms, navigate between pages, or perform specific tasks. Choose from different styles and sizes to match the importance and context of each action.
|
||||
|
||||
## Primary button
|
||||
|
||||
The default button style is primary. This should be used for primary actions.
|
||||
|
||||
<Button>Primary button</Button>
|
||||
|
||||
## Secondary button
|
||||
|
||||
Set `kind="secondary"` for secondary actions.
|
||||
|
||||
<Button kind="secondary">Secondary button</Button>
|
||||
|
||||
## Tertiary button
|
||||
|
||||
Set `kind="tertiary"` for tertiary actions.
|
||||
|
||||
<Button kind="tertiary">Tertiary button</Button>
|
||||
|
||||
## Ghost button
|
||||
|
||||
Set `kind="ghost"` for ghost-style buttons.
|
||||
|
||||
<Button kind="ghost">Ghost button</Button>
|
||||
|
||||
## Danger button
|
||||
|
||||
Set `kind="danger"` for destructive actions.
|
||||
|
||||
<Button kind="danger">Danger button</Button>
|
||||
|
||||
## Danger tertiary button
|
||||
|
||||
Set `kind="danger-tertiary"` for less prominent destructive actions.
|
||||
|
||||
<Button kind="danger-tertiary">Danger tertiary button</Button>
|
||||
|
||||
## Danger tertiary, icon-only button
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">
|
||||
You must provide an <strong>iconDescription</strong> for the button tooltip.
|
||||
Provide an <strong>iconDescription</strong> for accessibility. This text will be used as the button's tooltip and screen reader label.
|
||||
</div>
|
||||
</InlineNotification>
|
||||
|
||||
<Button kind="danger-tertiary"iconDescription="Delete" icon={TrashCan} />
|
||||
<Button kind="danger-tertiary" iconDescription="Delete" icon={TrashCan} />
|
||||
|
||||
## Danger ghost button
|
||||
|
||||
Set `kind="danger-ghost"` for ghost-style destructive actions.
|
||||
|
||||
<Button kind="danger-ghost">Danger ghost button</Button>
|
||||
|
||||
## Button with icon
|
||||
|
||||
Add an icon to the button using the `icon` prop.
|
||||
|
||||
<Button icon={Add}>With icon</Button>
|
||||
|
||||
## Icon-only button
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">
|
||||
You must provide an <strong>iconDescription</strong> for the button tooltip.
|
||||
Provide an <strong>iconDescription</strong> for accessibility. This text will be used as the button's tooltip and screen reader label.
|
||||
</div>
|
||||
</InlineNotification>
|
||||
|
||||
|
@ -62,11 +78,13 @@
|
|||
|
||||
## Icon-only, link button
|
||||
|
||||
Set `href` to create an icon-only link button.
|
||||
|
||||
<Button iconDescription="Login" icon={Login} href="#" />
|
||||
|
||||
## Icon-only button (custom tooltip position)
|
||||
|
||||
The tooltip position and alignment can be controlled by `tooltipPosition` and `tooltipAlignment`.
|
||||
Control the tooltip position and alignment with `tooltipPosition` and `tooltipAlignment`.
|
||||
|
||||
<Button tooltipPosition="right" tooltipAlignment="end" iconDescription="Tooltip text" icon={Add} />
|
||||
|
||||
|
@ -78,19 +96,21 @@ Set `isSelected` to `true` to enable the selected state for an icon-only, ghost
|
|||
|
||||
## Link button
|
||||
|
||||
If an `href` value is specified, the component will render an [anchor element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) instead of a `button` element.
|
||||
Set `href` to render an [anchor element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) instead of a `button` element.
|
||||
|
||||
<Button href="#">Link button</Button>
|
||||
|
||||
## Link button with icon
|
||||
|
||||
Similarly, link buttons can have icons.
|
||||
|
||||
<Button href="#" icon={Add}>Link button with icon</Button>
|
||||
|
||||
## Custom element
|
||||
|
||||
By default, the `Button` will render either a `button` or `a` element.
|
||||
|
||||
If you need to render a different element, set `as` to `true` and spread `let:props` to the element.
|
||||
To render a different element, set `as` to `true` and spread `let:props` to the element.
|
||||
|
||||
<Button as let:props>
|
||||
<p {...props}>Custom element</p>
|
||||
|
@ -98,6 +118,10 @@ If you need to render a different element, set `as` to `true` and spread `let:pr
|
|||
|
||||
## Field size
|
||||
|
||||
The default size is "default".
|
||||
|
||||
Set `size="field"` for field-sized buttons.
|
||||
|
||||
<Button size="field">Primary</Button>
|
||||
<Button size="field" kind="secondary">Secondary</Button>
|
||||
<Button size="field" kind="tertiary">Tertiary</Button>
|
||||
|
@ -106,6 +130,8 @@ If you need to render a different element, set `as` to `true` and spread `let:pr
|
|||
|
||||
## Small size
|
||||
|
||||
Set `size="small"` for small buttons.
|
||||
|
||||
<Button size="small">Primary</Button>
|
||||
<Button size="small" kind="secondary">Secondary</Button>
|
||||
<Button size="small" kind="tertiary">Tertiary</Button>
|
||||
|
@ -114,6 +140,8 @@ If you need to render a different element, set `as` to `true` and spread `let:pr
|
|||
|
||||
## Large size
|
||||
|
||||
Set `size="lg"` for large buttons.
|
||||
|
||||
<Button size="lg">Primary</Button>
|
||||
<Button size="lg" kind="secondary">Secondary</Button>
|
||||
<Button size="lg" kind="tertiary">Tertiary</Button>
|
||||
|
@ -122,6 +150,8 @@ If you need to render a different element, set `as` to `true` and spread `let:pr
|
|||
|
||||
## Extra-large size
|
||||
|
||||
Set `size="xl"` for extra-large buttons.
|
||||
|
||||
<Button size="xl">Primary</Button>
|
||||
<Button size="xl" kind="secondary">Secondary</Button>
|
||||
<Button size="xl" kind="tertiary">Tertiary</Button>
|
||||
|
@ -130,6 +160,8 @@ If you need to render a different element, set `as` to `true` and spread `let:pr
|
|||
|
||||
## Disabled state
|
||||
|
||||
Set `disabled` to disable the button.
|
||||
|
||||
<Button disabled>Disabled button</Button>
|
||||
<Button disabled iconDescription="Tooltip text" icon={Add} />
|
||||
|
||||
|
@ -139,7 +171,7 @@ Set `expressive` to `true` to use Carbon's expressive typesetting.
|
|||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">
|
||||
Expressive styles only work with the default, "lg", and "xl" button sizes.
|
||||
Use expressive styles with default, "lg", or "xl" button sizes.
|
||||
</div>
|
||||
</InlineNotification>
|
||||
|
||||
|
@ -163,6 +195,8 @@ Set `expressive` to `true` to use Carbon's expressive typesetting.
|
|||
|
||||
## Skeleton
|
||||
|
||||
Set `skeleton` to show a loading state.
|
||||
|
||||
<Button size="xl" skeleton />
|
||||
<Button size="lg" skeleton />
|
||||
<Button skeleton />
|
||||
|
@ -171,8 +205,6 @@ Set `expressive` to `true` to use Carbon's expressive typesetting.
|
|||
|
||||
## Programmatic focus
|
||||
|
||||
Bind to the `ref` prop to access a reference to the underlying button element.
|
||||
|
||||
You can use this reference to programmatically focus the button.
|
||||
Bind to the `ref` prop to access the button element for programmatic focus.
|
||||
|
||||
<FileSource src="/framed/Button/ProgrammaticFocus" />
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
Group related buttons together in a set. Use this component to create consistent spacing and alignment between multiple buttons.
|
||||
|
||||
## Default
|
||||
|
||||
Buttons in a button set are juxtaposed by default.
|
||||
Place buttons side by side in a horizontal layout.
|
||||
|
||||
<ButtonSet>
|
||||
<Button kind="secondary">Cancel</Button>
|
||||
|
@ -15,7 +17,7 @@ Buttons in a button set are juxtaposed by default.
|
|||
|
||||
## Stacked
|
||||
|
||||
Set `stacked` to `true` to use the stacked variant.
|
||||
Set `stacked` to `true` to arrange buttons vertically.
|
||||
|
||||
<ButtonSet stacked>
|
||||
<Button icon={Login}>Log in</Button>
|
||||
|
|
|
@ -3,39 +3,53 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
## Default (unchecked)
|
||||
Checkboxes let users select one or more options from a list. Use them for multiple-choice questions, settings, or to confirm actions.
|
||||
|
||||
## Default
|
||||
|
||||
Create a checkbox with a label using `labelText`.
|
||||
|
||||
By default, the checkbox is unchecked.
|
||||
|
||||
<Checkbox labelText="Label text" />
|
||||
|
||||
## Checked
|
||||
|
||||
Set `checked` to `true` to pre-select the checkbox.
|
||||
|
||||
<Checkbox labelText="Label text" checked />
|
||||
|
||||
## Indeterminate
|
||||
|
||||
Set `indeterminate` to `true` to show a mixed state, typically used in parent checkboxes with some children selected.
|
||||
|
||||
<Checkbox labelText="Label text" indeterminate />
|
||||
|
||||
## Hidden label
|
||||
|
||||
Set `hideLabel` to `true` to visually hide the label while keeping it accessible to screen readers.
|
||||
|
||||
<Checkbox labelText="Label text" hideLabel />
|
||||
|
||||
## Disabled
|
||||
## Disabled state
|
||||
|
||||
Set `disabled` to `true` to prevent user interaction.
|
||||
|
||||
<Checkbox labelText="Label text" disabled />
|
||||
|
||||
## Reactive example (bind:checked)
|
||||
|
||||
The `checked` prop supports two-way binding.
|
||||
Use two-way binding with `bind:checked` to track the checkbox state.
|
||||
|
||||
<FileSource src="/framed/Checkbox/CheckboxReactive" />
|
||||
|
||||
## Reactive example (bind:group)
|
||||
|
||||
An alternative to `checked` is binding an array of values using `group`. This API in inspired by Svelte [group inputs](https://svelte.dev/tutorial/group-inputs).
|
||||
Bind an array of values using `group` to manage multiple checkboxes. This API is inspired by Svelte [group inputs](https://svelte.dev/tutorial/group-inputs).
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">
|
||||
If using <strong>bind:group</strong>, <strong>bind:checked</strong> will only support one-way binding.
|
||||
When using <strong>bind:group</strong>, <strong>bind:checked</strong> only supports one-way binding.
|
||||
</div>
|
||||
</InlineNotification>
|
||||
|
||||
|
@ -43,4 +57,6 @@ An alternative to `checked` is binding an array of values using `group`. This AP
|
|||
|
||||
## Skeleton
|
||||
|
||||
Set `skeleton` to `true` to show a loading state.
|
||||
|
||||
<Checkbox skeleton />
|
||||
|
|
|
@ -3,15 +3,19 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
Clickable tiles create interactive content areas that link to other pages or trigger actions. Use them to group related content and provide clear navigation targets.
|
||||
|
||||
## Default
|
||||
|
||||
Create a clickable tile with an `href` to link to another page.
|
||||
|
||||
<ClickableTile href="https://www.carbondesignsystem.com/">
|
||||
Carbon Design System
|
||||
</ClickableTile>
|
||||
|
||||
## Prevent default behavior
|
||||
|
||||
Use the forwarded `click` event and invoke `e.preventDefault()` to prevent the native link behavior.
|
||||
Handle the `click` event to override the default link behavior. Use `e.preventDefault()` to stop navigation.
|
||||
|
||||
<ClickableTile
|
||||
href="/"
|
||||
|
@ -25,12 +29,16 @@ Use the forwarded `click` event and invoke `e.preventDefault()` to prevent the n
|
|||
|
||||
## Light variant
|
||||
|
||||
Set `light` to `true` to use the light color scheme.
|
||||
|
||||
<ClickableTile light href="https://www.carbondesignsystem.com/">
|
||||
Carbon Design System
|
||||
</ClickableTile>
|
||||
|
||||
## Disabled state
|
||||
|
||||
Set `disabled` to `true` to prevent interaction.
|
||||
|
||||
<ClickableTile disabled href="https://www.carbondesignsystem.com/">
|
||||
Carbon Design System
|
||||
</ClickableTile>
|
||||
|
|
|
@ -27,20 +27,21 @@ let comment = `
|
|||
`
|
||||
</script>
|
||||
|
||||
This component uses the native, asynchronous [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy text.
|
||||
Code snippets display and copy code examples. They support single-line, multi-line, and inline formats with customizable copy and expand functionality.
|
||||
|
||||
Please note that the `clipboard.writeText` API is not supported in [IE 11 nor Safari iOS version 13.3 or lower](https://caniuse.com/mdn-api_clipboard_writetext).
|
||||
This component uses the native, asynchronous [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy text.
|
||||
|
||||
You can override the default copy functionality with your own implementation. See [Overriding copy functionality](#overriding-copy-functionality).
|
||||
|
||||
## Default
|
||||
|
||||
## Default (single-line)
|
||||
Display a single-line code snippet by default.
|
||||
|
||||
<CodeSnippet code="npm i carbon-components-svelte" />
|
||||
|
||||
## Overriding copy functionality
|
||||
|
||||
To override the default copy behavior, pass a custom function to the `copy` prop.
|
||||
Pass a custom function to the `copy` prop to override the default copy behavior.
|
||||
|
||||
In this example, we use the open source module [clipboard-copy](https://github.com/feross/clipboard-copy) to copy the text instead of the default Clipboard API.
|
||||
|
||||
|
@ -48,33 +49,37 @@ In this example, we use the open source module [clipboard-copy](https://github.c
|
|||
|
||||
## Preventing copy functionality
|
||||
|
||||
To prevent text from being copied entirely, pass a no-op function to the `copy` prop.
|
||||
Pass a no-op function to the `copy` prop to disable copying.
|
||||
|
||||
<CodeSnippet code="npm i carbon-components-svelte" copy={() => {}} />
|
||||
|
||||
## Inline
|
||||
|
||||
Set `type="inline"` to display code inline with text.
|
||||
|
||||
<CodeSnippet type="inline" code="rm -rf node_modules/" />
|
||||
|
||||
## Multi-line
|
||||
|
||||
Set `type="multi"` to display multiple lines of code with expand/collapse functionality.
|
||||
|
||||
<CodeSnippet type="multi" {code} />
|
||||
|
||||
## Expanded by default
|
||||
|
||||
Use the `expanded` prop to control whether the multi-line code snippet is expanded or not.
|
||||
Set `expanded` to `true` to show the full multi-line code snippet.
|
||||
|
||||
<CodeSnippet type="multi" {code} expanded />
|
||||
|
||||
## Reactive example
|
||||
|
||||
The multi-line code snippet also dispatches "expand" and "collapse" events.
|
||||
The multi-line code snippet dispatches "expand" and "collapse" events.
|
||||
|
||||
<FileSource src="/framed/CodeSnippet/CodeSnippetReactive" />
|
||||
|
||||
## Custom copy feedback text
|
||||
|
||||
Use the `feedback` prop to override the default copy button feedback text.
|
||||
Set `feedback` to customize the copy button feedback text.
|
||||
|
||||
<CodeSnippet type="multi" {code} feedback="Copied to clipboard" />
|
||||
|
||||
|
@ -86,23 +91,25 @@ Set `hideCopyButton` to `true` to hide the copy button.
|
|||
|
||||
## Hidden show more button
|
||||
|
||||
Only multi-line code snippets have a "Show more" button by default. Set `showMoreLess` to `false` to hide it.
|
||||
Set `showMoreLess` to `false` to hide the expand/collapse button on multi-line snippets.
|
||||
|
||||
<CodeSnippet type="multi" {code} showMoreLess={false} />
|
||||
|
||||
## Hidden copy, show more buttons
|
||||
|
||||
Hide both the copy and expand/collapse buttons.
|
||||
|
||||
<CodeSnippet type="multi" {code} hideCopyButton showMoreLess={false} />
|
||||
|
||||
## Custom show more/less text
|
||||
|
||||
Use the `showMoreText` and `showLessText` props to override the default "Show more" and "Show less" button text.
|
||||
Set `showMoreText` and `showLessText` to customize the expand/collapse button text.
|
||||
|
||||
<CodeSnippet type="multi" {code} showMoreText="Expand" showLessText="Collapse" />
|
||||
|
||||
## Disabled
|
||||
|
||||
The `disabled` prop applies only to the `"single"` and `"multi"` code snippet types.
|
||||
Set `disabled` to `true` to disable interaction. This only applies to `"single"` and `"multi"` types.
|
||||
|
||||
<CodeSnippet disabled code="npm i carbon-components-svelte" />
|
||||
<br />
|
||||
|
@ -110,30 +117,34 @@ The `disabled` prop applies only to the `"single"` and `"multi"` code snippet ty
|
|||
|
||||
## Wrapped text
|
||||
|
||||
`wrapText` only applies to the `"multi"` type.
|
||||
By default, the code snippet preserves text formatting and does not wrap text.
|
||||
|
||||
Set `wrapText` to `true` to wrap long lines in multi-line snippets.
|
||||
|
||||
<CodeSnippet wrapText type="multi" code="{comment}" />
|
||||
|
||||
## Dynamic multi-line code
|
||||
|
||||
For dynamically updated code, you must use the `code` prop instead of the default slot.
|
||||
Use the `code` prop instead of the default slot for dynamically updated code.
|
||||
|
||||
<FileSource src="/framed/CodeSnippet/DynamicCodeSnippet" />
|
||||
|
||||
## Hidden multi-line code
|
||||
|
||||
There may be cases where your code snippet is hidden in the DOM. The logic to render the "Show more" button relies on the element's computed height. For hidden content, the button will not appear because the computed height is `0`.
|
||||
The "Show more" button relies on the element's computed height. For hidden content, the button won't appear because the height is `0`.
|
||||
|
||||
The recommended workaround is to re-render the component. See the example below.
|
||||
Re-render the component to fix this issue.
|
||||
|
||||
<FileSource src="/framed/CodeSnippet/HiddenCodeSnippet" />
|
||||
|
||||
## Skeleton
|
||||
|
||||
The default skeleton type is `"single"`.
|
||||
Set `skeleton` to `true` to show a loading state. Defaults to `"single"` type.
|
||||
|
||||
<CodeSnippet skeleton />
|
||||
|
||||
## Skeleton (multi-line)
|
||||
|
||||
Set `type="multi"` with `skeleton` to show a multi-line loading state.
|
||||
|
||||
<CodeSnippet type="multi" skeleton />
|
|
@ -3,6 +3,8 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`ComboBox` combines a text input with a dropdown menu to let users select from predefined options or enter custom values. It supports filtering, custom item rendering, and various states.
|
||||
|
||||
`ComboBox` is keyed for performance reasons.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
|
@ -11,6 +13,8 @@
|
|||
|
||||
## Default
|
||||
|
||||
Create a combobox with a title and placeholder text. Each item requires a unique `id` and `text`.
|
||||
|
||||
<ComboBox titleText="Contact" placeholder="Select contact method"
|
||||
items={[
|
||||
{id: "0", text: "Slack"},
|
||||
|
@ -20,12 +24,25 @@ items={[
|
|||
|
||||
## Custom slot
|
||||
|
||||
Override the default slot to customize the display of each item. Access the item and index through the `let:` directive.
|
||||
Override the default slot to customize how each item displays. Access the item and index through the `let:` directive.
|
||||
|
||||
<FileSource src="/framed/ComboBox/ComboBoxSlot" />
|
||||
|
||||
## Hidden label
|
||||
|
||||
Set `hideLabel` to `true` to visually hide the label while keeping it accessible to screen readers.
|
||||
|
||||
<ComboBox hideLabel titleText="Hidden Label" placeholder="Select contact method"
|
||||
items={[
|
||||
{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}
|
||||
]} />
|
||||
|
||||
## Initial selected id
|
||||
|
||||
Set `selectedId` to pre-select an item when the combobox loads.
|
||||
|
||||
<ComboBox titleText="Contact" placeholder="Select contact method"
|
||||
selectedId="1"
|
||||
items={[
|
||||
|
@ -36,33 +53,39 @@ items={[
|
|||
|
||||
## Reactive example
|
||||
|
||||
See how the combobox responds to user input and selection changes.
|
||||
|
||||
<FileSource src="/framed/ComboBox/ReactiveComboBox" />
|
||||
|
||||
## Clear selection
|
||||
|
||||
To programmatically clear the selection, access the component instance using the [bind:this](https://svelte.dev/docs#bind_element) directive and invoke the `ComboBox.clear()` accessor.
|
||||
Use `bind:this` to access the component instance and call `ComboBox.clear()` to programmatically clear the selection.
|
||||
|
||||
Specify `focus: false` in the method options to avoid re-focusing the input.
|
||||
Set `focus: false` in the method options to prevent re-focusing the input.
|
||||
|
||||
<FileSource src="/framed/ComboBox/ComboBoxClear" />
|
||||
|
||||
## Multiple combo boxes
|
||||
|
||||
See how to manage multiple comboboxes in a form.
|
||||
|
||||
<FileSource src="/framed/ComboBox/MultipleComboBox" />
|
||||
|
||||
## Filterable
|
||||
|
||||
Enable filtering to let users search through the options.
|
||||
|
||||
<FileSource src="/framed/ComboBox/FilterableComboBox" />
|
||||
|
||||
## Filterable with custom label
|
||||
|
||||
Combine a custom label `itemToString` with the filterable option (e.g., internationalization).
|
||||
Set `itemToString` to customize how items display in the filterable combobox.
|
||||
|
||||
<FileSource src="/framed/ComboBox/FilterableComboBoxCustomLabel" />
|
||||
|
||||
## Top direction
|
||||
|
||||
Set `direction` to `"top"` for the combobox dropdown menu to appear above the input.
|
||||
Set `direction` to `"top"` to make the dropdown menu appear above the input.
|
||||
|
||||
<ComboBox direction="top" titleText="Contact" placeholder="Select contact method"
|
||||
items={[
|
||||
|
@ -73,6 +96,8 @@ items={[
|
|||
|
||||
## Light variant
|
||||
|
||||
Set `light` to `true` to use the light color scheme.
|
||||
|
||||
<ComboBox light titleText="Contact" placeholder="Select contact method"
|
||||
items={[
|
||||
{id: "0", text: "Slack"},
|
||||
|
@ -82,6 +107,8 @@ items={[
|
|||
|
||||
## Extra-large size
|
||||
|
||||
Set `size` to `"xl"` for an extra-large combobox.
|
||||
|
||||
<ComboBox titleText="Contact" placeholder="Select contact method"
|
||||
size="xl"
|
||||
items={[
|
||||
|
@ -92,6 +119,8 @@ items={[
|
|||
|
||||
## Small size
|
||||
|
||||
Set `size` to `"sm"` for a small combobox.
|
||||
|
||||
<ComboBox titleText="Contact" placeholder="Select contact method"
|
||||
size="sm"
|
||||
items={[
|
||||
|
@ -102,6 +131,8 @@ items={[
|
|||
|
||||
## Invalid state
|
||||
|
||||
Set `invalid` to `true` and provide `invalidText` to show an error message.
|
||||
|
||||
<ComboBox invalid invalidText="Secondary contact method must be different from the primary contact" titleText="Contact" placeholder="Select contact method"
|
||||
items={[
|
||||
{id: "0", text: "Slack"},
|
||||
|
@ -111,6 +142,8 @@ items={[
|
|||
|
||||
## Warning state
|
||||
|
||||
Set `warn` to `true` and provide `warnText` to show a warning message.
|
||||
|
||||
<ComboBox warn warnText="This contact method is not associated with your account" titleText="Contact" placeholder="Select contact method"
|
||||
items={[
|
||||
{id: "0", text: "Slack"},
|
||||
|
@ -120,6 +153,8 @@ items={[
|
|||
|
||||
## Disabled state
|
||||
|
||||
Set `disabled` to `true` to prevent interaction with the combobox.
|
||||
|
||||
<ComboBox disabled titleText="Contact" placeholder="Select contact method"
|
||||
items={[
|
||||
{id: "0", text: "Slack"},
|
||||
|
@ -129,7 +164,7 @@ items={[
|
|||
|
||||
## Disabled items
|
||||
|
||||
Use the `disabled` property in the `items` prop to disable specific items.
|
||||
Set `disabled: true` in an item object to disable specific options.
|
||||
|
||||
<ComboBox
|
||||
titleText="Contact"
|
||||
|
|
|
@ -6,12 +6,16 @@ components: ["ComposedModal", "ModalHeader", "ModalBody", "ModalFooter"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`ComposedModal` lets you build custom modals by combining `ModalHeader`, `ModalBody`, and `ModalFooter` components. Use it to create focused interactions that require user attention or input.
|
||||
|
||||
## Composed modal
|
||||
|
||||
Create a modal with a header, body, and footer. Each section can be customized independently.
|
||||
|
||||
<FileSource src="/framed/Modal/ComposedModal" />
|
||||
|
||||
## Multiple secondary buttons
|
||||
|
||||
Use the `secondaryButtons` prop in `ModalFooter` to render two secondary buttons for a "3-button modal". The prop is a 2-tuple type that supersedes `secondaryButtonText`.
|
||||
Set `secondaryButtons` in `ModalFooter` to create a 3-button modal. This prop replaces `secondaryButtonText` and takes a tuple of two button configurations.
|
||||
|
||||
<FileSource src="/framed/Modal/3ButtonComposedModal" />
|
|
@ -9,8 +9,12 @@ components: ["ContentSwitcher", "Switch"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`ContentSwitcher` lets users switch between different views or sections of content. Use it to organize related content into distinct categories or states.
|
||||
|
||||
## Default
|
||||
|
||||
Create a content switcher with `Switch` components. Each switch needs a `text` prop.
|
||||
|
||||
<ContentSwitcher>
|
||||
<Switch text="Latest news" />
|
||||
<Switch text="Trending" />
|
||||
|
@ -18,6 +22,8 @@ components: ["ContentSwitcher", "Switch"]
|
|||
|
||||
## Initial selected index
|
||||
|
||||
Set `selectedIndex` to pre-select a switch when the content switcher loads.
|
||||
|
||||
<ContentSwitcher selectedIndex={1}>
|
||||
<Switch text="Latest news" />
|
||||
<Switch text="Trending" />
|
||||
|
@ -26,10 +32,16 @@ components: ["ContentSwitcher", "Switch"]
|
|||
|
||||
## Reactive example
|
||||
|
||||
This example demonstrates how to programmatically control the content switcher using
|
||||
the `bind:selectedIndex` directive. Update the selected index based on user
|
||||
interactions or application state.
|
||||
|
||||
<FileSource src="/framed/ContentSwitcher/ContentSwitcherReactive" />
|
||||
|
||||
## Custom switch slot
|
||||
|
||||
Override the default slot in `Switch` to customize how each option displays.
|
||||
|
||||
<ContentSwitcher>
|
||||
<Switch>
|
||||
<div style="display: flex; align-items: center;">
|
||||
|
@ -45,6 +57,8 @@ components: ["ContentSwitcher", "Switch"]
|
|||
|
||||
## Extra-large size
|
||||
|
||||
Set `size` to `"xl"` for an extra-large content switcher.
|
||||
|
||||
<ContentSwitcher size="xl">
|
||||
<Switch text="All" />
|
||||
<Switch text="Archived" />
|
||||
|
@ -52,6 +66,8 @@ components: ["ContentSwitcher", "Switch"]
|
|||
|
||||
## Small size
|
||||
|
||||
Set `size` to `"sm"` for a small content switcher.
|
||||
|
||||
<ContentSwitcher size="sm">
|
||||
<Switch text="All" />
|
||||
<Switch text="Archived" />
|
||||
|
@ -59,6 +75,8 @@ components: ["ContentSwitcher", "Switch"]
|
|||
|
||||
## Disabled
|
||||
|
||||
Set `disabled` to `true` on individual switches to prevent interaction.
|
||||
|
||||
<ContentSwitcher>
|
||||
<Switch disabled text="All" />
|
||||
<Switch disabled text="Archived" />
|
||||
|
|
|
@ -6,26 +6,32 @@ components: ["ContextMenu", "ContextMenuGroup", "ContextMenuRadioGroup", "Contex
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`ContextMenu` displays a menu when users right-click. Use it to provide quick access to contextual actions or options.
|
||||
|
||||
In the examples, right click anywhere within the iframe.
|
||||
|
||||
## Default
|
||||
|
||||
By default, the context menu will trigger when right clicking anywhere in the `window`.
|
||||
The context menu appears when right-clicking anywhere in the window. Use `ContextMenuOption` for menu items and `ContextMenuDivider` for visual separation.
|
||||
|
||||
<FileSource src="/framed/ContextMenu/ContextMenu" />
|
||||
|
||||
## Custom target
|
||||
|
||||
Specify a custom `HTMLElement` using the `target` prop.
|
||||
By default, the context menu will trigger when right clicking anywhere in the `window`.
|
||||
|
||||
Set `target` to specify which element triggers the context menu.
|
||||
|
||||
<FileSource src="/framed/ContextMenu/ContextMenuTarget" />
|
||||
|
||||
## Multiple targets
|
||||
|
||||
The `target` prop also accepts an array of elements.
|
||||
Set `target` to an array of elements to trigger the context menu from multiple sources.
|
||||
|
||||
<FileSource src="/framed/ContextMenu/ContextMenuTargets" />
|
||||
|
||||
## Radio groups
|
||||
|
||||
|
||||
Use `ContextMenuGroup` and `ContextMenuRadioGroup` to organize related options and create radio button selections.
|
||||
|
||||
<FileSource src="/framed/ContextMenu/ContextMenuGroups" />
|
|
@ -3,30 +3,32 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
This component uses the native, asynchronous [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy text.
|
||||
`CopyButton` lets users copy text to their clipboard with a single click. Use it to provide quick access to code snippets, links, or other text content.
|
||||
|
||||
Please note that the `clipboard.writeText` API is not supported in [IE 11 nor Safari iOS version 13.3 or lower](https://caniuse.com/mdn-api_clipboard_writetext).
|
||||
|
||||
You can override the default copy functionality with your own implementation. See [Overriding copy functionality](#overriding-copy-functionality).
|
||||
This component uses the native [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy text. Override the default copy functionality with your own implementation. See [Overriding copy functionality](#overriding-copy-functionality).
|
||||
|
||||
## Default
|
||||
|
||||
Create a copy button with the `text` prop to specify what to copy.
|
||||
|
||||
<CopyButton text="Carbon svelte" />
|
||||
|
||||
## Custom feedback text
|
||||
|
||||
Set `feedback` to customize the message shown after copying.
|
||||
|
||||
<CopyButton text="Carbon svelte" feedback="Copied to clipboard" />
|
||||
|
||||
## Overriding copy functionality
|
||||
|
||||
To override the default copy behavior, pass a custom function to the `copy` prop.
|
||||
Pass a custom function to the `copy` prop to override the default copy behavior.
|
||||
|
||||
In this example, we use the open source module [clipboard-copy](https://github.com/feross/clipboard-copy) to copy the text instead of the default Clipboard API.
|
||||
This example uses the NPM package [clipboard-copy](https://github.com/feross/clipboard-copy) to copy the text instead of the default Clipboard API.
|
||||
|
||||
<FileSource src="/framed/CopyButton/CopyButtonOverride" />
|
||||
|
||||
## Preventing copy functionality
|
||||
|
||||
To prevent text from being copied entirely, pass a no-op function to the `copy` prop.
|
||||
Pass a no-op function to the `copy` prop to disable copying.
|
||||
|
||||
<CopyButton text="This text should not be copied" copy={() => {}} />
|
||||
<CopyButton text="This text should not be copied" copy={() => {}} />
|
||||
|
|
|
@ -8,21 +8,20 @@ components: ["DataTable", "Pagination","Toolbar", "ToolbarContent", "ToolbarSear
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`DataTable` is keyed for performance reasons.
|
||||
`DataTable` displays structured data in a tabular format. Use it to present large datasets with features like sorting, filtering, pagination, and row selection.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">Every <code>headers</code> object must have a unique "key" property.</div>
|
||||
</InlineNotification>
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">Every <code>rows</code> object must have a unique "id" property.</div>
|
||||
<div class="body-short-01">
|
||||
This component is keyed for performance.
|
||||
|
||||
Every <strong>headers</strong> object must have a unique "key" property.
|
||||
<div class="body-short-01">Every <strong>rows</strong> object must have a unique "id" property.</div>
|
||||
</div>
|
||||
</InlineNotification>
|
||||
|
||||
## Default
|
||||
|
||||
The key value in `headers` corresponds to the key value defined in `rows`.
|
||||
|
||||
For example, the header key `"name"` will use the value of `rows[index].name`.
|
||||
Create a basic table by providing `headers` and `rows` data. Match the `key` in headers with the corresponding property in rows.
|
||||
|
||||
<DataTable
|
||||
headers="{[
|
||||
|
@ -79,9 +78,7 @@ For example, the header key `"name"` will use the value of `rows[index].name`.
|
|||
|
||||
## Slotted cells
|
||||
|
||||
Use the `"cell"` slot to control the display value per table cell. Individual row and cell data are provided through the `let:row` and `let:cell` directives.
|
||||
|
||||
The slot name for the table header cells is `"cell-header"`.
|
||||
Use the `"cell"` slot to customize cell content. Access row and cell data through `let:row` and `let:cell` directives. Use `"cell-header"` slot for header cells.
|
||||
|
||||
<DataTable
|
||||
headers="{[
|
||||
|
@ -153,6 +150,8 @@ The slot name for the table header cells is `"cell-header"`.
|
|||
|
||||
## With title, description
|
||||
|
||||
Add a title and description to provide context for the table data.
|
||||
|
||||
<DataTable title="Load balancers" description="Your organization's active load balancers."
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -208,7 +207,7 @@ The slot name for the table header cells is `"cell-header"`.
|
|||
|
||||
## Slottable title, description
|
||||
|
||||
The `title` and `description` props are slottable.
|
||||
Use slots to customize the title and description content.
|
||||
|
||||
<DataTable
|
||||
headers="{[
|
||||
|
@ -270,7 +269,7 @@ The `title` and `description` props are slottable.
|
|||
|
||||
## Static width
|
||||
|
||||
Set `useStaticWidth` to `true` to render the table with a width of "auto" instead of "100%".
|
||||
Set `useStaticWidth` to `true` to render the table with an auto width instead of 100%.
|
||||
|
||||
<DataTable useStaticWidth
|
||||
title="Load balancers" description="Your organization's active load balancers."
|
||||
|
@ -328,9 +327,7 @@ title="Load balancers" description="Your organization's active load balancers."
|
|||
|
||||
## Custom column widths
|
||||
|
||||
Specify a `width` or `minWidth` property in the `headers` object to customize the width of each column.
|
||||
|
||||
A [table-layout: fixed](https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout#values) rule will be applied to the `table` element when using custom widths.
|
||||
Specify `width` or `minWidth` in the `headers` object to set column dimensions. This applies a fixed table layout.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast kind="warning" title="Note:" hideCloseButton>
|
||||
<div class="body-short-01">Custom column widths do not work with a <a class="bx--link" href="#sticky-header">sticky header</a>.</div>
|
||||
|
@ -340,9 +337,7 @@ A [table-layout: fixed](https://developer.mozilla.org/en-US/docs/Web/CSS/table-l
|
|||
|
||||
## Sticky header
|
||||
|
||||
Set `stickyHeader` to `true` for the header to be fixed in place.
|
||||
|
||||
A maximum height will applied to the datatable to force a scrollbar.
|
||||
Set `stickyHeader` to `true` to fix the header in place. This adds a maximum height to force scrolling.
|
||||
|
||||
<DataTable
|
||||
stickyHeader
|
||||
|
@ -363,6 +358,8 @@ A maximum height will applied to the datatable to force a scrollbar.
|
|||
|
||||
## With toolbar
|
||||
|
||||
Add a toolbar with search, menu, and actions above the table.
|
||||
|
||||
<DataTable title="Load balancers" description="Your organization's active load balancers."
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -432,6 +429,8 @@ A maximum height will applied to the datatable to force a scrollbar.
|
|||
|
||||
## With toolbar (small size)
|
||||
|
||||
Use `size="short"` to create a more compact table with a small toolbar.
|
||||
|
||||
<DataTable size="short" title="Load balancers" description="Your organization's active load balancers."
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -499,24 +498,22 @@ A maximum height will applied to the datatable to force a scrollbar.
|
|||
|
||||
## Filterable
|
||||
|
||||
By default, `ToolbarSearch` will not filter `DataTable` rows.
|
||||
Set `shouldFilterRows` to `true` to enable client-side filtering. The default filter performs string comparisons on cell values.
|
||||
|
||||
Set `shouldFilterRows` to `true` to enable client-side filtering. The default filtering performs a basic string comparison on cell values that are of a string or a number type.
|
||||
|
||||
To use filtering with pagination, bind to the `filteredRowIds` prop and pass its length to `totalItems` in `Pagination`.
|
||||
|
||||
Note that in-memory filtering is not optimal for large data sets, where you might consider using server-side search.
|
||||
For pagination with filtering, bind to `filteredRowIds` and pass its length to `Pagination`'s `totalItems`.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableFilterable" />
|
||||
|
||||
## Filterable (custom)
|
||||
|
||||
`shouldFilterRows` also accepts a function and passes it the current row and search value. It expects the function to return a boolean.
|
||||
Pass a function to `shouldFilterRows` to implement custom filtering logic.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableFilterCustom" />
|
||||
|
||||
## Zebra stripes
|
||||
|
||||
Set `zebra` to `true` to add alternating row colors.
|
||||
|
||||
<DataTable zebra
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -572,6 +569,8 @@ Note that in-memory filtering is not optimal for large data sets, where you migh
|
|||
|
||||
## Tall rows
|
||||
|
||||
Set `size="tall"` for increased row height.
|
||||
|
||||
<DataTable size="tall"
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -627,6 +626,8 @@ Note that in-memory filtering is not optimal for large data sets, where you migh
|
|||
|
||||
## Medium rows
|
||||
|
||||
Set `size="medium"` for standard row height.
|
||||
|
||||
<DataTable size="medium"
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -682,6 +683,8 @@ Note that in-memory filtering is not optimal for large data sets, where you migh
|
|||
|
||||
## Short rows
|
||||
|
||||
Set `size="short"` for compact row height.
|
||||
|
||||
<DataTable size="short"
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -737,6 +740,8 @@ Note that in-memory filtering is not optimal for large data sets, where you migh
|
|||
|
||||
## Compact rows
|
||||
|
||||
Set `size="compact"` for minimal row height.
|
||||
|
||||
<DataTable size="compact"
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -792,11 +797,7 @@ Note that in-memory filtering is not optimal for large data sets, where you migh
|
|||
|
||||
## Sortable
|
||||
|
||||
Set `sortable` to `true` to enable table column sorting.
|
||||
|
||||
To disable sorting on a specific column, set `sort` to `false` in the header object passed to the `headers` prop.
|
||||
|
||||
In the example below, the "Protocol" column is not sortable.
|
||||
Set `sortable` to `true` to enable column sorting. Disable sorting on specific columns by setting `sort: false` in the header object.
|
||||
|
||||
<DataTable sortable
|
||||
headers="{[
|
||||
|
@ -853,12 +854,14 @@ In the example below, the "Protocol" column is not sortable.
|
|||
|
||||
## Sortable with pagination
|
||||
|
||||
For pagination, bind to the `pageSize` and `page` props of `Pagination` and pass their values to `DataTable`.
|
||||
Bind to `pageSize` and `page` props of `Pagination` and pass them to `DataTable`.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTablePagination" />
|
||||
|
||||
## Sortable with custom display and sort methods
|
||||
|
||||
Use `display` and `sort` functions in header objects to customize cell rendering and sorting.
|
||||
|
||||
<DataTable sortable title="Load balancers" description="Your organization's active load balancers."
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -926,6 +929,8 @@ For pagination, bind to the `pageSize` and `page` props of `Pagination` and pass
|
|||
|
||||
## Sortable with nested object values
|
||||
|
||||
Access nested object properties using dot notation in the header key.
|
||||
|
||||
<DataTable sortable title="Load balancers" description="Your organization's active load balancers."
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -1005,71 +1010,61 @@ For pagination, bind to the `pageSize` and `page` props of `Pagination` and pass
|
|||
|
||||
## Programmatic sorting
|
||||
|
||||
Use the reactive `sortKey` and `sortDirection` props for programmatic sorting.
|
||||
|
||||
By default, the table is not sorted by a specific key. The `sortKey` value must be a valid `key` specified in the `headers` object.
|
||||
|
||||
Possible values for `sortDirection` include `"none"` or `"ascending"` or `"descending"`.
|
||||
|
||||
Setting `sortKey` to `null` and `sortDirection` to `"none"` should reset the table rows to their initial order.
|
||||
Use `sortKey` and `sortDirection` props to control sorting programmatically. Set `sortKey` to a valid header key and `sortDirection` to "none", "ascending", or "descending".
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableProgrammaticSorting" />
|
||||
|
||||
## Empty column with overflow menu
|
||||
|
||||
Some use cases require an empty column in the table body without a corresponding table header.
|
||||
|
||||
For an object in the `headers` array, set `empty` to `true` to render an empty column.
|
||||
|
||||
In the following example, each row in the sortable data table has an overflow menu. There isn't a separate, useless table header column for the overflow menu.
|
||||
Set `empty: true` in a header object to create an empty column. Use this for overflow menus without a header.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableAppendColumns" />
|
||||
|
||||
## Selectable rows (checkbox)
|
||||
|
||||
Set `selectable` to `true` for rows to be multi-selectable.
|
||||
Set `selectable` to `true` for multi-select functionality. Bind to `selectedRowIds` to track selections. Use `inputName` to customize checkbox names.
|
||||
|
||||
<FileSource src="/framed/DataTable/SelectableDataTable" />
|
||||
|
||||
## Batch selection
|
||||
|
||||
Set `batchSelection` to `true` to add a checkbox for selecting all rows. The checkbox shows an indeterminate state when some rows are selected.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableBatchSelection" />
|
||||
|
||||
## Batch selection with initial selected rows
|
||||
|
||||
Use the `selectedRowIds` prop to specify which rows should be selected.
|
||||
Use `selectedRowIds` to specify initially selected rows.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableBatchSelectionInitial" />
|
||||
|
||||
## Batch selection with batch actions toolbar
|
||||
|
||||
Add a toolbar for batch actions when rows are selected.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableBatchSelectionToolbar" />
|
||||
|
||||
## Batch selection with controlled toolbar
|
||||
|
||||
By default, `ToolbarBatchActions` is activated if one or more rows is selected. Clicking "Cancel" will deactivate it.
|
||||
|
||||
Use the `active` prop to control the toolbar. Note that it will still activate if one or more rows are selected.
|
||||
|
||||
You can also prevent the default "Cancel" behavior in the dispatched `on:cancel` event.
|
||||
Control the batch actions toolbar with the `active` prop. Prevent default cancel behavior in the `on:cancel` event.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableBatchSelectionToolbarControlled" />
|
||||
|
||||
## Selectable rows (radio)
|
||||
|
||||
Set `radio` to `true` for only one row to be selected at a time.
|
||||
Set `radio` to `true` for single-row selection. Bind to `selectedRowIds` to track the selected row. Use `inputName` to customize radio button names.
|
||||
|
||||
<FileSource src="/framed/DataTable/RadioSelectableDataTable" />
|
||||
|
||||
## Non-selectable rows
|
||||
|
||||
Use `nonSelectableRowIds` to specify the ids for rows that should not be selectable.
|
||||
Use `nonSelectableRowIds` to prevent selection of specific rows.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableNonSelectableRows" />
|
||||
|
||||
## Expandable rows
|
||||
|
||||
Set `expandable` to `true` for rows to be expandable.
|
||||
Set `expandable` to `true` to make rows expandable. Use the `expanded-row` slot to customize expanded content.
|
||||
|
||||
<DataTable expandable
|
||||
headers="{[
|
||||
|
@ -1130,16 +1125,20 @@ Set `expandable` to `true` for rows to be expandable.
|
|||
|
||||
## Non-expandable rows
|
||||
|
||||
Use `nonExpandableRowIds` to specify the ids for rows that should not be expandable.
|
||||
Use `nonExpandableRowIds` to prevent expansion of specific rows.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableNonExpandableRows" />
|
||||
|
||||
## Expandable (zebra styles)
|
||||
|
||||
Combine expandable rows with zebra striping.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableExpandableZebra" />
|
||||
|
||||
## Expandable (compact size)
|
||||
|
||||
Set `size="compact"` for expandable rows with minimal height.
|
||||
|
||||
<DataTable size="compact" expandable
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -1199,6 +1198,8 @@ Use `nonExpandableRowIds` to specify the ids for rows that should not be expanda
|
|||
|
||||
## Expandable (short size)
|
||||
|
||||
Set `size="short"` for expandable rows with compact height.
|
||||
|
||||
<DataTable size="short" expandable
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -1258,6 +1259,8 @@ Use `nonExpandableRowIds` to specify the ids for rows that should not be expanda
|
|||
|
||||
## Expandable (tall size)
|
||||
|
||||
Set `size="tall"` for expandable rows with increased height.
|
||||
|
||||
<DataTable size="tall" expandable
|
||||
headers="{[
|
||||
{ key: "name", value: "Name" },
|
||||
|
@ -1317,7 +1320,7 @@ Use `nonExpandableRowIds` to specify the ids for rows that should not be expanda
|
|||
|
||||
## Batch expansion
|
||||
|
||||
Set `batchExpansion` to `true` for the ability to expand and collapse all rows at once.
|
||||
Set `batchExpansion` to `true` to expand and collapse all rows at once.
|
||||
|
||||
<DataTable batchExpansion
|
||||
headers="{[
|
||||
|
@ -1378,42 +1381,54 @@ Set `batchExpansion` to `true` for the ability to expand and collapse all rows a
|
|||
|
||||
## Expandable and selectable rows
|
||||
|
||||
The `batchExpansion` and `batchSelection` props can be used together.
|
||||
Combine `batchExpansion` and `batchSelection` for tables with both expandable and selectable rows.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableExpandableSelectable" />
|
||||
|
||||
## Skeleton
|
||||
|
||||
Use `DataTableSkeleton` to show a loading state.
|
||||
|
||||
<DataTableSkeleton />
|
||||
|
||||
## Skeleton with headers, row count
|
||||
|
||||
Specify headers and row count for the skeleton.
|
||||
|
||||
<DataTableSkeleton headers={["Name", "Protocol", "Port", "Rule"]} rows={10} />
|
||||
|
||||
## Skeleton with object headers
|
||||
|
||||
`headers` can also be an array of objects. The type is the same as the `headers` prop type used in `DataTable`.
|
||||
Pass header objects to customize the skeleton.
|
||||
|
||||
<DataTableSkeleton headers={[{ value: "Name" }, {value: "Protocol"}, {value:"Port"}, { value: "Rule"}]} rows={10} />
|
||||
|
||||
## Skeleton with empty header
|
||||
|
||||
Pass an object with `"empty"` set to `true` to render an empty table header column.
|
||||
Add an empty header column with `empty: true`.
|
||||
|
||||
<DataTableSkeleton headers={[{ value: "Name" }, {value: "Protocol"}, {value:"Port"}, { value: "Rule"}, { empty: true }]} rows={10} />
|
||||
|
||||
## Skeleton without header, toolbar
|
||||
|
||||
Hide the header and toolbar in the skeleton.
|
||||
|
||||
<DataTableSkeleton showHeader={false} showToolbar={false} />
|
||||
|
||||
## Skeleton (tall size)
|
||||
|
||||
Set `size="tall"` for a taller skeleton.
|
||||
|
||||
<DataTableSkeleton showHeader={false} showToolbar={false} size="tall" />
|
||||
|
||||
## Skeleton (short size)
|
||||
|
||||
Set `size="short"` for a shorter skeleton.
|
||||
|
||||
<DataTableSkeleton showHeader={false} showToolbar={false} size="short" />
|
||||
|
||||
## Skeleton (compact size)
|
||||
|
||||
Set `size="compact"` for a minimal skeleton.
|
||||
|
||||
<DataTableSkeleton showHeader={false} showToolbar={false} size="compact" />
|
|
@ -7,11 +7,7 @@ components: ["DatePicker", "DatePickerInput", "DatePickerSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
Carbon uses the zero dependency [flatpickr](https://github.com/flatpickr/flatpickr) library for its underlying calendar implementation.
|
||||
|
||||
Set `datePickerType` to `"single"` or `"range"` for the calendar functionality.
|
||||
|
||||
Specify [flatpickr options](https://flatpickr.js.org/options/) through the `flatpickrProps` prop.
|
||||
`DatePicker` lets users select a date or date range using a calendar interface. It uses the [flatpickr](https://github.com/flatpickr/flatpickr) library for its calendar implementation.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">
|
||||
|
@ -21,25 +17,27 @@ Specify [flatpickr options](https://flatpickr.js.org/options/) through the `flat
|
|||
|
||||
## Single
|
||||
|
||||
By default, the `flatpickr` option `static` is set to `true` so that the calendar is positioned inside the wrapper and next to the input element. This is required for the calendar position to work inside a [Modal](/components/Modal).
|
||||
|
||||
Set `flatpickrProps.static` to `false` to opt out of this behavior.
|
||||
Set `datePickerType` to `"single"` for single date selection.
|
||||
|
||||
<FileSource src="/framed/DatePicker/DatePickerSingle" />
|
||||
|
||||
## Range
|
||||
|
||||
Set `datePickerType` to `"range"` for the range variant.
|
||||
Set `datePickerType` to `"range"` to enable date range selection.
|
||||
|
||||
<FileSource src="/framed/DatePicker/DatePickerRange" />
|
||||
|
||||
## DatePicker in a modal
|
||||
|
||||
The calendar is positioned inside the wrapper by default (`flatpickrProps.static: true`). This ensures proper positioning within a [Modal](/components/Modal).
|
||||
|
||||
Set `flatpickrProps.static` to `false` to position the calendar outside the wrapper.
|
||||
|
||||
<FileSource src="/framed/DatePicker/DatePickerModal" />
|
||||
|
||||
## Simple
|
||||
|
||||
By default, the "simple" date picker does not have a dropdown calendar.
|
||||
Create a simple date picker without a dropdown calendar.
|
||||
|
||||
<DatePicker>
|
||||
<DatePickerInput labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||
|
@ -47,52 +45,70 @@ By default, the "simple" date picker does not have a dropdown calendar.
|
|||
|
||||
## With helper text
|
||||
|
||||
Add helper text to provide additional context or formatting instructions.
|
||||
|
||||
<DatePicker>
|
||||
<DatePickerInput labelText="Date of birth" helperText="Example: 01/12/1990" placeholder="mm/dd/yyyy" />
|
||||
</DatePicker>
|
||||
|
||||
## Hidden label
|
||||
|
||||
Hide the label while maintaining accessibility.
|
||||
|
||||
<DatePicker>
|
||||
<DatePickerInput hideLabel labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||
</DatePicker>
|
||||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for light backgrounds.
|
||||
|
||||
<DatePicker light>
|
||||
<DatePickerInput labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||
</DatePicker>
|
||||
|
||||
## Extra-large size
|
||||
|
||||
Use the extra-large size for more prominent date pickers.
|
||||
|
||||
<DatePicker>
|
||||
<DatePickerInput size="xl" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||
</DatePicker>
|
||||
|
||||
## Small size
|
||||
|
||||
Use the small size for compact date pickers.
|
||||
|
||||
<DatePicker>
|
||||
<DatePickerInput size="sm" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||
</DatePicker>
|
||||
|
||||
## Invalid state
|
||||
|
||||
Show an invalid state when the input value is not valid.
|
||||
|
||||
<DatePicker>
|
||||
<DatePickerInput invalid invalidText="Invalid date" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||
</DatePicker>
|
||||
|
||||
## Warning state
|
||||
|
||||
Show a warning state to indicate potential issues with the input.
|
||||
|
||||
<DatePicker>
|
||||
<DatePickerInput warn warnText="This info will not be stored" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||
</DatePicker>
|
||||
|
||||
## Disabled state
|
||||
|
||||
Disable the date picker to prevent user interaction.
|
||||
|
||||
<DatePicker>
|
||||
<DatePickerInput disabled labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||
</DatePicker>
|
||||
|
||||
## Skeleton
|
||||
|
||||
Show a loading state with the skeleton component.
|
||||
|
||||
<DatePickerSkeleton />
|
||||
|
|
|
@ -7,7 +7,9 @@ components: ["Dropdown", "DropdownSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Dropdown` is keyed for performance reasons.
|
||||
The `Dropdown` component provides a select input with a dropdown menu. It supports
|
||||
various states, sizes, and customization options. Each item in the dropdown must
|
||||
have a unique `id` property for proper functionality.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
||||
|
@ -15,25 +17,33 @@ components: ["Dropdown", "DropdownSkeleton"]
|
|||
|
||||
## Default
|
||||
|
||||
Use the `Dropdown` component to create a select input with a dropdown menu. Each item
|
||||
must have a unique `id` property.
|
||||
|
||||
<Dropdown titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}]}" />
|
||||
|
||||
## Custom slot
|
||||
|
||||
Override the default slot to customize the display of each item. Access the item and index through the `let:` directive.
|
||||
Override the default slot to customize the display of each item. Access the item and
|
||||
index through the `let:` directive.
|
||||
|
||||
<FileSource src="/framed/Dropdown/DropdownSlot" />
|
||||
|
||||
## Hidden label
|
||||
|
||||
Hide the label while maintaining accessibility by setting the `hideLabel` prop to
|
||||
`true`. The label will still be available to screen readers.
|
||||
|
||||
<Dropdown hideLabel titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}]}" />
|
||||
|
||||
## Format item display text
|
||||
|
||||
Use the `itemToString` prop to format the display of individual items.
|
||||
Format the display text of items using the `itemToString` prop. This function
|
||||
receives the item object and returns the formatted string.
|
||||
|
||||
<Dropdown itemToString={item => {
|
||||
return item.text + ' (' + item.id +')'
|
||||
|
@ -43,11 +53,15 @@ Use the `itemToString` prop to format the display of individual items.
|
|||
|
||||
## Multiple dropdowns
|
||||
|
||||
Create multiple dropdowns that work together. This example demonstrates how to
|
||||
manage the state of multiple dropdowns.
|
||||
|
||||
<FileSource src="/framed/Dropdown/MultipleDropdown" />
|
||||
|
||||
## Top direction
|
||||
|
||||
Set `direction` to `"top"` for the dropdown menu to appear above the input.
|
||||
Display the dropdown menu above the input by setting the `direction` prop to
|
||||
`"top"`. This is useful when there's limited space below the input.
|
||||
|
||||
<Dropdown direction="top" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
|
@ -55,49 +69,72 @@ Set `direction` to `"top"` for the dropdown menu to appear above the input.
|
|||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for dropdowns on dark backgrounds by setting the `light` prop
|
||||
to `true`.
|
||||
|
||||
<Dropdown light titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}]}" />
|
||||
|
||||
## Inline variant
|
||||
|
||||
Display the dropdown inline with other content by setting the `type` prop to
|
||||
`"inline"`. This variant removes the background and border.
|
||||
|
||||
<Dropdown type="inline" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}]}" />
|
||||
|
||||
## Extra-large size
|
||||
|
||||
Increase the size of the dropdown by setting the `size` prop to `"xl"`. This
|
||||
provides more visual emphasis for important selections.
|
||||
|
||||
<Dropdown size="xl" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}]}" />
|
||||
|
||||
## Small size
|
||||
|
||||
Decrease the size of the dropdown by setting the `size` prop to `"sm"`. This is
|
||||
useful for compact layouts or secondary selections.
|
||||
|
||||
<Dropdown size="sm" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}]}" />
|
||||
|
||||
## Invalid state
|
||||
|
||||
Indicate an invalid selection by setting the `invalid` prop to `true`. Provide
|
||||
feedback to users with the `invalidText` prop.
|
||||
|
||||
<Dropdown invalid invalidText="Secondary contact method must be different from the primary contact" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}]}" />
|
||||
|
||||
## Warning state
|
||||
|
||||
Indicate a warning state by setting the `warn` prop to `true`. Provide additional
|
||||
context with the `warnText` prop.
|
||||
|
||||
<Dropdown warn warnText="This contact method is not associated with your account" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}]}" />
|
||||
|
||||
## Disabled state
|
||||
|
||||
Disable the entire dropdown by setting the `disabled` prop to `true`. This prevents
|
||||
user interaction with the component.
|
||||
|
||||
<Dropdown disabled titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}]}" />
|
||||
|
||||
## Disabled items
|
||||
|
||||
Use the `disabled` property in the `items` prop to disable specific items.
|
||||
Disable specific items in the dropdown by setting the `disabled` property to
|
||||
`true` in the item object. This allows for more granular control over available
|
||||
selections.
|
||||
|
||||
<Dropdown
|
||||
selectedId="0"
|
||||
|
@ -111,4 +148,7 @@ Use the `disabled` property in the `items` prop to disable specific items.
|
|||
|
||||
## Skeleton
|
||||
|
||||
Display a loading state using the `DropdownSkeleton` component. This provides
|
||||
visual feedback while the dropdown content is being loaded.
|
||||
|
||||
<DropdownSkeleton />
|
|
@ -3,11 +3,19 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
The `ExpandableTile` component creates a collapsible content container that can
|
||||
show and hide content with a smooth animation. It's ideal for managing content
|
||||
overflow and progressive disclosure of information. The component automatically
|
||||
measures content height using a resize observer.
|
||||
|
||||
## Default
|
||||
|
||||
This component uses a [resize observer](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) to determine the height of the above-the-fold content.
|
||||
Create an expandable tile that shows and hides content. The component uses a
|
||||
[resize observer](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
|
||||
to determine the height of the above-the-fold content.
|
||||
|
||||
It's unexpanded by default.
|
||||
By default, the tile is collapsed. Use the `above` and `below` slots to define the
|
||||
content that appears before and after expansion.
|
||||
|
||||
<ExpandableTile>
|
||||
<div slot="above">
|
||||
|
@ -25,7 +33,8 @@ It's unexpanded by default.
|
|||
|
||||
## Custom tile heights
|
||||
|
||||
Set a custom height for the tiles on the "above" and "below" slots.
|
||||
Set custom heights for the tile content using CSS. This is useful when you need to
|
||||
control the exact dimensions of the visible and hidden content.
|
||||
|
||||
<ExpandableTile>
|
||||
<div slot="above" style="height: 10rem">Above the fold content here</div>
|
||||
|
@ -34,6 +43,9 @@ Set a custom height for the tiles on the "above" and "below" slots.
|
|||
|
||||
## Expanded
|
||||
|
||||
Display the tile in its expanded state by default by setting the `expanded` prop to
|
||||
`true`.
|
||||
|
||||
<ExpandableTile expanded>
|
||||
<div slot="above">Above the fold content here</div>
|
||||
<div slot="below">Below the fold content here</div>
|
||||
|
@ -41,6 +53,9 @@ Set a custom height for the tiles on the "above" and "below" slots.
|
|||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for expandable tiles on dark backgrounds by setting the
|
||||
`light` prop to `true`.
|
||||
|
||||
<ExpandableTile light>
|
||||
<div slot="above">Above the fold content here</div>
|
||||
<div slot="below">Below the fold content here</div>
|
||||
|
@ -48,6 +63,9 @@ Set a custom height for the tiles on the "above" and "below" slots.
|
|||
|
||||
## With icon labels
|
||||
|
||||
Customize the expand/collapse button labels using the `tileExpandedLabel` and
|
||||
`tileCollapsedLabel` props.
|
||||
|
||||
<ExpandableTile tileExpandedLabel="View less" tileCollapsedLabel="View more">
|
||||
<div slot="above">Above the fold content here</div>
|
||||
<div slot="below">Below the fold content here</div>
|
||||
|
@ -55,7 +73,9 @@ Set a custom height for the tiles on the "above" and "below" slots.
|
|||
|
||||
## With interactive content
|
||||
|
||||
For tiles containing interactive content, use `stopPropagation` to prevent the tile from toggling.
|
||||
Handle interactive content within the tile by preventing event propagation. This
|
||||
ensures that clicks on interactive elements don't trigger the tile's expand/collapse
|
||||
behavior.
|
||||
|
||||
<ExpandableTile tileExpandedLabel="View less" tileCollapsedLabel="View more">
|
||||
<div slot="above">
|
||||
|
|
|
@ -7,23 +7,28 @@ components: ["FileUploaderButton", "FileUploader", "FileUploaderDropContainer",
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
The `FileUploader` components provide a complete solution for file uploads, including
|
||||
a button trigger, drag-and-drop container, and file list display. The components
|
||||
support various states, file validation, and customization options.
|
||||
|
||||
## File uploader (button-only)
|
||||
|
||||
By default, the file uploader only accepts one file.
|
||||
|
||||
Set `multiple` to `true` for multiple files to be accepted.
|
||||
Create a simple file upload button using `FileUploaderButton`. By default, it
|
||||
accepts a single file. Set `multiple` to `true` to allow multiple file selection.
|
||||
|
||||
<FileUploaderButton labelText="Add file" />
|
||||
|
||||
## Multiple files
|
||||
|
||||
Enable multiple file selection by setting the `multiple` prop to `true`. This
|
||||
allows users to select multiple files at once.
|
||||
|
||||
<FileUploaderButton multiple labelText="Add files" />
|
||||
|
||||
## Custom button kind, size
|
||||
|
||||
By default, the `primary` small button kind is used.
|
||||
|
||||
Use the `kind` and `size` props to customize the button.
|
||||
Customize the button appearance using the `kind` and `size` props. The default is
|
||||
a small primary button.
|
||||
|
||||
<FileUploaderButton kind="secondary" size="field" />
|
||||
<FileUploaderButton kind="tertiary" size="default" />
|
||||
|
@ -32,17 +37,17 @@ Use the `kind` and `size` props to customize the button.
|
|||
|
||||
## File uploader
|
||||
|
||||
The `FileUploader` wraps `FileUploaderButton` and lists out uploaded files.
|
||||
The `FileUploader` component combines a button trigger with a list of uploaded
|
||||
files. It supports file type restrictions, multiple file selection, and various
|
||||
upload states.
|
||||
|
||||
The example below accepts multiple files with an extension of `.jpg` or `.jpeg`. It sets the status to `"complete"`; by default, the status is `"loading"`.
|
||||
|
||||
See the [item examples below](#item-uploading) for different statuses.
|
||||
This example accepts multiple JPEG files and displays them in a completed state.
|
||||
|
||||
<FileUploader multiple labelTitle="Upload files" buttonLabel="Add files" labelDescription="Only JPEG files are accepted." accept="{['.jpg', '.jpeg']}" status="complete" />
|
||||
|
||||
## Clear files
|
||||
|
||||
There are two ways to clear files in `FileUploader`:
|
||||
Remove uploaded files from the `FileUploader` component in two ways:
|
||||
|
||||
<UnorderedList svx-ignore style="margin-bottom: var(--cds-spacing-08)">
|
||||
<ListItem>programmatically using the <strong>clearFiles</strong> accessor</ListItem>
|
||||
|
@ -53,21 +58,29 @@ There are two ways to clear files in `FileUploader`:
|
|||
|
||||
## File uploader (disabled state)
|
||||
|
||||
Disable the file uploader by setting the `disabled` prop to `true`. This prevents
|
||||
user interaction with the component.
|
||||
|
||||
<FileUploader disabled multiple labelTitle="Upload files" buttonLabel="Add files" labelDescription="Only JPEG files are accepted." accept="{['.jpg', '.jpeg']}" status="complete" />
|
||||
|
||||
## Item (uploading)
|
||||
|
||||
Display a file upload in progress using the `uploading` status. This shows a
|
||||
loading indicator and the file name.
|
||||
|
||||
<FileUploaderItem name="README.md" status="uploading" />
|
||||
|
||||
## Item (complete)
|
||||
|
||||
Show a successfully uploaded file using the `complete` status. This displays a
|
||||
checkmark icon next to the file name.
|
||||
|
||||
<FileUploaderItem name="README.md" status="complete" />
|
||||
|
||||
## Item (edit)
|
||||
|
||||
If the `status` is `"edit"`, clicking the close icon will dispatch a `delete` event.
|
||||
|
||||
The event detail contains the item `id`.
|
||||
Enable file deletion by setting the status to `"edit"`. Clicking the close icon
|
||||
dispatches a `delete` event with the item's ID.
|
||||
|
||||
<FileUploaderItem id="readme" name="README.md" status="edit" on:delete={(e) => {
|
||||
console.log(e.detail); // "readme"
|
||||
|
@ -75,13 +88,15 @@ The event detail contains the item `id`.
|
|||
|
||||
## Item (edit status, invalid state)
|
||||
|
||||
An item can also have an edit status with an invalid state.
|
||||
Mark a file as invalid while keeping it editable. This shows an error icon and
|
||||
allows the user to remove the file.
|
||||
|
||||
<FileUploaderItem invalid id="readme" name="README.md" status="edit" on:delete />
|
||||
|
||||
## Item (edit status, invalid state with subject, body)
|
||||
|
||||
Use the `errorSubject` and `errorBody` props to customize the error message.
|
||||
Provide detailed error messages for invalid files using the `errorSubject` and
|
||||
`errorBody` props. This helps users understand and resolve upload issues.
|
||||
|
||||
<FileUploaderItem
|
||||
invalid
|
||||
|
@ -95,7 +110,8 @@ Use the `errorSubject` and `errorBody` props to customize the error message.
|
|||
|
||||
## Item sizes
|
||||
|
||||
The default `FileUploaderItem` size is "default".
|
||||
Customize the size of file uploader items using the `size` prop. The default size
|
||||
is "default".
|
||||
|
||||
<FileUploaderItem size="default" name="README.md" status="uploading" />
|
||||
<FileUploaderItem size="field" name="README.md" status="uploading" />
|
||||
|
@ -103,11 +119,11 @@ The default `FileUploaderItem` size is "default".
|
|||
|
||||
## Drop container
|
||||
|
||||
The `FileUploaderDropContainer` accepts files through click and drop events.
|
||||
Use `FileUploaderDropContainer` for drag-and-drop file uploads. It supports file
|
||||
validation and multiple file selection.
|
||||
|
||||
Use the `validateFiles` prop to filter out files before they are set.
|
||||
|
||||
The following example accepts files smaller than 1 kB.
|
||||
This example accepts files smaller than 1 kB and logs the selected files to the
|
||||
console.
|
||||
|
||||
<FileUploaderDropContainer
|
||||
multiple
|
||||
|
@ -122,4 +138,7 @@ The following example accepts files smaller than 1 kB.
|
|||
|
||||
## Skeleton
|
||||
|
||||
Display a loading state using the `FileUploaderSkeleton` component. This provides
|
||||
visual feedback while the file uploader content is being loaded.
|
||||
|
||||
<FileUploaderSkeleton />
|
|
@ -7,9 +7,15 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
The `FluidForm` component provides a fluid-width form layout that adapts to its
|
||||
container. It's designed for full-width form layouts and works with most Carbon
|
||||
input components. Note that inline input variants cannot be used within a
|
||||
`FluidForm`.
|
||||
|
||||
## Fluid form
|
||||
|
||||
Note that the `inline` input variants cannot be used within a `FluidForm`.
|
||||
Create a fluid-width form layout using the `FluidForm` component. This example
|
||||
shows a basic login form with required fields.
|
||||
|
||||
<FluidForm>
|
||||
<TextInput labelText="User name" placeholder="Enter user name..." required />
|
||||
|
@ -23,4 +29,8 @@ Note that the `inline` input variants cannot be used within a `FluidForm`.
|
|||
|
||||
## Invalid state
|
||||
|
||||
Handle form validation and display error states using the `invalid` and
|
||||
`invalidText` props on form inputs. This example demonstrates how to show
|
||||
validation errors in a fluid form.
|
||||
|
||||
<FileSource src="/framed/FluidForm/FluidFormInvalid" />
|
|
@ -14,8 +14,15 @@ components: ["Form", "FormGroup"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
The `Form` component provides a structured way to collect user input. It works with
|
||||
various form controls like checkboxes, radio buttons, and select menus. The
|
||||
`FormGroup` component helps organize related form controls with a legend.
|
||||
|
||||
## Form
|
||||
|
||||
Create a form with grouped controls using `Form` and `FormGroup`. This example
|
||||
shows a form with checkboxes, radio buttons, and a select menu.
|
||||
|
||||
<Form on:submit>
|
||||
<FormGroup legendText="Checkboxes">
|
||||
<Checkbox id="checkbox-0" labelText="Checkbox Label" checked />
|
||||
|
@ -63,7 +70,9 @@ components: ["Form", "FormGroup"]
|
|||
|
||||
## Prevent default behavior
|
||||
|
||||
The forwarded `submit` event is not modified. Use `e.preventDefault()` to prevent the native form submission behavior.
|
||||
Handle form submission by preventing the default browser behavior. Use
|
||||
`e.preventDefault()` to stop the native form submission and handle the event
|
||||
programmatically.
|
||||
|
||||
<Form on:submit={e => {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -6,34 +6,62 @@ components: ["Grid", "Row", "Column"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
The `Grid` system provides a responsive, 12-column layout structure. Use `Row` and
|
||||
`Column` components to create flexible layouts that adapt to different screen
|
||||
sizes. The grid supports various spacing options and column configurations.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic grid layout with equal-width columns. This example demonstrates the
|
||||
default grid behavior.
|
||||
|
||||
<FileSource src="/framed/Grid/Grid" />
|
||||
|
||||
## Full width
|
||||
|
||||
Use the full-width grid variant for layouts that span the entire viewport width.
|
||||
This removes the default max-width constraint.
|
||||
|
||||
<FileSource src="/framed/Grid/FullWidthGrid" />
|
||||
|
||||
## Narrow
|
||||
|
||||
Create a more compact grid layout using the narrow variant. This reduces the
|
||||
spacing between columns.
|
||||
|
||||
<FileSource src="/framed/Grid/NarrowGrid" />
|
||||
|
||||
## Condensed
|
||||
|
||||
Use the condensed variant for even tighter spacing between columns. This is ideal
|
||||
for dense data displays.
|
||||
|
||||
<FileSource src="/framed/Grid/CondensedGrid" />
|
||||
|
||||
## Responsive
|
||||
|
||||
Build responsive layouts by specifying different column widths for different
|
||||
breakpoints. The grid automatically adjusts based on screen size.
|
||||
|
||||
<FileSource src="/framed/Grid/ResponsiveGrid" />
|
||||
|
||||
## Offset columns
|
||||
|
||||
Create space between columns using the offset feature. This allows for more
|
||||
flexible layouts without empty columns.
|
||||
|
||||
<FileSource src="/framed/Grid/OffsetColumns" />
|
||||
|
||||
## Aspect ratio columns
|
||||
|
||||
Maintain consistent column heights using aspect ratio columns. This ensures
|
||||
content alignment across different column widths.
|
||||
|
||||
<FileSource src="/framed/Grid/AspectRatioColumns" />
|
||||
|
||||
## Padded columns
|
||||
|
||||
Add padding to columns using the padded variant. This creates more breathing room
|
||||
between content.
|
||||
|
||||
<FileSource src="/framed/Grid/PaddedGrid" />
|
||||
|
|
|
@ -5,15 +5,22 @@
|
|||
let key = 0;
|
||||
</script>
|
||||
|
||||
This utility component uses the [Image API](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image) to programmatically load an image with slottable loading and error states.
|
||||
|
||||
The `ImageLoader` component provides a robust way to load images with built-in
|
||||
loading and error states. It uses the [Image API](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image)
|
||||
to handle image loading programmatically. The component supports aspect ratios,
|
||||
fade-in animations, and custom loading/error states.
|
||||
|
||||
## Default
|
||||
|
||||
|
||||
Load an image with the default configuration. The component handles the loading
|
||||
process automatically.
|
||||
|
||||
<ImageLoader src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg" />
|
||||
|
||||
## Slots
|
||||
|
||||
Use the "loading" and "error" named slots to render an element when the image is loading or has an error.
|
||||
Customize the loading and error states using named slots. This example shows how
|
||||
to display a loading indicator and error message.
|
||||
|
||||
<ImageLoader src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg">
|
||||
<svelte:fragment slot="loading">
|
||||
|
@ -26,27 +33,32 @@ Use the "loading" and "error" named slots to render an element when the image is
|
|||
|
||||
## With aspect ratio
|
||||
|
||||
If `ratio` is set, this component uses the [AspectRatio](/components/AspectRatio) to constrain the image.
|
||||
Maintain consistent image dimensions using aspect ratios. The component uses
|
||||
[AspectRatio](/components/AspectRatio) to constrain the image.
|
||||
|
||||
Supported aspect ratios include `"2x1"`, `"2x3"`, `"16x9"`, `"4x3"`, `"1x1"`, `"3x4"`, `"3x2"`, `"9x16"` and `"1x2"`.
|
||||
Supported aspect ratios include `"2x1"`, `"2x3"`, `"16x9"`, `"4x3"`, `"1x1"`,
|
||||
`"3x4"`, `"3x2"`, `"9x16"` and `"1x2"`.
|
||||
|
||||
<ImageLoader ratio="16x9" src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg" />
|
||||
|
||||
## Fade in
|
||||
|
||||
Set `fadeIn` to `true` to fade in the image if successfully loaded.
|
||||
Enable a smooth fade-in animation when the image loads successfully. This provides
|
||||
a better user experience for image loading.
|
||||
|
||||
<Button kind="ghost" on:click="{() => { key++;}}">Reload image</Button>
|
||||
{#key key}<ImageLoader fadeIn ratio="16x9" src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg" />{/key}
|
||||
|
||||
## Programmatic usage
|
||||
|
||||
In this example, a component reference is obtained to programmatically trigger the `loadImage` method.
|
||||
Control image loading programmatically using component references. This example
|
||||
demonstrates how to trigger image loading manually.
|
||||
|
||||
<FileSource src="/framed/ImageLoader/ProgrammaticImageLoader" />
|
||||
|
||||
## Dynamic image source
|
||||
|
||||
The same `ImageLoader` instance can be used to load different images.
|
||||
Update the image source dynamically using the same `ImageLoader` instance. This
|
||||
allows for smooth transitions between different images.
|
||||
|
||||
<FileSource src="/framed/ImageLoader/DynamicImageLoader" />
|
||||
|
|
|
@ -1,18 +1,37 @@
|
|||
---
|
||||
components: ["InlineLoading"]
|
||||
---
|
||||
|
||||
<script>
|
||||
import { InlineLoading } from "carbon-components-svelte";
|
||||
import { InlineLoading, UnorderedList, ListItem } from "carbon-components-svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
The `InlineLoading` component provides a compact loading indicator that can be embedded within content. It's ideal for showing progress during inline operations like form submissions or data updates.
|
||||
|
||||
## Default
|
||||
|
||||
Display a basic loading indicator with the default configuration.
|
||||
|
||||
<InlineLoading />
|
||||
|
||||
## With description
|
||||
|
||||
Add a descriptive text to provide context about the loading operation.
|
||||
|
||||
<InlineLoading description="Loading metrics..." />
|
||||
|
||||
## Status states
|
||||
|
||||
The component supports different status states to indicate progress:
|
||||
|
||||
<UnorderedList svx-ignore style="margin-bottom: var(--cds-spacing-08)">
|
||||
<ListItem><strong>active</strong>: Shows an animated loading indicator</ListItem>
|
||||
<ListItem><strong>inactive</strong>: Displays a static state</ListItem>
|
||||
<ListItem><strong>finished</strong>: Shows a success state</ListItem>
|
||||
<ListItem><strong>error</strong>: Displays an error state</ListItem>
|
||||
</UnorderedList>
|
||||
|
||||
<InlineLoading status="active" description="Submitting..." />
|
||||
<InlineLoading status="inactive" description="Cancelling..." />
|
||||
<InlineLoading status="finished" description="Success" />
|
||||
|
@ -20,4 +39,6 @@
|
|||
|
||||
## UX example
|
||||
|
||||
See how to integrate the loading indicator in a real-world scenario.
|
||||
|
||||
<FileSource src="/framed/InlineLoading/InlineLoadingUx" />
|
|
@ -7,26 +7,29 @@ components: ["InlineNotification", "NotificationActionButton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
Notification that appears inline.
|
||||
The `InlineNotification` component displays contextual messages inline with content. It supports various types of notifications (error, warning, success, info) and can include actions. Use it to provide feedback or important information to users.
|
||||
|
||||
See [detailed
|
||||
usage](https://carbondesignsystem.com/components/notification/usage).
|
||||
See [detailed usage](https://carbondesignsystem.com/components/notification/usage).
|
||||
See also: [ToastNotification](ToastNotification)
|
||||
|
||||
## Default (error)
|
||||
## Default
|
||||
|
||||
Display a basic error notification with title and subtitle by default.
|
||||
|
||||
<InlineNotification title="Error:" subtitle="An internal server error occurred." />
|
||||
|
||||
## Prevent default close behavior
|
||||
|
||||
`InlineNotification` is a controlled component. Prevent the default close behavior using the `e.preventDefault()` method in the dispatched `on:close` event.
|
||||
The component is controlled, allowing you to prevent the default close behavior using `e.preventDefault()`.
|
||||
|
||||
<InlineNotification title="Error" subtitle="An internal server error occurred." on:close={(e) => {
|
||||
e.preventDefault();
|
||||
// custom close logic (e.g., transitions)
|
||||
}} />
|
||||
|
||||
## Slottable title, subtitle
|
||||
## Slottable title and subtitle
|
||||
|
||||
Customize the notification content using slots for more flexibility.
|
||||
|
||||
<InlineNotification>
|
||||
<strong slot="title">Error: </strong>
|
||||
|
@ -35,9 +38,7 @@ See also: [ToastNotification](ToastNotification)
|
|||
|
||||
## Accessible icon descriptions
|
||||
|
||||
The status icon and close button icon descriptions appear on cursor hover and are read
|
||||
by assistive technology. Default descriptions are provided in English and can be
|
||||
overridden via `statusIconDescription` and `closeButtonDescription`.
|
||||
Make notifications more accessible by providing custom descriptions for icons.
|
||||
|
||||
<InlineNotification
|
||||
title="错误"
|
||||
|
@ -48,10 +49,14 @@ overridden via `statusIconDescription` and `closeButtonDescription`.
|
|||
|
||||
## Hidden close button
|
||||
|
||||
Create a persistent notification by hiding the close button.
|
||||
|
||||
<InlineNotification hideCloseButton kind="warning" title="Scheduled maintenance:" subtitle="Maintenance will last 2-4 hours." />
|
||||
|
||||
## With actions
|
||||
|
||||
Add interactive elements to notifications using the actions slot.
|
||||
|
||||
<InlineNotification kind="warning" title="Scheduled maintenance:" subtitle="Maintenance will last 2-4 hours.">
|
||||
<svelte:fragment slot="actions">
|
||||
<NotificationActionButton>Learn more</NotificationActionButton>
|
||||
|
@ -60,6 +65,8 @@ overridden via `statusIconDescription` and `closeButtonDescription`.
|
|||
|
||||
## Notification variants
|
||||
|
||||
The component supports different notification types:
|
||||
|
||||
<InlineNotification kind="error" title="Error:" subtitle="An internal server error occurred." />
|
||||
<InlineNotification kind="info" title="New updates:" subtitle="Restart to get the latest updates." />
|
||||
<InlineNotification kind="info-square" title="New updates:" subtitle="Restart to get the latest updates." />
|
||||
|
@ -69,6 +76,8 @@ overridden via `statusIconDescription` and `closeButtonDescription`.
|
|||
|
||||
## Low contrast
|
||||
|
||||
Use low contrast variants for less prominent notifications.
|
||||
|
||||
<InlineNotification lowContrast kind="error" title="Error:" subtitle="An internal server error occurred." />
|
||||
<InlineNotification lowContrast kind="info" title="New updates:" subtitle="Restart to get the latest updates." />
|
||||
<InlineNotification lowContrast kind="info-square" title="New updates:" subtitle="Restart to get the latest updates." />
|
||||
|
|
|
@ -8,17 +8,19 @@ components: ["Link", "OutboundLink"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
The `Link` component provides styled hyperlinks with various customization options. It supports different sizes, states, and can include icons. The `OutboundLink` variant automatically handles external links with proper security attributes.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic link with the default styling.
|
||||
|
||||
<Link href="https://www.carbondesignsystem.com/">
|
||||
Carbon Design System
|
||||
</Link>
|
||||
|
||||
## Target _blank
|
||||
|
||||
If setting `target` to `"_blank"`, the `Link` component will automatically set `rel="noopener noreferrer"` to guard against [potential cross-origin security exploits](https://web.dev/external-anchors-use-rel-noopener/).
|
||||
|
||||
You can override the `rel` attribute with a custom value.
|
||||
For external links, the component automatically adds security attributes. You can override the `rel` attribute if needed.
|
||||
|
||||
<Link href="https://www.carbondesignsystem.com/" target="_blank">
|
||||
Carbon Design System
|
||||
|
@ -26,7 +28,7 @@ You can override the `rel` attribute with a custom value.
|
|||
|
||||
## Outbound link
|
||||
|
||||
An alternative to manually setting `target` to `"_blank"` is to use the `OutboundLink`.
|
||||
Use `OutboundLink` as a convenient alternative for external links.
|
||||
|
||||
<OutboundLink href="https://www.carbondesignsystem.com/">
|
||||
Carbon Design System
|
||||
|
@ -34,6 +36,8 @@ An alternative to manually setting `target` to `"_blank"` is to use the `Outboun
|
|||
|
||||
## Inline variant
|
||||
|
||||
Create links that flow naturally with surrounding text.
|
||||
|
||||
<div>
|
||||
Visit the
|
||||
<Link inline href="https://www.carbondesignsystem.com/">
|
||||
|
@ -43,7 +47,7 @@ An alternative to manually setting `target` to `"_blank"` is to use the `Outboun
|
|||
|
||||
## Link with icon
|
||||
|
||||
Note that `inline` must be `false` when rendering a link with an icon.
|
||||
Add icons to links for better visual context. Note that `inline` must be `false` when using icons.
|
||||
|
||||
<div>
|
||||
Visit the
|
||||
|
@ -52,28 +56,34 @@ Note that `inline` must be `false` when rendering a link with an icon.
|
|||
</Link>.
|
||||
</div>
|
||||
|
||||
## Large size
|
||||
## Size variants
|
||||
|
||||
The component supports different sizes to match your design needs:
|
||||
|
||||
<Link size="lg" href="https://www.carbondesignsystem.com/">
|
||||
Carbon Design System
|
||||
Large link
|
||||
</Link>
|
||||
|
||||
## Small size
|
||||
|
||||
<br />
|
||||
<Link href="https://www.carbondesignsystem.com/">
|
||||
Default link
|
||||
</Link>
|
||||
<br />
|
||||
<Link size="sm" href="https://www.carbondesignsystem.com/">
|
||||
Carbon Design System
|
||||
Small link
|
||||
</Link>
|
||||
|
||||
## Disabled
|
||||
## Disabled state
|
||||
|
||||
A `disabled` link will render a `p` tag instead of an anchor element.
|
||||
Disabled links render as plain text while maintaining accessibility.
|
||||
|
||||
<Link disabled href="https://www.carbondesignsystem.com/">
|
||||
Carbon Design System
|
||||
Disabled link
|
||||
</Link>
|
||||
|
||||
## Visited styles
|
||||
|
||||
Show visited state styling for links.
|
||||
|
||||
<Link visited href="https://www.carbondesignsystem.com/">
|
||||
Carbon Design System
|
||||
Visited link
|
||||
</Link>
|
|
@ -1,16 +1,28 @@
|
|||
---
|
||||
components: ["Loading"]
|
||||
---
|
||||
|
||||
<script>
|
||||
import { Loading } from "carbon-components-svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
## Default (with overlay)
|
||||
The `Loading` component provides a full-screen or inline loading indicator. It's ideal for showing progress during page loads or data fetching operations.
|
||||
|
||||
## Default
|
||||
|
||||
Display a loading indicator with a semi-transparent overlay that covers the entire viewport.
|
||||
|
||||
<FileSource src="/framed/Loading/Loading" />
|
||||
|
||||
## No overlay
|
||||
|
||||
Show a loading indicator without the overlay, allowing interaction with the underlying content.
|
||||
|
||||
<Loading withOverlay={false} />
|
||||
|
||||
## Small size
|
||||
|
||||
Display a more compact loading indicator.
|
||||
|
||||
<Loading withOverlay={false} small />
|
|
@ -1,23 +1,26 @@
|
|||
---
|
||||
components: ["LocalStorage"]
|
||||
---
|
||||
|
||||
<script>
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
This utility component wraps the [Window.localStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) and is useful for persisting ephemeral data (e.g., color theme) at the browser level.
|
||||
|
||||
The `LocalStorage` component provides a reactive wrapper around the [Window.localStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). It's useful for persisting user preferences and application state across page reloads.
|
||||
|
||||
## Reactive example
|
||||
|
||||
In the example below, toggle the switch and reload the page. The updated theme should be persisted locally.
|
||||
|
||||
See how the component maintains state across page reloads. Toggle the switch and refresh the page to see the persisted state.
|
||||
|
||||
<FileSource src="/framed/LocalStorage/LocalStorage" />
|
||||
|
||||
## Clear item, clear all
|
||||
|
||||
Use the `bind:this` directive to access the `clearItem` and `clearAll` methods.
|
||||
The component provides methods to manage stored data:
|
||||
|
||||
Invoking `clearItem` will remove the persisted key value from the browser's local storage.
|
||||
- `clearItem`: Remove a specific key-value pair
|
||||
- `clearAll`: Remove all stored data
|
||||
|
||||
Invoking `clearAll` will remove all key values.
|
||||
|
||||
In the following example, toggle the switch and reload the page. Then, click the "Clear storage" button. Refresh the page; the theme should be reset to the untoggled state.
|
||||
Use `bind:this` to access these methods. In this example, try toggling the switch, refreshing the page, then clearing the storage.
|
||||
|
||||
<FileSource src="/framed/LocalStorage/LocalStorageClear" />
|
|
@ -2,60 +2,78 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
## Default (transactional)
|
||||
The `Modal` component provides a focused dialog for user interactions, confirmations, or data entry. It supports various sizes, states, and customization options to create accessible and user-friendly modal experiences.
|
||||
|
||||
## Default
|
||||
|
||||
Display a modal dialog with a header, content area, and footer by default.
|
||||
|
||||
Create a basic modal dialog with primary and secondary actions. This variant is ideal for confirming user actions or gathering input.
|
||||
|
||||
<FileSource src="/framed/Modal/Modal" />
|
||||
|
||||
## Custom focus
|
||||
|
||||
By default, the modal close button will be focused when opened.
|
||||
|
||||
Use the `selectorPrimaryFocus` to specify the element that should be focused when the modal is opened (e.g., `#id`, `.class`, `[data-attribute]`).
|
||||
Control which element receives focus when the modal opens. Use `selectorPrimaryFocus` to specify the target element using CSS selectors.
|
||||
|
||||
<FileSource src="/framed/Modal/ModalCustomFocus" />
|
||||
|
||||
## Danger modal
|
||||
|
||||
Display critical actions or destructive operations with the danger variant. This style emphasizes the severity of the action.
|
||||
|
||||
<FileSource src="/framed/Modal/DangerModal" />
|
||||
|
||||
## Passive modal
|
||||
|
||||
Create a non-interactive modal for displaying information. This variant lacks action buttons and focuses on content presentation.
|
||||
|
||||
<FileSource src="/framed/Modal/PassiveModal" />
|
||||
|
||||
## Has scrolling content
|
||||
|
||||
Setting `hasScrollingContent` to `true` increases the vertical space within the modal.
|
||||
Enable vertical scrolling for modals with lengthy content. This ensures all content remains accessible while maintaining a reasonable modal height.
|
||||
|
||||
<FileSource src="/framed/Modal/ModalScrollingContent" />
|
||||
|
||||
## Multiple modals
|
||||
|
||||
Stack multiple modals for complex workflows. Each modal maintains its own state and focus management.
|
||||
|
||||
<FileSource src="/framed/Modal/ModalMultiple" />
|
||||
|
||||
## Multiple secondary buttons
|
||||
|
||||
Use the `secondaryButtons` prop to render two secondary buttons. The prop is a 2-tuple type that supersedes `secondaryButtonText`.
|
||||
Add up to two secondary actions using the `secondaryButtons` prop. This provides more flexibility than the single `secondaryButtonText` option.
|
||||
|
||||
<FileSource src="/framed/Modal/3ButtonModal" />
|
||||
|
||||
## Extra-small size
|
||||
|
||||
Use the extra-small size for compact notifications by setting `size` to `"xs"`. This is ideal for simple confirmations.
|
||||
|
||||
<FileSource src="/framed/Modal/ModalExtraSmall" />
|
||||
|
||||
## Small size
|
||||
|
||||
Use the small size for simple confirmations by setting `size` to `"sm"`. This provides a more focused dialog.
|
||||
|
||||
<FileSource src="/framed/Modal/ModalSmall" />
|
||||
|
||||
## Large size
|
||||
|
||||
Use the large size for complex content by setting `size` to `"lg"`. This provides more space for detailed information.
|
||||
|
||||
<FileSource src="/framed/Modal/ModalLarge" />
|
||||
|
||||
## Prevent close on outside click
|
||||
|
||||
`preventCloseOnClickOutside` prevents the modal from being closed when clicking outside of an open modal. This prop is intended to be used for transactional modals.
|
||||
Disable closing the modal when clicking outside by setting `preventCloseOnClickOutside` to `true`. This is useful for transactional modals where explicit user action is required.
|
||||
|
||||
<FileSource src="/framed/Modal/ModalPreventOutsideClick" />
|
||||
|
||||
## Button with icon
|
||||
|
||||
Enhance modal buttons with icons for better visual context and clarity. This example shows how to add icons to modal actions.
|
||||
|
||||
<FileSource src="/framed/Modal/ModalButtonWithIcon" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`MultiSelect` is keyed for performance reasons.
|
||||
The `MultiSelect` component provides a dropdown interface for selecting multiple options using checkboxes. It supports filtering, custom formatting, and various states. Each item must have a unique `id` property for proper functionality.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
||||
|
@ -11,12 +11,7 @@
|
|||
|
||||
## Default
|
||||
|
||||
By default, items will be ordered alphabetically based on the `item.text` value.
|
||||
To prevent this, see [#no-alphabetical-ordering](#no-alphabetical-ordering).
|
||||
|
||||
MultiSelect provides interactivity for a list of checkbox inputs. Those
|
||||
checkboxes will remain rendered in the DOM and are submittable within forms.
|
||||
Checkbox attributes can be adjusted via the `itemToInput` prop.
|
||||
Create a basic multi-select dropdown with three contact methods. By default, items are ordered alphabetically.
|
||||
|
||||
<MultiSelect titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
|
@ -26,7 +21,7 @@ Checkbox attributes can be adjusted via the `itemToInput` prop.
|
|||
|
||||
## Format item display text
|
||||
|
||||
Use the `itemToString` prop to format the display of individual items without modifying the underlying value.
|
||||
Format the display text of items using the `itemToString` prop. This example appends the item ID in parentheses.
|
||||
|
||||
<MultiSelect itemToString={item => {
|
||||
return item.text + ' (' + item.id +')'
|
||||
|
@ -39,15 +34,13 @@ Use the `itemToString` prop to format the display of individual items without mo
|
|||
|
||||
## Custom slot
|
||||
|
||||
For even more customization, use the default slot.
|
||||
|
||||
Access the `item` and `index` values through the `let:` directive.
|
||||
Override the default slot to customize item rendering. This example shows how to access and use the item and index values.
|
||||
|
||||
<FileSource src="/framed/MultiSelect/MultiSelectSlot" />
|
||||
|
||||
## No alphabetical ordering
|
||||
|
||||
To prevent alphabetical item ordering, pass a noop function to the `sortItem` prop.
|
||||
Prevent automatic alphabetical ordering by passing a no-op function to `sortItem`. This maintains the original order of items.
|
||||
|
||||
<MultiSelect titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
|
@ -58,9 +51,7 @@ To prevent alphabetical item ordering, pass a noop function to the `sortItem` pr
|
|||
|
||||
## Filterable
|
||||
|
||||
Set `filterable` to `true` to enable filtering.
|
||||
|
||||
`$$restProps` are spread to the underlying input element.
|
||||
Enable filtering by setting `filterable` to `true`. This example includes a placeholder text for the filter input.
|
||||
|
||||
<MultiSelect spellcheck="false" filterable titleText="Contact" placeholder="Filter contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
|
@ -70,7 +61,7 @@ Set `filterable` to `true` to enable filtering.
|
|||
|
||||
## Initial selected items
|
||||
|
||||
To select (or bind) items, pass an array of item ids to `selectedIds`.
|
||||
Pre-select items by passing an array of item IDs to `selectedIds`. This example pre-selects Slack and Email.
|
||||
|
||||
<MultiSelect selectedIds="{["0", "1"]}" titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
|
@ -80,19 +71,24 @@ To select (or bind) items, pass an array of item ids to `selectedIds`.
|
|||
|
||||
## Multiple multi-select dropdowns
|
||||
|
||||
This example demonstrates how to manage multiple dropdowns in a form with coordinated state.
|
||||
|
||||
<FileSource src="/framed/MultiSelect/MultipleMultiSelect" />
|
||||
|
||||
## Format checkbox values
|
||||
|
||||
Customize checkbox attributes using the `itemToInput` prop. This example sets a consistent name for all checkboxes.
|
||||
|
||||
Use the `itemToInput` prop to customize the user-selectable checkbox values.
|
||||
This will also override the underlying hidden inputs used for form submission.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
(item) => ({name: `Contact_${item.id}`], value: item.id})
|
||||
|
||||
|
||||
itemToInput={(item) => {
|
||||
return {
|
||||
name: `Contact_${item.id}`,
|
||||
value: item.id
|
||||
}
|
||||
}}
|
||||
```
|
||||
|
||||
The above function sets the `name` attribute to
|
||||
|
@ -112,7 +108,7 @@ renders, along with each respective item's `id` set to the `value` attribute.
|
|||
|
||||
## Top direction
|
||||
|
||||
Set `direction` to `"top"` for the dropdown menu to appear above the input.
|
||||
Display the dropdown menu above the input by setting `direction` to `"top"`. This is useful when space below is limited.
|
||||
|
||||
<MultiSelect direction="top" titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
|
@ -122,9 +118,7 @@ Set `direction` to `"top"` for the dropdown menu to appear above the input.
|
|||
|
||||
## Hidden label
|
||||
|
||||
Set `hideLabel` to `true` to visually hide the label.
|
||||
|
||||
Note that you should still specify a `label` for accessibility.
|
||||
Hide the label visually while maintaining accessibility by setting `hideLabel` to `true`. The label is still available to screen readers.
|
||||
|
||||
<MultiSelect titleText="Contact" label="Select contact methods..." hideLabel
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
|
@ -134,6 +128,8 @@ Note that you should still specify a `label` for accessibility.
|
|||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for dark backgrounds by setting `light` to `true`. This provides better contrast in dark themes.
|
||||
|
||||
<MultiSelect light titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
|
@ -142,6 +138,8 @@ Note that you should still specify a `label` for accessibility.
|
|||
|
||||
## Inline variant
|
||||
|
||||
Display the dropdown inline with other content by setting `type` to `"inline"`. This removes the background and border.
|
||||
|
||||
<MultiSelect type="inline" titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
|
@ -150,6 +148,8 @@ Note that you should still specify a `label` for accessibility.
|
|||
|
||||
## Extra-large size
|
||||
|
||||
Use the extra-large size for prominent selections by setting `size` to `"xl"`. This provides more visual emphasis.
|
||||
|
||||
<MultiSelect size="xl" titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
|
@ -158,6 +158,8 @@ Note that you should still specify a `label` for accessibility.
|
|||
|
||||
## Small size
|
||||
|
||||
Use the small size for compact layouts by setting `size` to `"sm"`. This is ideal for secondary selections.
|
||||
|
||||
<MultiSelect size="sm" titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
|
@ -166,6 +168,8 @@ Note that you should still specify a `label` for accessibility.
|
|||
|
||||
## Invalid state
|
||||
|
||||
Indicate an invalid selection by setting `invalid` to `true`. This example shows a required field error.
|
||||
|
||||
<MultiSelect invalid invalidText="A contact method is required" titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
|
@ -174,6 +178,8 @@ Note that you should still specify a `label` for accessibility.
|
|||
|
||||
## Warning state
|
||||
|
||||
Indicate a warning state by setting `warn` to `true`. This example shows a warning about unassociated accounts.
|
||||
|
||||
<MultiSelect warn warnText="One or more contact methods are not associated with your account" titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
|
@ -182,6 +188,8 @@ Note that you should still specify a `label` for accessibility.
|
|||
|
||||
## Disabled state
|
||||
|
||||
Disable the entire dropdown by setting `disabled` to `true`. This prevents all user interaction.
|
||||
|
||||
<MultiSelect disabled titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
|
@ -190,7 +198,7 @@ Note that you should still specify a `label` for accessibility.
|
|||
|
||||
## Disabled items
|
||||
|
||||
Use the `disabled` property in the `items` prop to disable specific items.
|
||||
Disable specific items using the `disabled` property in the `items` prop. This example disables the Email option.
|
||||
|
||||
<MultiSelect
|
||||
titleText="Contact"
|
||||
|
|
|
@ -7,74 +7,100 @@ components: ["NumberInput", "NumberInputSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
The `NumberInput` component provides a controlled input for numerical values. It supports validation, step values, and various states to ensure accurate data entry.
|
||||
|
||||
## Default
|
||||
|
||||
This component requires a numerical value for `value`.
|
||||
|
||||
See [#no-value](#no-value) to allow for an empty value.
|
||||
Create a basic number input with increment and decrement controls. The input accepts numerical values and provides visual feedback.
|
||||
|
||||
<NumberInput label="Clusters" value={0} />
|
||||
|
||||
## With helper text
|
||||
## No value
|
||||
|
||||
Allow empty values by setting both `allowEmpty` to `true` and `value` to `null`. The `allowEmpty` prop enables the empty state, while `value={null}` represents no value.
|
||||
|
||||
<FileSource src="/framed/NumberInput/NumberInputEmpty" />
|
||||
|
||||
## Helper text
|
||||
|
||||
Add descriptive text below the input using the `helperText` prop. This helps users understand the expected input.
|
||||
|
||||
<NumberInput label="Clusters" value={0} helperText="Clusters provisioned in your region" />
|
||||
|
||||
## Minimum and maximum values
|
||||
|
||||
Constrain input values using `min` and `max` props. This example limits values between 4 and 20.
|
||||
|
||||
<NumberInput min="{4}" max="{20}" value="{4}" invalidText="Number must be between 4 and 20." helperText="Clusters provisioned in your region" label="Clusters (4 min, 20 max)" />
|
||||
|
||||
## With step value
|
||||
## Step value
|
||||
|
||||
Control the increment/decrement step size using the `step` prop. This example uses a step of 0.1.
|
||||
|
||||
<NumberInput value="{1}" helperText="Step of 0.1" step={0.1} label="Clusters" />
|
||||
|
||||
## No value
|
||||
|
||||
Set `allowEmpty` to `true` to allow for no value.
|
||||
|
||||
Set `value` to `null` to denote "no value."
|
||||
|
||||
<FileSource src="/framed/NumberInput/NumberInputEmpty" />
|
||||
|
||||
## Hidden label
|
||||
|
||||
Hide the label visually while maintaining accessibility by setting `hideLabel` to `true`. The label is still available to screen readers.
|
||||
|
||||
<NumberInput hideLabel label="Clusters" value={0} />
|
||||
|
||||
## Hidden steppers
|
||||
|
||||
<NumberInput hideSteppers label="Clusters" value={0} />
|
||||
|
||||
## Light variant
|
||||
|
||||
<NumberInput light label="Clusters" value={0} />
|
||||
|
||||
## Read-only variant
|
||||
|
||||
<NumberInput readonly label="Clusters" value={0} />
|
||||
|
||||
## Extra-large size
|
||||
|
||||
Use the extra-large size for prominent inputs by setting `size` to `"xl"`. This provides more visual emphasis.
|
||||
|
||||
<NumberInput size="xl" label="Clusters" value={0} />
|
||||
|
||||
## Small size
|
||||
|
||||
Use the small size for compact layouts by setting `size` to `"sm"`. This is ideal for secondary inputs.
|
||||
|
||||
<NumberInput size="sm" label="Clusters" value={0} />
|
||||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for dark backgrounds by setting `light` to `true`. This provides better contrast in dark themes.
|
||||
|
||||
<NumberInput light label="Clusters" value={0} />
|
||||
|
||||
## Invalid state
|
||||
|
||||
Indicate an invalid value by setting `invalid` to `true`. This example shows a validation error.
|
||||
|
||||
<NumberInput invalid invalidText="Invalid value" label="Clusters" value={0} />
|
||||
|
||||
## Warning state
|
||||
|
||||
Indicate a warning state by setting `warn` to `true`. This example shows a warning about the input value.
|
||||
|
||||
<NumberInput warn warnText="A high number may impact initial rollout" label="Clusters" value={25} />
|
||||
|
||||
## Disabled state
|
||||
|
||||
Disable the input by setting `disabled` to `true`. This prevents all user interaction.
|
||||
|
||||
<NumberInput disabled label="Clusters" value={0} />
|
||||
|
||||
## Read-only state
|
||||
|
||||
Make the input read-only by setting `readonly` to `true`. This allows viewing but prevents editing.
|
||||
|
||||
<NumberInput readonly label="Clusters" value={0} />
|
||||
|
||||
## Hidden steppers
|
||||
|
||||
Hide the increment/decrement controls by setting `hideSteppers` to `true`. This provides a simpler input interface.
|
||||
|
||||
<NumberInput hideSteppers label="Clusters" value={0} />
|
||||
|
||||
## Skeleton
|
||||
|
||||
Show a loading state using the `NumberInputSkeleton` component. This is useful while data is being fetched.
|
||||
|
||||
<NumberInputSkeleton />
|
||||
|
||||
## Skeleton without label
|
||||
|
||||
Show a loading state without a label by setting `hideLabel` to `true`. This maintains layout consistency.
|
||||
|
||||
<NumberInputSkeleton hideLabel />
|
|
@ -7,14 +7,18 @@ components: ["OrderedList", "ListItem"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`OrderedList` provides a structured way to display numbered lists of items. It supports nested lists, native browser styles, and expressive typography for enhanced visual hierarchy.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Tip:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">
|
||||
Consider using the <Link href="/components/RecursiveList#ordered">RecursiveList</Link> component for rendering tree structured data.
|
||||
</div>
|
||||
</div>
|
||||
</InlineNotification>
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic ordered list by wrapping `ListItem` components within `OrderedList`.
|
||||
|
||||
<OrderedList>
|
||||
<ListItem>Ordered list item</ListItem>
|
||||
<ListItem>Ordered list item</ListItem>
|
||||
|
@ -23,6 +27,8 @@ components: ["OrderedList", "ListItem"]
|
|||
|
||||
## With links
|
||||
|
||||
Add interactive elements like `Link` components within list items.
|
||||
|
||||
<OrderedList>
|
||||
<ListItem>
|
||||
<Link href="#">Ordered list item</Link>
|
||||
|
@ -37,6 +43,8 @@ components: ["OrderedList", "ListItem"]
|
|||
|
||||
## Nested
|
||||
|
||||
Set the `nested` prop to `true` to create hierarchical lists with proper indentation and numbering.
|
||||
|
||||
<OrderedList>
|
||||
<ListItem>
|
||||
Ordered list level 1
|
||||
|
@ -57,7 +65,7 @@ components: ["OrderedList", "ListItem"]
|
|||
|
||||
## Native list styles
|
||||
|
||||
Use the `native` attribute to enable default browser list styles. This is useful for large lists (i.e., 1000 or more items) where the list number may overlap with the list item text.
|
||||
Enable native browser list styles by setting the `native` prop to `true`. This is useful for large lists where the list number may overlap with the list item text.
|
||||
|
||||
<OrderedList native>
|
||||
<ListItem>
|
||||
|
@ -79,7 +87,7 @@ Use the `native` attribute to enable default browser list styles. This is useful
|
|||
|
||||
## Expressive styles
|
||||
|
||||
Set `expressive` to `true` to use Carbon's expressive typesetting.
|
||||
Use Carbon's expressive typesetting by setting the `expressive` prop to `true`.
|
||||
|
||||
<OrderedList expressive>
|
||||
<ListItem><Link size="lg" href="#">Ordered list item</Link></ListItem>
|
||||
|
|
|
@ -8,8 +8,12 @@ components: ["OverflowMenu", "OverflowMenuItem"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`OverflowMenu` provides a compact way to display a list of actions or options. It renders as a button that opens a dropdown menu when clicked, making it ideal for secondary actions or overflow content.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic overflow menu by wrapping `OverflowMenuItem` components within `OverflowMenu`.
|
||||
|
||||
<OverflowMenu>
|
||||
<OverflowMenuItem text="Manage credentials" />
|
||||
<OverflowMenuItem href="https://cloud.ibm.com/docs/api-gateway/" text="API documentation" />
|
||||
|
@ -18,7 +22,7 @@ components: ["OverflowMenu", "OverflowMenuItem"]
|
|||
|
||||
## Flipped
|
||||
|
||||
Set `flipped` to `true` for the menu to be positioned to the left of the button.
|
||||
Set `flipped` to `true` to position the menu to the left of the button.
|
||||
|
||||
<OverflowMenu flipped>
|
||||
<OverflowMenuItem text="Manage credentials" />
|
||||
|
@ -26,7 +30,9 @@ Set `flipped` to `true` for the menu to be positioned to the left of the button.
|
|||
<OverflowMenuItem danger text="Delete service" />
|
||||
</OverflowMenu>
|
||||
|
||||
## Menu direction top
|
||||
## Menu direction
|
||||
|
||||
Set `direction` to `"top"` to position the menu above the button.
|
||||
|
||||
<OverflowMenu flipped direction="top">
|
||||
<OverflowMenuItem text="Manage credentials" />
|
||||
|
@ -36,6 +42,8 @@ Set `flipped` to `true` for the menu to be positioned to the left of the button.
|
|||
|
||||
## Light variant
|
||||
|
||||
Enable the light variant by setting `light` to `true`.
|
||||
|
||||
<OverflowMenu light>
|
||||
<OverflowMenuItem text="Manage credentials" />
|
||||
<OverflowMenuItem href="https://cloud.ibm.com/docs/api-gateway/" text="API documentation" />
|
||||
|
@ -44,6 +52,8 @@ Set `flipped` to `true` for the menu to be positioned to the left of the button.
|
|||
|
||||
## Extra-large size
|
||||
|
||||
Set `size` to `"xl"` for an extra-large overflow menu.
|
||||
|
||||
<OverflowMenu size="xl">
|
||||
<OverflowMenuItem text="Manage credentials" />
|
||||
<OverflowMenuItem href="https://cloud.ibm.com/docs/api-gateway/" text="API documentation" />
|
||||
|
@ -52,6 +62,8 @@ Set `flipped` to `true` for the menu to be positioned to the left of the button.
|
|||
|
||||
## Small size
|
||||
|
||||
Set `size` to `"sm"` for a small overflow menu.
|
||||
|
||||
<OverflowMenu size="sm">
|
||||
<OverflowMenuItem text="Manage credentials" />
|
||||
<OverflowMenuItem href="https://cloud.ibm.com/docs/api-gateway/" text="API documentation" />
|
||||
|
@ -60,7 +72,7 @@ Set `flipped` to `true` for the menu to be positioned to the left of the button.
|
|||
|
||||
## Custom primary focus
|
||||
|
||||
By default, the first overflow menu item is focused when opening the dropdown.
|
||||
Set `primaryFocus` to `true` on a menu item to focus it when opening the dropdown.
|
||||
|
||||
<OverflowMenu>
|
||||
<OverflowMenuItem text="Manage credentials" />
|
||||
|
@ -70,6 +82,8 @@ By default, the first overflow menu item is focused when opening the dropdown.
|
|||
|
||||
## Custom trigger icon
|
||||
|
||||
Replace the default vertical overflow menu icon with a custom icon.
|
||||
|
||||
<OverflowMenu icon={Add}>
|
||||
<OverflowMenuItem text="Manage credentials" />
|
||||
<OverflowMenuItem href="https://cloud.ibm.com/docs/api-gateway/" text="API documentation" />
|
||||
|
@ -78,6 +92,8 @@ By default, the first overflow menu item is focused when opening the dropdown.
|
|||
|
||||
## Custom trigger slot
|
||||
|
||||
Use the `menu` slot to customize the trigger button content.
|
||||
|
||||
<OverflowMenu style="width: auto;">
|
||||
<div slot="menu" style="padding: 1rem; color: red;">Custom trigger</div>
|
||||
<OverflowMenuItem text="Manage credentials" />
|
||||
|
@ -87,7 +103,7 @@ By default, the first overflow menu item is focused when opening the dropdown.
|
|||
|
||||
## Disabled items
|
||||
|
||||
Disable menu items by setting `disabled` to `true`.
|
||||
Set `disabled` to `true` to disable menu items. Use `hasDivider` to add visual separation between items.
|
||||
|
||||
<OverflowMenu>
|
||||
<OverflowMenuItem text="Create key" />
|
||||
|
|
|
@ -7,26 +7,52 @@ components: ["Pagination", "PaginationSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Pagination` provides navigation controls for large data sets. It displays the current page, total items, and allows users to change page size and navigate between pages.
|
||||
|
||||
## Default
|
||||
|
||||
<Pagination totalItems={102} pageSizes="{[10, 15, 20]}" />
|
||||
Create a basic pagination component with default page size options.
|
||||
|
||||
<Pagination totalItems={102} pageSizes={[10, 15, 20]} />
|
||||
|
||||
## Current page
|
||||
|
||||
Set the current page using the `page` prop.
|
||||
|
||||
<Pagination totalItems={102} page={4} />
|
||||
|
||||
## Custom page sizes
|
||||
|
||||
<Pagination totalItems={102} pageSizes="{[16, 36, 99]}" pageSize="{36}" />
|
||||
Specify custom page sizes and set a default page size.
|
||||
|
||||
<Pagination totalItems={102} pageSizes={[16, 36, 99]} pageSize={36} />
|
||||
|
||||
## Unknown pages
|
||||
|
||||
Set `pagesUnknown` to `true` when the total number of pages is unknown. This renders the item range text without factoring in the total number of pages.
|
||||
|
||||
<Pagination pagesUnknown />
|
||||
|
||||
## Page window
|
||||
|
||||
The number of native select items rendered is derived from `totalItems`. For large datasets, this can impact performance. Use `pageWindow` to control the number of rendered items.
|
||||
|
||||
<Pagination totalItems={100_000} pageSizes={[10, 15, 20]} />
|
||||
|
||||
## Hidden page input
|
||||
|
||||
Disable the page input by setting `pageInputDisabled` to `true`.
|
||||
|
||||
<Pagination totalItems={102} pageInputDisabled />
|
||||
|
||||
## Hidden page size
|
||||
|
||||
Disable the page size selector by setting `pageSizeInputDisabled` to `true`.
|
||||
|
||||
<Pagination totalItems={102} pageSizeInputDisabled />
|
||||
|
||||
## Skeleton
|
||||
|
||||
Use `PaginationSkeleton` to show a loading state.
|
||||
|
||||
<PaginationSkeleton />
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`PaginationNav` provides a compact navigation interface for paginated content. It displays page numbers and navigation buttons, with support for overflow menus when there are many pages.
|
||||
|
||||
## Default
|
||||
|
||||
`PaginationNav` renders `10` items and does not loop by default.
|
||||
Create a basic pagination navigation with default settings.
|
||||
|
||||
<PaginationNav />
|
||||
|
||||
|
@ -15,37 +17,35 @@ Use the `page` prop to bind to the current page number.
|
|||
|
||||
<FileSource src="/framed/PaginationNav/PaginationNavReactive" />
|
||||
|
||||
## Total
|
||||
## Total pages
|
||||
|
||||
Use the `total` prop to specify the number of pages.
|
||||
Specify the total number of pages using the `total` prop.
|
||||
|
||||
<PaginationNav total={3} />
|
||||
|
||||
## Loopable
|
||||
## Loop navigation
|
||||
|
||||
Set `loop` to `true` for navigation to be looped.
|
||||
Set `loop` to `true` to enable circular navigation between pages.
|
||||
|
||||
<PaginationNav total={3} loop />
|
||||
|
||||
## Shown
|
||||
## Visible pages
|
||||
|
||||
If `total` is greater than `10`, the number of items shown will be truncated to `10`.
|
||||
Control the number of visible page numbers with the `shown` prop.
|
||||
|
||||
Use `shown` to override the number of items shown.
|
||||
|
||||
<PaginationNav total={100} shown={5} />
|
||||
<PaginationNav total={100} shown={5} />
|
||||
|
||||
## Custom button text
|
||||
|
||||
Use the `forwardText` and `backwardText` props to customize the button text.
|
||||
Customize the navigation button text using `forwardText` and `backwardText`.
|
||||
|
||||
<PaginationNav
|
||||
forwardText="Next"
|
||||
backwardText="Previous"
|
||||
/>
|
||||
|
||||
## Tooltip Position
|
||||
## Tooltip position
|
||||
|
||||
Use the `tooltipPosition` prop to change the alignment of the tooltip.
|
||||
Set the tooltip position relative to the navigation buttons using `tooltipPosition`.
|
||||
|
||||
<PaginationNav tooltipPosition="outside" total={3} loop />
|
|
@ -3,8 +3,12 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`PasswordInput` provides a secure text input field with a visibility toggle for password entry. It includes features for validation, warnings, and accessibility.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic password input with a label and placeholder.
|
||||
|
||||
<PasswordInput labelText="Password" placeholder="Enter password..." />
|
||||
|
||||
## Custom tooltip alignment
|
||||
|
@ -21,36 +25,54 @@ Set prop `type` to `"text"` to toggle password visibility.
|
|||
|
||||
## Hidden label
|
||||
|
||||
Visually hide the label while maintaining accessibility.
|
||||
|
||||
<PasswordInput hideLabel labelText="Password" placeholder="Enter password..." />
|
||||
|
||||
## Light variant
|
||||
|
||||
Enable the light variant for use on dark backgrounds.
|
||||
|
||||
<PasswordInput light labelText="Password" placeholder="Enter password..." />
|
||||
|
||||
## Inline
|
||||
|
||||
Display the input with an inline label layout.
|
||||
|
||||
<PasswordInput inline labelText="Password" placeholder="Enter password..." />
|
||||
|
||||
## Extra-large size
|
||||
|
||||
Use the extra-large size variant for increased visibility.
|
||||
|
||||
<PasswordInput size="xl" labelText="Password" placeholder="Enter password..." />
|
||||
|
||||
## Small size
|
||||
|
||||
Use the small size variant for compact layouts.
|
||||
|
||||
<PasswordInput size="sm" labelText="Password" placeholder="Enter password..." />
|
||||
|
||||
## Invalid state
|
||||
|
||||
Display an error message when the input is invalid.
|
||||
|
||||
<PasswordInput invalid invalidText="Incorrect user name or password." labelText="Password" placeholder="Enter password..." />
|
||||
|
||||
## Warning state
|
||||
|
||||
Show a warning message for non-critical issues.
|
||||
|
||||
<PasswordInput warn warnText="Password has been reset." labelText="Password" placeholder="Enter password..." />
|
||||
|
||||
## Disabled state
|
||||
|
||||
Disable the input to prevent user interaction.
|
||||
|
||||
<PasswordInput disabled labelText="Password" placeholder="Enter password..." />
|
||||
|
||||
## With helper text
|
||||
|
||||
Add helper text to provide additional context or instructions.
|
||||
|
||||
<PasswordInput helperText="Your password should be hard to guess" labelText="Password" placeholder="Enter password..." />
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Popover` provides a floating container that displays content relative to a trigger element. It supports various alignments, caret indicators, and visual variants.
|
||||
|
||||
## Default
|
||||
|
||||
By default, the position of the popover component is absolute.
|
||||
Create a basic popover with absolute positioning.
|
||||
|
||||
<div data-outline>
|
||||
Parent
|
||||
|
@ -16,7 +18,7 @@ By default, the position of the popover component is absolute.
|
|||
|
||||
## Relative position
|
||||
|
||||
Set `relative` to `true` to use a relative position.
|
||||
Set `relative` to `true` to position the popover relative to its parent element.
|
||||
|
||||
<div data-outline>
|
||||
Parent
|
||||
|
@ -27,7 +29,7 @@ Set `relative` to `true` to use a relative position.
|
|||
|
||||
## Close on outside click
|
||||
|
||||
Set `closeOnOutsideClick` to set `open` to `false` when clicking outside of the popover.
|
||||
Enable automatic closing when clicking outside the popover using `closeOnOutsideClick`.
|
||||
|
||||
<div data-outline>
|
||||
Parent
|
||||
|
@ -111,6 +113,8 @@ The default `align` value is `"top"`.
|
|||
|
||||
## With caret
|
||||
|
||||
Add a caret indicator to the popover using the `caret` prop.
|
||||
|
||||
<div data-outline>
|
||||
Parent
|
||||
<Popover caret open>
|
||||
|
@ -120,9 +124,7 @@ The default `align` value is `"top"`.
|
|||
|
||||
## Custom caret alignment
|
||||
|
||||
By default, the caret is aligned "top".
|
||||
|
||||
Possible `align` values include `"top"`, `"top-left"`, `"top-right"`, `"bottom"`, `"bottom-left"`, `"bottom-right"`, `"left"`, `"left-bottom"`, `"left-top"`, `"right"`, `"right-bottom"` or `"right-top"`.
|
||||
By default, the caret is aligned "top". Possible `align` values include `"top"`, `"top-left"`, `"top-right"`, `"bottom"`, `"bottom-left"`, `"bottom-right"`, `"left"`, `"left-bottom"`, `"left-top"`, `"right"`, `"right-bottom"` or `"right-top"`.
|
||||
|
||||
<div data-outline>
|
||||
Parent
|
||||
|
@ -133,6 +135,8 @@ Possible `align` values include `"top"`, `"top-left"`, `"top-right"`, `"bottom"`
|
|||
|
||||
## Light variant
|
||||
|
||||
Enable the light variant for use on dark backgrounds.
|
||||
|
||||
<div data-outline>
|
||||
Parent
|
||||
<Popover light open>
|
||||
|
@ -142,6 +146,8 @@ Possible `align` values include `"top"`, `"top-left"`, `"top-right"`, `"bottom"`
|
|||
|
||||
## High contrast variant
|
||||
|
||||
Enable the high contrast variant for improved visibility.
|
||||
|
||||
<div data-outline>
|
||||
Parent
|
||||
<Popover highContrast open>
|
||||
|
|
|
@ -3,66 +3,70 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`ProgressBar` provides a visual indicator of progress for operations such as file uploads or data processing. It supports determinate and indeterminate states, various sizes, and status indicators.
|
||||
|
||||
## Default
|
||||
|
||||
Without a specified `value` prop, the progress bar is indeterminate.
|
||||
Create an indeterminate progress bar that continuously animates.
|
||||
|
||||
<ProgressBar helperText="Loading..." />
|
||||
|
||||
## Small size
|
||||
|
||||
Specify `size="sm"` to use the small variant.
|
||||
Use the small size variant for compact layouts.
|
||||
|
||||
<ProgressBar size="sm" helperText="Loading..." />
|
||||
|
||||
## Percentage
|
||||
|
||||
Specify a `value` for the progress bar to be determinate.
|
||||
Display progress as a percentage using the `value` prop.
|
||||
|
||||
<ProgressBar value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
||||
|
||||
## Finished status
|
||||
|
||||
Specify `status="finished"` for the progress bar.
|
||||
Show completion status with a checkmark icon.
|
||||
|
||||
<ProgressBar value={100} status="finished" labelText="Upload file" helperText="Upload complete" />
|
||||
|
||||
## Error status
|
||||
|
||||
Specify `status="error"` for the progress bar.
|
||||
Indicate errors with an error icon and red styling.
|
||||
|
||||
<ProgressBar value={0} status="error" labelText="Upload file" helperText="Invalid file format" />
|
||||
|
||||
## Custom max value
|
||||
|
||||
The default `max` value is `100`.
|
||||
Set a custom maximum value for the progress bar.
|
||||
|
||||
<ProgressBar value={40} max={200} labelText="Upload status" helperText="40 MB of 200 MB" />
|
||||
|
||||
## Hidden label
|
||||
|
||||
It's recommended that you provide a `labelText` for accessibility.
|
||||
|
||||
Use `hideLabel` to visually hide the label text.
|
||||
Visually hide the label while maintaining accessibility.
|
||||
|
||||
<ProgressBar hideLabel value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
||||
|
||||
## Inline variant
|
||||
|
||||
The inline variant visually hides the `helperText`.
|
||||
Use the inline variant to display progress without helper text.
|
||||
|
||||
<ProgressBar kind="inline" value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
||||
|
||||
## Indented variant
|
||||
|
||||
Use the indented variant for a more compact layout.
|
||||
|
||||
<ProgressBar kind="indented" value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
||||
|
||||
## Indented status variant
|
||||
|
||||
Combine the indented variant with status indicators.
|
||||
|
||||
<ProgressBar kind="indented" status="finished" value={40} labelText="Upload file" helperText="Upload complete" />
|
||||
|
||||
## UX example
|
||||
|
||||
This example shows how to animate the progress bar from 0 to 100% with start and end states.
|
||||
Demonstrate a complete upload flow with start and end states.
|
||||
|
||||
<FileSource src="/framed/ProgressBar/ProgressBarUx" />
|
|
@ -7,7 +7,11 @@ components: ["ProgressIndicator", "ProgressStep", "ProgressIndicatorSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
## Default (horizontal)
|
||||
`ProgressIndicator` provides a visual representation of progress through a sequence of steps. It supports horizontal and vertical layouts, step completion states, and interactive navigation.
|
||||
|
||||
## Default
|
||||
|
||||
Create a horizontal progress indicator with four steps.
|
||||
|
||||
<ProgressIndicator currentIndex={2}>
|
||||
<ProgressStep complete
|
||||
|
@ -30,9 +34,7 @@ components: ["ProgressIndicator", "ProgressStep", "ProgressIndicatorSkeleton"]
|
|||
|
||||
## Prevent change on click
|
||||
|
||||
By default, clicking any step that is complete will update the current step index.
|
||||
|
||||
Set `preventChangeOnClick` to `true` to prevent this behavior.
|
||||
Disable automatic step selection when clicking completed steps.
|
||||
|
||||
<ProgressIndicator preventChangeOnClick currentIndex={2}>
|
||||
<ProgressStep complete
|
||||
|
@ -55,12 +57,14 @@ Set `preventChangeOnClick` to `true` to prevent this behavior.
|
|||
|
||||
## Programmatic usage
|
||||
|
||||
When programmatically updating the `currentIndex`, keep in mind that only completed steps should be selectable.
|
||||
Update the current step programmatically while maintaining step completion rules.
|
||||
|
||||
<FileSource src="/framed/ProgressIndicator/ProgrammaticProgressIndicator" />
|
||||
|
||||
## Invalid step
|
||||
|
||||
Mark a step as invalid to indicate an error state.
|
||||
|
||||
<ProgressIndicator>
|
||||
<ProgressStep complete
|
||||
label="Step 1"
|
||||
|
@ -78,6 +82,8 @@ When programmatically updating the `currentIndex`, keep in mind that only comple
|
|||
|
||||
## Disabled steps
|
||||
|
||||
Disable specific steps to prevent user interaction.
|
||||
|
||||
<ProgressIndicator>
|
||||
<ProgressStep complete
|
||||
label="Step 1"
|
||||
|
@ -95,6 +101,8 @@ When programmatically updating the `currentIndex`, keep in mind that only comple
|
|||
|
||||
## Spaced-equally
|
||||
|
||||
Distribute steps evenly across the available space.
|
||||
|
||||
<ProgressIndicator spaceEqually>
|
||||
<ProgressStep
|
||||
label="Really long label"
|
||||
|
@ -112,6 +120,8 @@ When programmatically updating the `currentIndex`, keep in mind that only comple
|
|||
|
||||
## Vertical
|
||||
|
||||
Display steps in a vertical layout.
|
||||
|
||||
<ProgressIndicator vertical>
|
||||
<ProgressStep
|
||||
label="Really long label"
|
||||
|
@ -129,10 +139,12 @@ When programmatically updating the `currentIndex`, keep in mind that only comple
|
|||
|
||||
## Skeleton
|
||||
|
||||
Use the `count` prop to specify the number of progress steps to render.
|
||||
Show a loading state with the specified number of steps.
|
||||
|
||||
<ProgressIndicatorSkeleton />
|
||||
|
||||
## Skeleton (vertical)
|
||||
|
||||
Show a vertical loading state with the specified number of steps.
|
||||
|
||||
<ProgressIndicatorSkeleton vertical />
|
|
@ -7,9 +7,11 @@ components: ["RadioButtonGroup", "RadioButton", "RadioButtonSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`RadioButton` provides a selection control that allows users to choose a single option from a set. It supports both individual and grouped usage, with options for horizontal and vertical layouts.
|
||||
|
||||
## Default
|
||||
|
||||
The `name` prop set on `RadioButtonGroup` is passed to the individual `RadioButton` inputs.
|
||||
Create a group of radio buttons with a shared name and legend.
|
||||
|
||||
<RadioButtonGroup legendText="Storage tier (disk)" name="plan" selected="standard">
|
||||
<RadioButton labelText="Free (1 GB)" value="free" />
|
||||
|
@ -19,9 +21,7 @@ The `name` prop set on `RadioButtonGroup` is passed to the individual `RadioButt
|
|||
|
||||
## Hidden legend
|
||||
|
||||
It's recommended that you provide a legend for accessibility.
|
||||
|
||||
Use `hideLegend` to visually hide the legend text.
|
||||
Visually hide the legend while maintaining accessibility.
|
||||
|
||||
<RadioButtonGroup hideLegend legendText="Storage tier (disk)" name="plan-legend" selected="standard">
|
||||
<RadioButton labelText="Free (1 GB)" value="free" />
|
||||
|
@ -31,7 +31,7 @@ Use `hideLegend` to visually hide the legend text.
|
|||
|
||||
## Legend text slot
|
||||
|
||||
Use the named "legendText" slot to customize the legend text.
|
||||
Customize the legend text with additional content.
|
||||
|
||||
<RadioButtonGroup name="plan-legend-slot" selected="standard">
|
||||
<div slot="legendText" style:display="flex">
|
||||
|
@ -49,12 +49,14 @@ Use the named "legendText" slot to customize the legend text.
|
|||
|
||||
## Reactive example
|
||||
|
||||
Use the `selected` prop to bind and update the selected value.
|
||||
Bind and update the selected value programmatically.
|
||||
|
||||
<FileSource src="/framed/RadioButton/RadioButtonReactive" />
|
||||
|
||||
## Left-aligned label text
|
||||
|
||||
Position labels to the left of the radio buttons.
|
||||
|
||||
<RadioButtonGroup labelPosition="left" legendText="Storage tier (disk)" name="plan-left-aligned" selected="standard">
|
||||
<RadioButton labelText="Free (1 GB)" value="free" />
|
||||
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
||||
|
@ -63,6 +65,8 @@ Use the `selected` prop to bind and update the selected value.
|
|||
|
||||
## Disabled buttons
|
||||
|
||||
Disable specific radio buttons to prevent selection.
|
||||
|
||||
<RadioButtonGroup labelPosition="left" legendText="Storage tier (disk)" name="plan-disabled" selected="standard">
|
||||
<RadioButton disabled labelText="Free (1 GB)" value="free" />
|
||||
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
||||
|
@ -71,6 +75,8 @@ Use the `selected` prop to bind and update the selected value.
|
|||
|
||||
## Vertical orientation
|
||||
|
||||
Display radio buttons in a vertical layout.
|
||||
|
||||
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)" name="plan-vertical" selected="standard">
|
||||
<RadioButton labelText="Free (1 GB)" value="free" />
|
||||
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
||||
|
@ -79,6 +85,8 @@ Use the `selected` prop to bind and update the selected value.
|
|||
|
||||
## Skeleton
|
||||
|
||||
Show a loading state for horizontal radio buttons.
|
||||
|
||||
<RadioButtonGroup legendText="Storage tier (disk)">
|
||||
<RadioButtonSkeleton />
|
||||
<RadioButtonSkeleton />
|
||||
|
@ -87,6 +95,8 @@ Use the `selected` prop to bind and update the selected value.
|
|||
|
||||
## Skeleton (vertical)
|
||||
|
||||
Show a loading state for vertical radio buttons.
|
||||
|
||||
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)">
|
||||
<RadioButtonSkeleton />
|
||||
<RadioButtonSkeleton />
|
||||
|
|
|
@ -7,8 +7,12 @@ components: ["TileGroup", "RadioTile"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`RadioTile` provides a selectable tile interface for choosing a single option from a set. It supports both individual and grouped usage, with options for light and disabled states.
|
||||
|
||||
## Default
|
||||
|
||||
Create a group of radio tiles with a shared name and legend.
|
||||
|
||||
<TileGroup legend="Service pricing tiers" name="plan" selected="standard">
|
||||
<RadioTile value="lite">
|
||||
Lite plan
|
||||
|
@ -23,16 +27,20 @@ components: ["TileGroup", "RadioTile"]
|
|||
|
||||
## Reactive (one-way binding)
|
||||
|
||||
Update the selected value using the `select` event.
|
||||
|
||||
<FileSource src="/framed/RadioTile/RadioTileReactiveOneWay" />
|
||||
|
||||
## Reactive (two-way binding)
|
||||
|
||||
Binding to the `selected` prop is a more concise approach to managing state.
|
||||
Bind to the `selected` prop for simpler state management.
|
||||
|
||||
<FileSource src="/framed/RadioTile/RadioTileReactive" />
|
||||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for light backgrounds.
|
||||
|
||||
<TileGroup legend="Service pricing tiers" name="plan-light" selected="standard">
|
||||
<RadioTile light value="lite">
|
||||
Lite plan
|
||||
|
@ -47,6 +55,8 @@ Binding to the `selected` prop is a more concise approach to managing state.
|
|||
|
||||
## Disabled state
|
||||
|
||||
Disable specific tiles to prevent selection.
|
||||
|
||||
<TileGroup legend="Service pricing tiers" name="plan-disabled" selected="standard">
|
||||
<RadioTile value="lite" disabled>
|
||||
Lite plan
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
This component uses the [svelte:self API](https://svelte.dev/docs#svelte_self) to render the [UnorderedList](/components/UnorderedList) and [OrderedList](/components/OrderedList) components with tree structured data.
|
||||
|
||||
A child node can render text, a link, HTML content, and other child nodes.
|
||||
`RecursiveList` provides a flexible way to render hierarchical data structures using either unordered or ordered lists. It supports nested nodes, links, and HTML content, making it ideal for displaying complex data hierarchies.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">
|
||||
|
@ -19,22 +17,26 @@ A child node can render text, a link, HTML content, and other child nodes.
|
|||
</div>
|
||||
</InlineNotification>
|
||||
|
||||
## Unordered
|
||||
## Default
|
||||
|
||||
The `nodes` prop accepts an array of child nodes.
|
||||
|
||||
By default, the list type is unordered.
|
||||
Create a hierarchical list using the `nodes` prop. Each node can contain text, links, HTML content, and nested nodes.
|
||||
|
||||
<FileSource src="/framed/RecursiveList/RecursiveList" />
|
||||
|
||||
## Ordered
|
||||
|
||||
Set `type` to `"ordered"` to use the ordered list variant.
|
||||
Set `type` to `"ordered"` to use numbered lists with proper indentation.
|
||||
|
||||
<FileSource src="/framed/RecursiveList/RecursiveListOrdered" />
|
||||
|
||||
## Ordered (native styles)
|
||||
|
||||
Set `type` to `"ordered-native"` to use the native styles for an ordered list.
|
||||
Set `type` to `"ordered-native"` to use browser-native numbering styles.
|
||||
|
||||
<FileSource src="/framed/RecursiveList/RecursiveListOrderedNative" />
|
||||
<FileSource src="/framed/RecursiveList/RecursiveListOrderedNative" />
|
||||
|
||||
## Flat data structure
|
||||
|
||||
Convert flat data structures to hierarchical arrays using the `toHierarchy` utility function.
|
||||
|
||||
<FileSource src="/framed/RecursiveList/RecursiveListFlatArray" />
|
||||
|
|
|
@ -4,54 +4,72 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Search` provides a flexible search input component with support for expandable variants, different sizes, and custom icons. It includes built-in functionality for clearing input and handling keyboard events.
|
||||
|
||||
## Default
|
||||
|
||||
The `Search` component size is extra-large by default. There are [large](#large-size) and [small](#small-size) size variants.
|
||||
The search component is extra-large by default. Use the `size` prop to choose between [large](#large-size) and [small](#small-size) variants.
|
||||
|
||||
<Search />
|
||||
|
||||
## Default value
|
||||
|
||||
Set an initial value using the `value` prop.
|
||||
|
||||
<Search placeholder="Search catalog..." value="Cloud functions" />
|
||||
|
||||
## Reactive example
|
||||
|
||||
Bind to the `value` prop for reactive updates.
|
||||
|
||||
<FileSource src="/framed/Search/SearchReactive" />
|
||||
|
||||
## on:clear
|
||||
## Clear event
|
||||
|
||||
The "clear" event is dispatched when clicking the "X" button or when pressing the "Escape" key.
|
||||
The `clear` event is dispatched when clicking the clear button or pressing the Escape key.
|
||||
|
||||
<Search value="Cloud functions" on:clear={() => console.log('clear')}/>
|
||||
|
||||
## Expandable variant
|
||||
|
||||
Set `expandable` to `true` to use the expandable variant.
|
||||
Enable the expandable variant to show a compact search icon that expands on focus.
|
||||
|
||||
<FileSource src="/framed/Search/SearchExpandableReactive" />
|
||||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for light backgrounds.
|
||||
|
||||
<Search light />
|
||||
|
||||
## Large size
|
||||
|
||||
Set `size` to `"lg"` for a large search input.
|
||||
|
||||
<Search size="lg" />
|
||||
|
||||
## Small size
|
||||
|
||||
Set `size` to `"sm"` for a small search input.
|
||||
|
||||
<Search size="sm" />
|
||||
|
||||
## Disabled state
|
||||
|
||||
Disable the search input using the `disabled` prop.
|
||||
|
||||
<Search disabled />
|
||||
|
||||
## Custom search icon
|
||||
## Custom icon
|
||||
|
||||
Replace the default search icon with a custom one.
|
||||
|
||||
<Search icon={Query} />
|
||||
|
||||
## Skeleton
|
||||
|
||||
Display a loading state using the skeleton variant.
|
||||
|
||||
<Search skeleton />
|
||||
|
||||
## Skeleton (large)
|
||||
|
|
|
@ -7,9 +7,11 @@ components: ["Select", "SelectItem", "SelectItemGroup", "SelectSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Select` provides a dropdown menu for selecting a single option from a list. It supports various states, sizes, and includes built-in validation and helper text.
|
||||
|
||||
## Default
|
||||
|
||||
If the `selected` prop is not set, the value of the first `SelectItem` will be used as the default value.
|
||||
Create a basic select menu with `SelectItem` components. The first item's value is used as the default if `selected` is not set.
|
||||
|
||||
<Select labelText="Carbon theme" on:change={e => console.log("value", e.target.value)}>
|
||||
<SelectItem value="white" />
|
||||
|
@ -21,7 +23,7 @@ If the `selected` prop is not set, the value of the first `SelectItem` will be u
|
|||
|
||||
## Custom item text
|
||||
|
||||
Use the `text` prop on `SelectItem` to customize the display value.
|
||||
Use the `text` prop to customize the display text of each option.
|
||||
|
||||
<Select labelText="Carbon theme" on:change={e => console.log("value", e.target.value)}>
|
||||
<SelectItem value="white" text="White" />
|
||||
|
@ -33,7 +35,7 @@ Use the `text` prop on `SelectItem` to customize the display value.
|
|||
|
||||
## Initial selected value
|
||||
|
||||
Use the `selected` prop to specify an initial value.
|
||||
Set the initial selection using the `selected` prop.
|
||||
|
||||
<Select labelText="Carbon theme" selected="g10" on:change={e => console.log("value", e.target.value)}>
|
||||
<SelectItem value="white" text="White" />
|
||||
|
@ -45,12 +47,14 @@ Use the `selected` prop to specify an initial value.
|
|||
|
||||
## Reactive example
|
||||
|
||||
The `selected` prop is reactive and supports two-way binding.
|
||||
The `selected` prop supports two-way binding for reactive updates.
|
||||
|
||||
<FileSource src="/framed/Select/SelectReactive" />
|
||||
|
||||
## Helper text
|
||||
|
||||
Add descriptive text below the select menu.
|
||||
|
||||
<Select helperText="Carbon offers 4 themes (2 light, 3 dark)" labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
|
@ -61,6 +65,8 @@ The `selected` prop is reactive and supports two-way binding.
|
|||
|
||||
## Hidden label
|
||||
|
||||
Visually hide the label while maintaining accessibility.
|
||||
|
||||
<Select hideLabel labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
|
@ -71,6 +77,8 @@ The `selected` prop is reactive and supports two-way binding.
|
|||
|
||||
## Item groups
|
||||
|
||||
Group related options using `SelectItemGroup` components.
|
||||
|
||||
<Select labelText="Carbon theme" selected="0">
|
||||
<SelectItem value="0" text="Select a theme" disabled hidden />
|
||||
<SelectItemGroup label="Light theme">
|
||||
|
@ -84,38 +92,10 @@ The `selected` prop is reactive and supports two-way binding.
|
|||
</SelectItemGroup>
|
||||
</Select>
|
||||
|
||||
## Light variant
|
||||
|
||||
<Select light labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
<SelectItem value="g80" text="Gray 80" />
|
||||
<SelectItem value="g90" text="Gray 90" />
|
||||
<SelectItem value="g100" text="Gray 100" />
|
||||
</Select>
|
||||
|
||||
## Inline variant
|
||||
|
||||
<Select inline labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
<SelectItem value="g80" text="Gray 80" />
|
||||
<SelectItem value="g90" text="Gray 90" />
|
||||
<SelectItem value="g100" text="Gray 100" />
|
||||
</Select>
|
||||
|
||||
## Extra-large size
|
||||
|
||||
<Select size="xl" labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
<SelectItem value="g80" text="Gray 80" />
|
||||
<SelectItem value="g90" text="Gray 90" />
|
||||
<SelectItem value="g100" text="Gray 100" />
|
||||
</Select>
|
||||
|
||||
## Small size
|
||||
|
||||
Use the small size variant for compact layouts.
|
||||
|
||||
<Select size="sm" labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
|
@ -124,8 +104,46 @@ The `selected` prop is reactive and supports two-way binding.
|
|||
<SelectItem value="g100" text="Gray 100" />
|
||||
</Select>
|
||||
|
||||
## Extra-large size
|
||||
|
||||
Use the extra-large size variant for prominent selections.
|
||||
|
||||
<Select size="xl" labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
<SelectItem value="g80" text="Gray 80" />
|
||||
<SelectItem value="g90" text="Gray 90" />
|
||||
<SelectItem value="g100" text="Gray 100" />
|
||||
</Select>
|
||||
|
||||
## Inline variant
|
||||
|
||||
Use the inline variant for horizontal layouts.
|
||||
|
||||
<Select inline labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
<SelectItem value="g80" text="Gray 80" />
|
||||
<SelectItem value="g90" text="Gray 90" />
|
||||
<SelectItem value="g100" text="Gray 100" />
|
||||
</Select>
|
||||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for light backgrounds.
|
||||
|
||||
<Select light labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
<SelectItem value="g80" text="Gray 80" />
|
||||
<SelectItem value="g90" text="Gray 90" />
|
||||
<SelectItem value="g100" text="Gray 100" />
|
||||
</Select>
|
||||
|
||||
## Invalid state
|
||||
|
||||
Show validation errors using the invalid state.
|
||||
|
||||
<Select invalid invalidText="Theme must be a dark variant" labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
|
@ -136,6 +154,8 @@ The `selected` prop is reactive and supports two-way binding.
|
|||
|
||||
## Warning state
|
||||
|
||||
Show warnings using the warning state.
|
||||
|
||||
<Select warn warnText="The selected theme will not be persisted" labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
|
@ -146,6 +166,8 @@ The `selected` prop is reactive and supports two-way binding.
|
|||
|
||||
## Disabled state
|
||||
|
||||
Disable the select menu to prevent interaction.
|
||||
|
||||
<Select disabled labelText="Carbon theme" selected="g10" >
|
||||
<SelectItem value="white" text="White" />
|
||||
<SelectItem value="g10" text="Gray 10" />
|
||||
|
@ -156,6 +178,8 @@ The `selected` prop is reactive and supports two-way binding.
|
|||
|
||||
## Skeleton
|
||||
|
||||
Display a loading state using the skeleton variant.
|
||||
|
||||
<SelectSkeleton />
|
||||
|
||||
## Skeleton (hidden label)
|
||||
|
|
|
@ -7,8 +7,12 @@ components: ["SelectableTile"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`SelectableTile` provides a tile-based selection interface that allows users to select multiple options. It supports various states and includes built-in keyboard navigation and accessibility features.
|
||||
|
||||
## Multi-selectable tiles
|
||||
|
||||
Group multiple selectable tiles together for multi-selection scenarios.
|
||||
|
||||
<div role="group" aria-label="selectable tiles">
|
||||
<SelectableTile selected>
|
||||
Multi-select Tile
|
||||
|
@ -23,6 +27,8 @@ components: ["SelectableTile"]
|
|||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for light backgrounds.
|
||||
|
||||
<div role="group" aria-label="selectable tiles">
|
||||
<SelectableTile light selected>
|
||||
Multi-select Tile
|
||||
|
@ -37,6 +43,8 @@ components: ["SelectableTile"]
|
|||
|
||||
## Disabled state
|
||||
|
||||
Disable tiles to prevent interaction.
|
||||
|
||||
<div role="group" aria-label="selectable tiles">
|
||||
<SelectableTile selected>
|
||||
Multi-select Tile
|
||||
|
|
|
@ -3,10 +3,16 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`SkeletonPlaceholder` provides a loading state placeholder that can be used to indicate content is being loaded. It supports custom sizing and forwards mouse events for interactive loading states.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic skeleton placeholder with default styling.
|
||||
|
||||
<SkeletonPlaceholder />
|
||||
|
||||
## Custom size
|
||||
|
||||
Specify custom dimensions using the `style` prop.
|
||||
|
||||
<SkeletonPlaceholder style="height: 12rem; width: 12rem;" />
|
||||
|
|
|
@ -3,22 +3,34 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`SkeletonText` provides a loading state for text content with support for different sizes and line counts. It's commonly used to indicate that text content is being loaded.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic skeleton text with default styling.
|
||||
|
||||
<SkeletonText />
|
||||
|
||||
## Heading variant
|
||||
|
||||
Use the heading variant for larger text placeholders.
|
||||
|
||||
<SkeletonText heading />
|
||||
|
||||
## Paragraph variant
|
||||
|
||||
Use the paragraph variant for multi-line text placeholders.
|
||||
|
||||
<SkeletonText paragraph />
|
||||
|
||||
## Paragraph with custom line count
|
||||
|
||||
Specify the number of lines to render using the `lines` prop.
|
||||
|
||||
<SkeletonText paragraph lines={8} />
|
||||
|
||||
## Paragraph with max width
|
||||
|
||||
Set a custom width for the text placeholder using the `width` prop.
|
||||
|
||||
<SkeletonText paragraph width="50%" />
|
|
@ -7,8 +7,12 @@ components: ["Slider", "SliderSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Slider` provides a visual way to select a value from a range. It supports keyboard navigation, custom ranges, step values, and various states.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic slider with a label and default range (0-100).
|
||||
|
||||
<Slider labelText="Instances" value={0} />
|
||||
|
||||
## Full width
|
||||
|
@ -19,36 +23,54 @@ Set `fullWidth` to `true` for the slider to span the full width of its containin
|
|||
|
||||
## Hidden label
|
||||
|
||||
Visually hide the label while maintaining accessibility.
|
||||
|
||||
<Slider labelText="Instances" hideLabel value={0} />
|
||||
|
||||
## Hidden text input
|
||||
|
||||
Hide the text input while keeping the slider functionality.
|
||||
|
||||
<Slider labelText="Instances" hideTextInput value={0} />
|
||||
|
||||
## Custom minimum, maximum values
|
||||
|
||||
Set custom range values and labels.
|
||||
|
||||
<Slider labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} />
|
||||
|
||||
## Custom step value
|
||||
|
||||
Specify the step value for more precise control.
|
||||
|
||||
<Slider labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||
|
||||
## Light variant
|
||||
|
||||
<Slider light labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||
Use the light variant for light backgrounds.
|
||||
|
||||
<Slider light labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||
|
||||
## Invalid state
|
||||
|
||||
<Slider invalid labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||
Indicate an invalid state with the `invalid` prop.
|
||||
|
||||
<Slider invalid labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||
|
||||
## Disabled state
|
||||
|
||||
<Slider disabled labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||
Disable the slider to prevent interaction.
|
||||
|
||||
<Slider disabled labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||
|
||||
## Skeleton
|
||||
|
||||
Show a loading state with the skeleton variant.
|
||||
|
||||
<SliderSkeleton />
|
||||
|
||||
## Skeleton (hidden label)
|
||||
|
||||
Show a loading state without a label.
|
||||
|
||||
<SliderSkeleton hideLabel />
|
|
@ -3,12 +3,16 @@ components: ["StructuredList", "StructuredListSkeleton", "StructuredListBody", "
|
|||
---
|
||||
|
||||
<script>
|
||||
import { StructuredList, StructuredListSkeleton, StructuredListBody, StructuredListHead, StructuredListCell ,StructuredListRow, StructuredListInput } from "carbon-components-svelte";
|
||||
import { StructuredList, StructuredListSkeleton, StructuredListBody, StructuredListHead, StructuredListCell, StructuredListRow, StructuredListInput } from "carbon-components-svelte";
|
||||
import CheckmarkFilled from "carbon-icons-svelte/lib/CheckmarkFilled.svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
## Default (read-only)
|
||||
`StructuredList` provides a semantic way to display tabular data with support for selection, keyboard navigation, and various layout options.
|
||||
|
||||
## Default
|
||||
|
||||
Display a basic structured list with headers and rows by default.
|
||||
|
||||
<StructuredList>
|
||||
<StructuredListHead>
|
||||
|
@ -20,40 +24,27 @@ components: ["StructuredList", "StructuredListSkeleton", "StructuredListBody", "
|
|||
</StructuredListHead>
|
||||
<StructuredListBody>
|
||||
<StructuredListRow>
|
||||
<StructuredListCell noWrap>Row 1</StructuredListCell>
|
||||
<StructuredListCell>Row 1</StructuredListCell>
|
||||
<StructuredListCell>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||
vulputate nisl a porttitor interdum.
|
||||
</StructuredListCell>
|
||||
<StructuredListCell>Row 1</StructuredListCell>
|
||||
<StructuredListCell>Row 1</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
<StructuredListRow>
|
||||
<StructuredListCell noWrap>Row 2</StructuredListCell>
|
||||
<StructuredListCell>Row 2</StructuredListCell>
|
||||
<StructuredListCell>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||
vulputate nisl a porttitor interdum.
|
||||
</StructuredListCell>
|
||||
<StructuredListCell>Row 2</StructuredListCell>
|
||||
<StructuredListCell>Row 2</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
<StructuredListRow>
|
||||
<StructuredListCell noWrap>Row 3</StructuredListCell>
|
||||
<StructuredListCell>Row 3</StructuredListCell>
|
||||
<StructuredListCell>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||
vulputate nisl a porttitor interdum.
|
||||
</StructuredListCell>
|
||||
<StructuredListCell>Row 3</StructuredListCell>
|
||||
<StructuredListCell>Row 3</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
</StructuredListBody>
|
||||
</StructuredList>
|
||||
|
||||
## Condensed variant
|
||||
|
||||
Use the condensed variant for more compact rows.
|
||||
|
||||
<StructuredList condensed>
|
||||
<StructuredListHead>
|
||||
<StructuredListRow head>
|
||||
|
@ -64,39 +55,26 @@ components: ["StructuredList", "StructuredListSkeleton", "StructuredListBody", "
|
|||
</StructuredListHead>
|
||||
<StructuredListBody>
|
||||
<StructuredListRow>
|
||||
<StructuredListCell noWrap>Row 1</StructuredListCell>
|
||||
<StructuredListCell>Row 1</StructuredListCell>
|
||||
<StructuredListCell>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||
vulputate nisl a porttitor interdum.
|
||||
</StructuredListCell>
|
||||
<StructuredListCell>Row 1</StructuredListCell>
|
||||
<StructuredListCell>Row 1</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
<StructuredListRow>
|
||||
<StructuredListCell noWrap>Row 2</StructuredListCell>
|
||||
<StructuredListCell>Row 2</StructuredListCell>
|
||||
<StructuredListCell>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||
vulputate nisl a porttitor interdum.
|
||||
</StructuredListCell>
|
||||
<StructuredListCell>Row 2</StructuredListCell>
|
||||
<StructuredListCell>Row 2</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
<StructuredListRow>
|
||||
<StructuredListCell noWrap>Row 3</StructuredListCell>
|
||||
<StructuredListCell>Row 3</StructuredListCell>
|
||||
<StructuredListCell>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||
vulputate nisl a porttitor interdum.
|
||||
</StructuredListCell>
|
||||
<StructuredListCell>Row 3</StructuredListCell>
|
||||
<StructuredListCell>Row 3</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
</StructuredListBody>
|
||||
</StructuredList>
|
||||
|
||||
## Flush
|
||||
## Flush variant
|
||||
|
||||
Use the flush variant to remove padding from the list.
|
||||
|
||||
<StructuredList flush>
|
||||
<StructuredListHead>
|
||||
|
@ -142,6 +120,8 @@ components: ["StructuredList", "StructuredListSkeleton", "StructuredListBody", "
|
|||
|
||||
## Selectable rows
|
||||
|
||||
Enable row selection with the `selection` prop and `StructuredListInput` components.
|
||||
|
||||
<StructuredList selection selected="row-1-value">
|
||||
<StructuredListHead>
|
||||
<StructuredListRow head>
|
||||
|
@ -182,4 +162,6 @@ components: ["StructuredList", "StructuredListSkeleton", "StructuredListBody", "
|
|||
|
||||
## Skeleton
|
||||
|
||||
Show a loading state with the skeleton variant.
|
||||
|
||||
<StructuredListSkeleton rows={3} />
|
|
@ -7,8 +7,12 @@ components: ["Tabs", "Tab", "TabContent", "TabsSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Tabs` provides a way to organize content into separate views that can be switched between. It supports keyboard navigation, disabled states, and various layout options.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic tab interface with labels and content.
|
||||
|
||||
<Tabs>
|
||||
<Tab label="Tab label 1" />
|
||||
<Tab label="Tab label 2" />
|
||||
|
@ -22,9 +26,7 @@ components: ["Tabs", "Tab", "TabContent", "TabsSkeleton"]
|
|||
|
||||
## Auto width
|
||||
|
||||
By default, the width of each tab is set to `10rem`.
|
||||
|
||||
Set `autoWidth` to `true` for tabs to have an automatically set width.
|
||||
By default, each tab has a fixed width of `10rem`. Set `autoWidth` to `true` for tabs to automatically adjust their width based on content.
|
||||
|
||||
<Tabs autoWidth>
|
||||
<Tab label="Tab label 1" />
|
||||
|
@ -39,13 +41,13 @@ Set `autoWidth` to `true` for tabs to have an automatically set width.
|
|||
|
||||
## Reactive example
|
||||
|
||||
Use `bind:selected` to create a two-way binding with the selected tab index. This allows you to programmatically control the selected tab and react to tab changes.
|
||||
|
||||
<FileSource src="/framed/Tabs/TabsReactive" />
|
||||
|
||||
## Disabled tabs
|
||||
|
||||
Setting `disabled` to `true` on the `Tab` component will prevent it from being clickable.
|
||||
|
||||
Using keyboard navigation (left and right arrow keys) will skip to the next non-disabled tab.
|
||||
Set `disabled` to `true` on a `Tab` component to prevent interaction. Keyboard navigation will skip disabled tabs.
|
||||
|
||||
<Tabs>
|
||||
<Tab label="Tab label 1" />
|
||||
|
@ -62,6 +64,8 @@ Using keyboard navigation (left and right arrow keys) will skip to the next non-
|
|||
|
||||
## Container type
|
||||
|
||||
Use the container type for a more prominent tab interface.
|
||||
|
||||
<Tabs type="container">
|
||||
<Tab label="Tab label 1" />
|
||||
<Tab label="Tab label 2" />
|
||||
|
@ -75,8 +79,12 @@ Using keyboard navigation (left and right arrow keys) will skip to the next non-
|
|||
|
||||
## Skeleton (default)
|
||||
|
||||
Show a loading state with the default skeleton variant.
|
||||
|
||||
<TabsSkeleton count={3} />
|
||||
|
||||
## Skeleton (container)
|
||||
|
||||
Show a loading state with the container skeleton variant.
|
||||
|
||||
<TabsSkeleton type="container" count={3} />
|
|
@ -1,19 +1,31 @@
|
|||
---
|
||||
components: ["Tag", "TagSkeleton"]
|
||||
---
|
||||
|
||||
<script>
|
||||
import { Tag, TooltipDefinition } from "carbon-components-svelte";
|
||||
import IbmCloud from "carbon-icons-svelte/lib/IbmCloud.svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Tag` provides a way to categorize content with a keyword or label. It supports various styles, sizes, and interactive states, including filterable and interactive variants.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic tag with text content.
|
||||
|
||||
<Tag>IBM Cloud</Tag>
|
||||
|
||||
## Small size
|
||||
|
||||
Use the small size variant for more compact layouts.
|
||||
|
||||
<Tag size="sm">IBM Cloud</Tag>
|
||||
|
||||
## Tag types
|
||||
|
||||
Choose from a variety of color types to match your design system.
|
||||
|
||||
<Tag type="red">red</Tag>
|
||||
<Tag type="magenta">magenta</Tag>
|
||||
<Tag type="purple">purple</Tag>
|
||||
|
@ -29,37 +41,45 @@
|
|||
|
||||
## Filterable
|
||||
|
||||
Create a filterable tag with a close button that dispatches a `close` event when clicked.
|
||||
|
||||
<Tag filter on:close>carbon-components</Tag>
|
||||
|
||||
## Filterable (disabled)
|
||||
|
||||
Disable a filterable tag to prevent interaction.
|
||||
|
||||
<Tag filter disabled on:close>carbon-components</Tag>
|
||||
|
||||
## Filterable (small)
|
||||
|
||||
Combine the filterable variant with the small size.
|
||||
|
||||
<Tag size="sm" filter on:close>carbon-components</Tag>
|
||||
|
||||
## Custom icon
|
||||
|
||||
Note: rendering a custom icon cannot be used with the filterable variant.
|
||||
Add a custom icon to the tag. Note: custom icons cannot be used with the filterable variant.
|
||||
|
||||
<Tag icon={IbmCloud}>IBM Cloud</Tag>
|
||||
|
||||
## Interactive variant
|
||||
|
||||
Set `interactive` to `true` to render a `button` element instead of a `div`.
|
||||
Set `interactive` to `true` to render a `button` element instead of a `div`. This is useful for clickable tags.
|
||||
|
||||
<Tag interactive>Machine learning</Tag>
|
||||
|
||||
## Disabled
|
||||
|
||||
The filterable and interactive tag variants have a disabled state.
|
||||
Both filterable and interactive tag variants support a disabled state.
|
||||
|
||||
<Tag filter disabled>Machine learning</Tag>
|
||||
<Tag interactive disabled>Machine learning</Tag>
|
||||
|
||||
## Tooltip in a tag
|
||||
|
||||
Embed a tooltip within a tag to provide additional context.
|
||||
|
||||
<Tag>
|
||||
<TooltipDefinition tooltipText="IBM Corporate Headquarters is based in Armonk, New York.">
|
||||
Armonk
|
||||
|
@ -68,8 +88,12 @@ The filterable and interactive tag variants have a disabled state.
|
|||
|
||||
## Skeleton
|
||||
|
||||
Show a loading state with the default skeleton variant.
|
||||
|
||||
<Tag skeleton />
|
||||
|
||||
## Skeleton (small)
|
||||
|
||||
Show a loading state with the small skeleton variant.
|
||||
|
||||
<Tag size="sm" skeleton />
|
|
@ -7,46 +7,64 @@ components: ["TextArea", "TextAreaSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`TextArea` provides a multi-line text input field with support for various states, character counting, and accessibility features. It's ideal for longer text input like descriptions, comments, or messages.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic textarea with a label and placeholder text.
|
||||
|
||||
<TextArea labelText="App description" placeholder="Enter a description..." />
|
||||
|
||||
## Maximum character count
|
||||
|
||||
Specify the max character count using the `maxCount` prop. A character counter will be displayed to the right of the label.
|
||||
|
||||
You can always use the native `maxlength` attribute if you'd prefer that a counter not be shown.
|
||||
Specify the max character count using the `maxCount` prop. A character counter will be displayed to the right of the label. You can also use the native `maxlength` attribute if you prefer not to show a counter.
|
||||
|
||||
<TextArea labelText="App description" placeholder="Enter a description..." maxCount={100} />
|
||||
|
||||
## With helper text
|
||||
|
||||
Add helper text below the textarea to provide additional context or instructions.
|
||||
|
||||
<TextArea labelText="App description" helperText="A rich description helps us better recommend related products and services" placeholder="Enter a description..." />
|
||||
|
||||
## Hidden label
|
||||
|
||||
Visually hide the label while maintaining accessibility by setting `hideLabel` to `true`.
|
||||
|
||||
<TextArea hideLabel labelText="App description" placeholder="Enter a description..." />
|
||||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for light-themed backgrounds by setting `light` to `true`.
|
||||
|
||||
<TextArea light labelText="App description" placeholder="Enter a description..." />
|
||||
|
||||
## Custom rows
|
||||
|
||||
Adjust the number of visible rows using the `rows` prop. The default is 4 rows.
|
||||
|
||||
<TextArea rows={10} labelText="App description" placeholder="Enter a description..." />
|
||||
|
||||
## Invalid state
|
||||
|
||||
Indicate an invalid state with an error message by setting `invalid` to `true` and providing `invalidText`.
|
||||
|
||||
<TextArea invalid invalidText="Only plain text characters are allowed" labelText="App description" placeholder="Enter a description..." />
|
||||
|
||||
## Disabled state
|
||||
|
||||
Disable the textarea to prevent user interaction by setting `disabled` to `true`.
|
||||
|
||||
<TextArea disabled labelText="App description" placeholder="Enter a description..." />
|
||||
|
||||
## Skeleton
|
||||
|
||||
Show a loading state with the default skeleton variant.
|
||||
|
||||
<TextAreaSkeleton />
|
||||
|
||||
## Skeleton without label
|
||||
|
||||
Show a loading state without a label by setting `hideLabel` to `true`.
|
||||
|
||||
<TextAreaSkeleton hideLabel />
|
|
@ -7,54 +7,82 @@ components: ["TextInput", "TextInputSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`TextInput` provides a single-line text input field with support for various states, sizes, and accessibility features. It's ideal for short text input like usernames, search terms, or form fields.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic text input with a label and placeholder text.
|
||||
|
||||
<TextInput labelText="User name" placeholder="Enter user name..." />
|
||||
|
||||
## With helper text
|
||||
|
||||
Add helper text below the input to provide additional context or instructions.
|
||||
|
||||
<TextInput labelText="User name" helperText="Your user name is associated with your email" placeholder="Enter user name..." />
|
||||
|
||||
## Hidden label
|
||||
|
||||
Visually hide the label while maintaining accessibility by setting `hideLabel` to `true`.
|
||||
|
||||
<TextInput hideLabel labelText="User name" placeholder="Enter user name..." />
|
||||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for light-themed backgrounds by setting `light` to `true`.
|
||||
|
||||
<TextInput light labelText="User name" placeholder="Enter user name..." />
|
||||
|
||||
## Inline variant
|
||||
|
||||
Use the inline variant to display the label and input on the same line by setting `inline` to `true`.
|
||||
|
||||
<TextInput inline labelText="User name" placeholder="Enter user name..." />
|
||||
|
||||
## Read-only variant
|
||||
|
||||
Display a non-editable value by setting `readonly` to `true`.
|
||||
|
||||
<TextInput readonly labelText="User name" value="IBM" />
|
||||
|
||||
## Extra-large size
|
||||
|
||||
Use the extra-large size for more prominent inputs by setting `size` to `"xl"`.
|
||||
|
||||
<TextInput size="xl" labelText="User name" placeholder="Enter user name..." />
|
||||
|
||||
## Small size
|
||||
|
||||
Use the small size for more compact inputs by setting `size` to `"sm"`.
|
||||
|
||||
<TextInput size="sm" labelText="User name" placeholder="Enter user name..." />
|
||||
|
||||
## Invalid state
|
||||
|
||||
Indicate an invalid state with an error message by setting `invalid` to `true` and providing `invalidText`.
|
||||
|
||||
<TextInput invalid invalidText="User name is already taken. Please try another." labelText="User name" placeholder="Enter user name..." />
|
||||
|
||||
## Warning state
|
||||
|
||||
Indicate a warning state with a message by setting `warn` to `true` and providing `warnText`.
|
||||
|
||||
<TextInput warn warnText="Your user name is different from your log in ID." labelText="User name" placeholder="Enter user name..." />
|
||||
|
||||
## Disabled state
|
||||
|
||||
Disable the input to prevent user interaction by setting `disabled` to `true`.
|
||||
|
||||
<TextInput disabled labelText="User name" placeholder="Enter user name..." />
|
||||
|
||||
## Skeleton
|
||||
|
||||
Show a loading state with the default skeleton variant.
|
||||
|
||||
<TextInputSkeleton />
|
||||
|
||||
## Skeleton without label
|
||||
|
||||
Show a loading state without a label by setting `hideLabel` to `true`.
|
||||
|
||||
<TextInputSkeleton hideLabel />
|
|
@ -1,3 +1,7 @@
|
|||
---
|
||||
components: ["Theme"]
|
||||
---
|
||||
|
||||
<script>
|
||||
import { InlineNotification, CodeSnippet } from "carbon-components-svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
|
@ -5,7 +9,7 @@
|
|||
let code = `import "carbon-components-svelte/css/all.css";`;
|
||||
</script>
|
||||
|
||||
The `Theme` component can dyanmically update the Carbon theme on the client-side. It can persist the theme locally using [window.localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
|
||||
The `Theme` component provides dynamic client-side theming using CSS variables. It supports five Carbon themes: white, g10, g80, g90, and g100, and allows for custom theme token overrides. The component can persist theme preferences using [window.localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) and provides built-in toggle and select controls for theme switching.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">You must use the "all.css" StyleSheet with the <code>Theme</code> component.</div>
|
||||
|
@ -17,40 +21,42 @@ The `all.css` StyleSheet uses [CSS variables](https://developer.mozilla.org/en-U
|
|||
|
||||
## Default
|
||||
|
||||
Create a basic theme component that can be controlled programmatically.
|
||||
|
||||
<FileSource src="/framed/Theme/Theme" />
|
||||
|
||||
## Persist locally
|
||||
|
||||
Set `persist` to `true` to persist the theme locally using the [Window.localStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
|
||||
Set `persist` to `true` to save the theme preference in [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). Use `persistKey` to specify a custom storage key.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemePersist" />
|
||||
|
||||
## Custom theme
|
||||
|
||||
Define keys and values in the `tokens` prop that override default Carbon theme tokens. Refer to the [Carbon website](https://carbondesignsystem.com/guidelines/themes/overview#customizing-a-theme) for guidance on customizing a theme using token values.
|
||||
Override default Carbon theme tokens by providing custom key-value pairs in the `tokens` prop. Refer to the [Carbon website](https://carbondesignsystem.com/guidelines/themes/overview#customizing-a-theme) for guidance on customizing themes.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemeTokens" />
|
||||
|
||||
## Theme toggle
|
||||
|
||||
Set `render` to `"toggle"` to render a toggle switch to control the theme.
|
||||
Set `render` to `"toggle"` to display a toggle switch for switching between two themes. By default, it toggles between "white" and "g100" themes.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemeToggle" />
|
||||
|
||||
## Theme toggle (custom)
|
||||
|
||||
Customize the toggle using the `toggle` prop.
|
||||
Customize the toggle appearance and behavior using the `toggle` prop. You can specify custom themes, labels, and other toggle properties.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemeToggleCustom" />
|
||||
|
||||
## Theme select
|
||||
|
||||
Set `render` to `"select"` to render a select dropdown to control the theme.
|
||||
Set `render` to `"select"` to display a dropdown menu for selecting from all available themes.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemeSelect" />
|
||||
|
||||
## Theme select (custom)
|
||||
|
||||
Customize the select using the `select` prop.
|
||||
Customize the select dropdown using the `select` prop. You can specify which themes to include, customize labels, and adjust other select properties.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemeSelectCustom" />
|
|
@ -3,10 +3,16 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Tile` provides a container for displaying content in a structured, card-like format. It supports light and dark variants and can be used to create consistent, visually distinct content sections.
|
||||
|
||||
## Default
|
||||
|
||||
Create a basic tile container for your content.
|
||||
|
||||
<Tile>Content</Tile>
|
||||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for light-themed backgrounds by setting `light` to `true`.
|
||||
|
||||
<Tile light>Content</Tile>
|
|
@ -7,6 +7,8 @@ components: ["TimePicker", "TimePickerSelect", "SelectItem"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`TimePicker` provides a time input field with optional period (AM/PM) and timezone selectors. It supports various sizes, states, and themes to match your application's design system.
|
||||
|
||||
## Default
|
||||
|
||||
<TimePicker labelText="Cron job" placeholder="hh:mm">
|
||||
|
@ -22,6 +24,8 @@ components: ["TimePicker", "TimePickerSelect", "SelectItem"]
|
|||
|
||||
## Light variant
|
||||
|
||||
Use the light variant for light-themed backgrounds by setting `light` to `true`.
|
||||
|
||||
<TimePicker light labelText="Cron job" placeholder="hh:mm">
|
||||
<TimePickerSelect value="pm">
|
||||
<SelectItem value="am" text="AM" />
|
||||
|
@ -35,6 +39,8 @@ components: ["TimePicker", "TimePickerSelect", "SelectItem"]
|
|||
|
||||
## Extra-large size
|
||||
|
||||
Use the extra-large size for more prominent time pickers by setting `size` to `"xl"`.
|
||||
|
||||
<TimePicker size="xl" labelText="Cron job" placeholder="hh:mm">
|
||||
<TimePickerSelect value="pm">
|
||||
<SelectItem value="am" text="AM" />
|
||||
|
@ -48,6 +54,8 @@ components: ["TimePicker", "TimePickerSelect", "SelectItem"]
|
|||
|
||||
## Small size
|
||||
|
||||
Use the small size for more compact time pickers by setting `size` to `"sm"`.
|
||||
|
||||
<TimePicker size="sm" labelText="Cron job" placeholder="hh:mm">
|
||||
<TimePickerSelect value="pm">
|
||||
<SelectItem value="am" text="AM" />
|
||||
|
@ -61,6 +69,8 @@ components: ["TimePicker", "TimePickerSelect", "SelectItem"]
|
|||
|
||||
## Invalid state
|
||||
|
||||
Indicate an invalid state with an error message by setting `invalid` to `true` and providing `invalidText`.
|
||||
|
||||
<TimePicker invalid invalidText="A valid value is required" labelText="Cron job" placeholder="hh:mm">
|
||||
<TimePickerSelect value="pm">
|
||||
<SelectItem value="am" text="AM" />
|
||||
|
@ -72,9 +82,10 @@ components: ["TimePicker", "TimePickerSelect", "SelectItem"]
|
|||
</TimePickerSelect>
|
||||
</TimePicker>
|
||||
|
||||
|
||||
## Disabled state
|
||||
|
||||
Disable the time picker to prevent user interaction by setting `disabled` to `true`.
|
||||
|
||||
<TimePicker labelText="Cron job" placeholder="hh:mm" disabled>
|
||||
<TimePickerSelect value="pm" disabled>
|
||||
<SelectItem value="am" text="AM" />
|
||||
|
|
|
@ -1,30 +1,32 @@
|
|||
---
|
||||
components: ["ToastNotification"]
|
||||
---
|
||||
|
||||
<script>
|
||||
import { ToastNotification } from "carbon-components-svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
Toasts are non-modal, time-based window elements used to display short messages;
|
||||
they usually appear at the top of the screen and disappear after a few seconds.
|
||||
`ToastNotification` displays non-modal, time-based messages that appear at the top of the screen and automatically disappear. It supports various notification types, custom content, and accessibility features.
|
||||
|
||||
See [detailed
|
||||
usage](https://carbondesignsystem.com/components/notification/usage).
|
||||
See [detailed usage](https://carbondesignsystem.com/components/notification/usage).
|
||||
See also: [InlineNotification](InlineNotification)
|
||||
|
||||
## Default (error)
|
||||
## Default
|
||||
|
||||
Display a basic error notification with title, subtitle, and timestamp by default.
|
||||
|
||||
<ToastNotification title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
||||
|
||||
## Autoclose
|
||||
|
||||
By default, `ToastNotification` does not automatically close.
|
||||
|
||||
Specify the `timeout` prop to automatically close the notification after a specified duration (in milliseconds).
|
||||
|
||||
<FileSource src="/framed/ToastNotification/ToastNotificationTimeout" />
|
||||
|
||||
## Prevent default close behavior
|
||||
|
||||
`ToastNotification` is a controlled component. Prevent the default close behavior using the `e.preventDefault()` method in the dispatched `on:close` event.
|
||||
Prevent the default close behavior using `e.preventDefault()` in the `on:close` event handler.
|
||||
|
||||
<ToastNotification title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" on:close={(e) => {
|
||||
e.preventDefault();
|
||||
|
@ -33,12 +35,14 @@ Specify the `timeout` prop to automatically close the notification after a speci
|
|||
|
||||
## Full width
|
||||
|
||||
Set `fullWidth` to `true` for the notification to span the full width of its containing element.
|
||||
Set `fullWidth` to `true` for the notification to span the full width of its container.
|
||||
|
||||
<ToastNotification fullWidth title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
||||
|
||||
## Slottable title, subtitle, caption
|
||||
|
||||
Customize the notification content using slots for more flexibility.
|
||||
|
||||
<ToastNotification>
|
||||
<strong slot="title">Error: </strong>
|
||||
<strong slot="subtitle">An internal server error occurred.</strong>
|
||||
|
@ -47,9 +51,7 @@ Set `fullWidth` to `true` for the notification to span the full width of its con
|
|||
|
||||
## Accessible icon descriptions
|
||||
|
||||
The status icon and close button icon descriptions appear on cursor hover and are read
|
||||
by assistive technology. Default descriptions are provided in English and can be
|
||||
overridden via `statusIconDescription` and `closeButtonDescription`.
|
||||
Provide custom descriptions for icons to improve accessibility.
|
||||
|
||||
<ToastNotification
|
||||
title="错误"
|
||||
|
@ -60,10 +62,14 @@ overridden via `statusIconDescription` and `closeButtonDescription`.
|
|||
|
||||
## Hidden close button
|
||||
|
||||
Create a persistent notification by hiding the close button.
|
||||
|
||||
<ToastNotification hideCloseButton kind="warning" title="Scheduled maintenance" subtitle="Maintenance will last 2-4 hours." caption="{new Date().toLocaleString()}" />
|
||||
|
||||
## Notification variants
|
||||
|
||||
The component supports different notification types:
|
||||
|
||||
<ToastNotification kind="error" title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
||||
<ToastNotification kind="info" title="New updates" subtitle="Restart to get the latest updates." caption="{new Date().toLocaleString()}" />
|
||||
<ToastNotification kind="info-square" title="New updates" subtitle="Restart to get the latest updates." caption="{new Date().toLocaleString()}" />
|
||||
|
@ -73,6 +79,8 @@ overridden via `statusIconDescription` and `closeButtonDescription`.
|
|||
|
||||
## Low contrast
|
||||
|
||||
Use low contrast variants for less prominent notifications.
|
||||
|
||||
<ToastNotification lowContrast kind="error" title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
||||
<ToastNotification lowContrast kind="info" title="New updates" subtitle="Restart to get the latest updates." caption="{new Date().toLocaleString()}" />
|
||||
<ToastNotification lowContrast kind="info-square" title="New updates" subtitle="Restart to get the latest updates." caption="{new Date().toLocaleString()}" />
|
||||
|
|
|
@ -7,53 +7,73 @@ components: ["Toggle", "ToggleSkeleton"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
## Default (untoggled)
|
||||
`Toggle` provides a switch-like control that allows users to turn options on or off. It supports custom labels, different sizes, and various states to match your application's needs.
|
||||
|
||||
## Default
|
||||
|
||||
Display a basic toggle in its untoggled state by default.
|
||||
|
||||
<Toggle labelText="Push notifications" />
|
||||
|
||||
## Toggled
|
||||
|
||||
Set `toggled` to `true` to display the toggle in its on state.
|
||||
|
||||
<Toggle labelText="Push notifications" toggled />
|
||||
|
||||
## Reactive example
|
||||
|
||||
Use two-way binding to control the toggle state programmatically.
|
||||
|
||||
<FileSource src="/framed/Toggle/ToggleReactive" />
|
||||
|
||||
## on:toggle event
|
||||
|
||||
Listen for toggle state changes using the `on:toggle` event.
|
||||
|
||||
<Toggle labelText="Push notifications" on:toggle={e => console.log(e.detail)} />
|
||||
|
||||
## Hidden label text
|
||||
|
||||
Set `hideLabel` to `true` to visually hide the label text. It's recommended to still specify `labelText` for screen reader accessibility.
|
||||
Set `hideLabel` to `true` to visually hide the label while maintaining accessibility.
|
||||
|
||||
<Toggle labelText="Push notifications" hideLabel />
|
||||
|
||||
## Custom labels
|
||||
|
||||
Customize the toggle labels using `labelA` and `labelB` props.
|
||||
|
||||
<Toggle labelText="Push notifications" labelA="No" labelB="Yes" />
|
||||
|
||||
## Slottable labels
|
||||
|
||||
An alternative to the "labelA" and "labelB" props is to use the corresponding named slots.
|
||||
Use slots to customize the toggle labels with additional styling or content.
|
||||
|
||||
<Toggle labelText="Push notifications">
|
||||
<span slot="labelA" style="color: red">No</span>
|
||||
<span slot="labelB" style="color: green">Yes</span>
|
||||
</Toggle>
|
||||
|
||||
## Disabled
|
||||
## Disabled state
|
||||
|
||||
Set `disabled` to `true` to prevent user interaction.
|
||||
|
||||
<Toggle labelText="Push notifications" disabled />
|
||||
|
||||
## Small size
|
||||
|
||||
Use the small size variant by setting `size` to `"sm"`.
|
||||
|
||||
<Toggle size="sm" labelText="Push notifications" />
|
||||
|
||||
## Skeleton
|
||||
|
||||
Display a loading state using the skeleton component.
|
||||
|
||||
<ToggleSkeleton />
|
||||
|
||||
## Skeleton (small)
|
||||
|
||||
Use the small size variant for the skeleton component.
|
||||
|
||||
<ToggleSkeleton size="sm" />
|
|
@ -8,9 +8,11 @@ components: ["Tooltip", "TooltipFooter"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`Tooltip` displays contextual information when users hover over or focus on an element. It supports various directions, alignments, and interactive content to provide additional context or guidance.
|
||||
|
||||
## Default
|
||||
|
||||
By default, the tooltip is triggered by an information icon.
|
||||
Display a tooltip triggered by the default information icon.
|
||||
|
||||
<Tooltip>
|
||||
<p>
|
||||
|
@ -20,6 +22,8 @@ By default, the tooltip is triggered by an information icon.
|
|||
|
||||
## With trigger text
|
||||
|
||||
Use custom trigger text instead of the default icon.
|
||||
|
||||
<Tooltip triggerText="Resource list">
|
||||
<p>
|
||||
Resources are provisioned based on your account's organization.
|
||||
|
@ -28,10 +32,14 @@ By default, the tooltip is triggered by an information icon.
|
|||
|
||||
## Reactive example
|
||||
|
||||
Control the tooltip state programmatically.
|
||||
|
||||
<FileSource src="/framed/Tooltip/TooltipReactive" />
|
||||
|
||||
## Directions
|
||||
|
||||
Position the tooltip in different directions using the `direction` prop.
|
||||
|
||||
<Tooltip triggerText="Top" direction="top"><p>Top</p></Tooltip>
|
||||
<Tooltip triggerText="Right" direction="right"><p>Right</p></Tooltip>
|
||||
<Tooltip triggerText="Bottom" direction="bottom"><p>Bottom</p></Tooltip>
|
||||
|
@ -39,12 +47,16 @@ By default, the tooltip is triggered by an information icon.
|
|||
|
||||
## Alignment
|
||||
|
||||
Align the tooltip content using the `align` prop.
|
||||
|
||||
<Tooltip triggerText="Start" align="start"><p>Start</p></Tooltip>
|
||||
<Tooltip triggerText="End" align="end"><p>End</p></Tooltip>
|
||||
<Tooltip triggerText="Center" align="center"><p>Center</p></Tooltip>
|
||||
|
||||
## Interactive
|
||||
|
||||
Add interactive elements like links and buttons using `TooltipFooter`.
|
||||
|
||||
<Tooltip triggerText="Resource list">
|
||||
<p>
|
||||
Resources are provisioned based on your account's organization.
|
||||
|
@ -52,11 +64,13 @@ By default, the tooltip is triggered by an information icon.
|
|||
<TooltipFooter selectorPrimaryFocus="#d">
|
||||
<Link href="/">Learn more</Link>
|
||||
<Button id="d" size="small">Manage</Button>
|
||||
</TooltipFooter>
|
||||
</TooltipFooter>
|
||||
</Tooltip>
|
||||
|
||||
## Custom icon (component)
|
||||
|
||||
Use a custom icon component with the `icon` prop.
|
||||
|
||||
<Tooltip triggerText="Resource list" icon={Catalog}>
|
||||
<p>
|
||||
Resources are provisioned based on your account's organization.
|
||||
|
@ -65,6 +79,8 @@ By default, the tooltip is triggered by an information icon.
|
|||
|
||||
## Custom icon (slot)
|
||||
|
||||
Customize the icon using the `icon` slot for more flexibility.
|
||||
|
||||
<Tooltip triggerText="Resource list">
|
||||
<div slot="icon" style="width: 1rem; height: 1rem; outline: 1px solid red;"></div>
|
||||
<p>
|
||||
|
@ -74,6 +90,8 @@ By default, the tooltip is triggered by an information icon.
|
|||
|
||||
## Hidden icon
|
||||
|
||||
Hide the icon while keeping the tooltip functionality using `hideIcon`.
|
||||
|
||||
<Tooltip hideIcon triggerText="Resource list">
|
||||
<p>
|
||||
Resources are provisioned based on your account's organization.
|
||||
|
|
|
@ -3,17 +3,19 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`TooltipDefinition` provides inline definitions for terms or concepts. It displays a tooltip when users hover over or focus on the defined term, making it ideal for providing additional context without cluttering the interface.
|
||||
|
||||
## Default
|
||||
|
||||
Display a basic definition tooltip with the default bottom-center alignment.
|
||||
|
||||
<TooltipDefinition tooltipText="IBM Corporate Headquarters is based in Armonk, New York.">
|
||||
Armonk
|
||||
</TooltipDefinition>
|
||||
|
||||
## Custom tooltip direction and alignment
|
||||
|
||||
Customize the tooltip menu direction and alignment through the `direction` and `align` props.
|
||||
|
||||
By default, `direction` is `"bottom"` and `align` is `"center"`.
|
||||
Customize the tooltip position using the `direction` and `align` props. The default direction is `"bottom"` and alignment is `"center"`.
|
||||
|
||||
<TooltipDefinition direction="top" align="start" tooltipText="IBM Corporate Headquarters is based in Armonk, New York.">
|
||||
Armonk
|
||||
|
@ -21,6 +23,8 @@ By default, `direction` is `"bottom"` and `align` is `"center"`.
|
|||
|
||||
## Custom tooltip slot
|
||||
|
||||
Use the `tooltip` slot to customize the tooltip content with additional styling or structure.
|
||||
|
||||
<TooltipDefinition>
|
||||
Armonk
|
||||
<span slot="tooltip" style="color: red">
|
||||
|
|
|
@ -5,12 +5,18 @@
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
## Default ("bottom" direction, "center" aligned)
|
||||
`TooltipIcon` displays contextual information when users hover over or focus on an icon. It's ideal for providing additional context about icons or actions in your interface.
|
||||
|
||||
## Default
|
||||
|
||||
Display a tooltip with the default bottom-center alignment.
|
||||
|
||||
<TooltipIcon tooltipText="Carbon is an open source design system by IBM." icon={Carbon} />
|
||||
|
||||
## Directions
|
||||
|
||||
Position the tooltip in different directions and alignments using the `direction` and `align` props.
|
||||
|
||||
<TooltipIcon tooltipText="Top start" direction="top" align="start" icon={Filter} />
|
||||
<TooltipIcon tooltipText="Right end" direction="right" align="end" icon={Filter} />
|
||||
<TooltipIcon tooltipText="Bottom start" direction="bottom" align="start" icon={Filter} />
|
||||
|
@ -18,12 +24,14 @@
|
|||
|
||||
## Custom tooltip text
|
||||
|
||||
Use the "text" slot to customize the tooltip text.
|
||||
Use the `tooltipText` slot to customize the tooltip content with additional styling.
|
||||
|
||||
<TooltipIcon icon={Carbon}>
|
||||
<span slot="tooltipText" style="color: red">Carbon is an open source design system by IBM.</span>
|
||||
</TooltipIcon>
|
||||
|
||||
## Disabled
|
||||
## Disabled state
|
||||
|
||||
Set `disabled` to `true` to prevent user interaction with the tooltip.
|
||||
|
||||
<TooltipIcon disabled tooltipText="Carbon is an open source design system by IBM." icon={Carbon} />
|
|
@ -1,15 +1,13 @@
|
|||
<script>
|
||||
import { InlineNotification, UnorderedList, ListItem, Link, } from "carbon-components-svelte";
|
||||
import { InlineNotification, UnorderedList, ListItem, Link } from "carbon-components-svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`TreeView` displays hierarchical data in a collapsible tree structure. It supports node selection, expansion, icons, and programmatic control of the tree state.
|
||||
|
||||
## Default
|
||||
|
||||
The `nodes` prop accepts an array of child nodes. Each node should contain `id` and `text` properties.
|
||||
|
||||
Optional properties include `disabled`, `icon`, and `nodes`.
|
||||
|
||||
A parent node contains `nodes` while a leaf node does not.
|
||||
Create a basic tree view using the `nodes` prop. Each node requires an `id` and `text`, with optional properties for `disabled`, `icon`, and child `nodes`.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">
|
||||
|
@ -25,9 +23,7 @@ A parent node contains `nodes` while a leaf node does not.
|
|||
|
||||
## Slottable node
|
||||
|
||||
By default, each item renders the value of `node.text`. Use the data from `let:node` directive to override the default slot.
|
||||
|
||||
The destructured `let:node` contains the following properties:
|
||||
Customize node rendering using the default slot with the `let:node` directive. The node object provides:
|
||||
|
||||
<UnorderedList svx-ignore style="margin-bottom: var(--cds-spacing-08)">
|
||||
<ListItem><strong>id</strong>: the node id</ListItem>
|
||||
|
@ -42,68 +38,66 @@ The destructured `let:node` contains the following properties:
|
|||
|
||||
## Initial active node
|
||||
|
||||
The active node can be set through `activeId`.
|
||||
Set the initial active node using the `activeId` prop.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewActive" />
|
||||
|
||||
## Compact size
|
||||
|
||||
Set `size` to `"compact"` to use the compact variant.
|
||||
Use the compact variant by setting `size` to `"compact"`.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewCompact" />
|
||||
|
||||
## With icons
|
||||
|
||||
To render a node with an icon, define an `icon` property with a Carbon Svelte icon as its value.
|
||||
Add icons to nodes by defining an `icon` property with a Carbon Svelte icon component.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewIcons" />
|
||||
|
||||
## Initial expanded nodes
|
||||
|
||||
Expanded nodes can be set using `expandedIds`.
|
||||
Set initially expanded nodes using the `expandedIds` prop.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewExpanded" />
|
||||
|
||||
## Initial multiple selected nodes
|
||||
|
||||
Initial multiple selected nodes can be set using `selectedIds`.
|
||||
Set multiple initially selected nodes using the `selectedIds` prop.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewMultiselect" />
|
||||
|
||||
## Expand all nodes
|
||||
|
||||
To programmatically expand all nodes, access the component instance using the [bind:this](https://svelte.dev/docs#bind_element) directive and invoke the `TreeView.expandAll()` accessor.
|
||||
Programmatically expand all nodes using the `TreeView.expandAll()` method.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewExpandAll" />
|
||||
|
||||
## Collapse all nodes
|
||||
|
||||
Similarly, invoke `TreeView.collapseAll()` to collapse all nodes.
|
||||
Programmatically collapse all nodes using the `TreeView.collapseAll()` method.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewCollapseAll" />
|
||||
|
||||
## Expand a subset of nodes
|
||||
|
||||
Use the `TreeView.expandNodes` method to expand only a subset of nodes.
|
||||
|
||||
The method accepts an argument that takes a node and returns a boolean.
|
||||
|
||||
If no argument is provided, all nodes will be expanded.
|
||||
Use `TreeView.expandNodes` to expand specific nodes based on a condition.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewExpandNodes" />
|
||||
|
||||
## Collapse a subset of nodes
|
||||
|
||||
Use the `TreeView.collapseNodes` method to collapse a subset of nodes.
|
||||
|
||||
If no argument is provided, all nodes will be collapsed.
|
||||
Use `TreeView.collapseNodes` to collapse specific nodes based on a condition.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewCollapseNodes" />
|
||||
|
||||
## Show a specific node
|
||||
|
||||
Use the `TreeView.showNode` method to show a specific node.
|
||||
|
||||
If a matching node is found, it will be expanded, selected, and focused.
|
||||
Use `TreeView.showNode` to expand, select, and focus a specific node.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewShowNode" />
|
||||
|
||||
## Flat data structure
|
||||
|
||||
Convert flat data to a hierarchical structure using the `toHierarchy` utility.
|
||||
|
||||
<FileSource src="/framed/TreeView/TreeViewFlatArray" />
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
|
||||
<script>
|
||||
import { Truncate, truncate } from "carbon-components-svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
This utility component wraps the `.bx--text-truncate--*` CSS selectors from [carbon-components](https://github.com/carbon-design-system/carbon/blob/master/packages/components/src/globals/scss/_helper-classes.scss#L11) for single-line text truncation.
|
||||
`Truncate` provides text truncation functionality for single-line content. It implements Carbon's text truncation CSS classes and can be used as either a component or an action.
|
||||
|
||||
## Default
|
||||
|
||||
By default, text will be clamped at the end of the line. Text is wrapped with a paragraph (`p`) element. Use the [truncate action](#usetruncate) to truncate text in other elements.
|
||||
Display truncated text using the default component. Text is wrapped in a paragraph element and truncated at the end of the line.
|
||||
|
||||
<Truncate>
|
||||
Carbon Components Svelte is a Svelte component library that implements the Carbon Design System, an open source design system by IBM.
|
||||
|
@ -16,7 +15,7 @@ By default, text will be clamped at the end of the line. Text is wrapped with a
|
|||
|
||||
## Clamp front
|
||||
|
||||
Set `clamp` to `"front"` to clamp the text from the front.
|
||||
Truncate text from the beginning by setting `clamp` to `"front"`.
|
||||
|
||||
<Truncate clamp="front">
|
||||
Carbon Components Svelte is a Svelte component library that implements the Carbon Design System, an open source design system by IBM.
|
||||
|
@ -24,7 +23,7 @@ Set `clamp` to `"front"` to clamp the text from the front.
|
|||
|
||||
## use:truncate
|
||||
|
||||
The `truncate` action can be used on plain HTML elements.
|
||||
Apply truncation to any HTML element using the `truncate` action.
|
||||
|
||||
<h4 use:truncate>
|
||||
Carbon Components Svelte is a Svelte component library that implements the Carbon Design System, an open source design system by IBM.
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
---
|
||||
components: ["Header",
|
||||
"HeaderAction",
|
||||
|
@ -27,6 +25,8 @@ components: ["Header",
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`UIShell` provides a collection of components for building application shells and navigation structures. It includes header, side navigation, and content components that work together to create a cohesive user interface.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">
|
||||
Currently, the UI Shell is not themable and only supports dark mode.
|
||||
|
@ -37,6 +37,8 @@ Open the following examples in a new tab to experience them in full.
|
|||
|
||||
## Header
|
||||
|
||||
Create a basic header with the `Header` component.
|
||||
|
||||
<FileSource src="/framed/UIShell/Header" />
|
||||
|
||||
## Header with side navigation
|
||||
|
@ -59,14 +61,30 @@ You can disable the `transition` by setting it to `false`.
|
|||
|
||||
<FileSource src="/framed/UIShell/HeaderSwitcher" />
|
||||
|
||||
## Header with multiple switchers
|
||||
|
||||
Multiple switchers can be used, and the switcher button can be customized. For example, display a tooltip using `iconDescription`.
|
||||
|
||||
Control the tooltip alignment using `tooltipAlignment`.
|
||||
|
||||
Note that providing `text` overrides the tooltip.
|
||||
|
||||
<FileSource src="/framed/UIShell/HeaderMultipleSwitcher" />
|
||||
|
||||
## Header with global search
|
||||
|
||||
Add a global search component to the header.
|
||||
|
||||
<FileSource src="/framed/UIShell/HeaderSearch" />
|
||||
|
||||
## Header with utilities
|
||||
|
||||
Include utility components in the header using `HeaderUtilities`.
|
||||
|
||||
<FileSource src="/framed/UIShell/HeaderUtilities" />
|
||||
|
||||
## Header with persisted hamburger menu
|
||||
|
||||
Create a header with a persistent hamburger menu state.
|
||||
|
||||
<FileSource src="/framed/UIShell/PersistedHamburgerMenu" />
|
|
@ -7,6 +7,8 @@ components: ["UnorderedList", "ListItem"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`UnorderedList` provides a styled unordered list component that supports nested lists, links, and expressive typography. It's ideal for displaying bulleted content in your interface.
|
||||
|
||||
<InlineNotification svx-ignore lowContrast title="Tip:" kind="info" hideCloseButton>
|
||||
<div class="body-short-01">
|
||||
Consider using the <Link href="/components/RecursiveList#unordered">RecursiveList</Link> component for rendering tree structured data.
|
||||
|
@ -15,6 +17,8 @@ components: ["UnorderedList", "ListItem"]
|
|||
|
||||
## Default
|
||||
|
||||
Create a basic unordered list with `ListItem` components.
|
||||
|
||||
<UnorderedList>
|
||||
<ListItem>Unordered list item</ListItem>
|
||||
<ListItem>Unordered list item</ListItem>
|
||||
|
@ -23,6 +27,8 @@ components: ["UnorderedList", "ListItem"]
|
|||
|
||||
## With links
|
||||
|
||||
Add links to list items by wrapping them in `Link` components.
|
||||
|
||||
<UnorderedList>
|
||||
<ListItem>
|
||||
<Link href="#">Unordered list item</Link>
|
||||
|
@ -37,6 +43,8 @@ components: ["UnorderedList", "ListItem"]
|
|||
|
||||
## Nested
|
||||
|
||||
Create nested lists by setting `nested` to `true` on child `UnorderedList` components.
|
||||
|
||||
<UnorderedList>
|
||||
<ListItem>
|
||||
Unordered list level 1
|
||||
|
@ -57,7 +65,7 @@ components: ["UnorderedList", "ListItem"]
|
|||
|
||||
## Expressive styles
|
||||
|
||||
Set `expressive` to `true` to use Carbon's expressive typesetting.
|
||||
Use Carbon's expressive typesetting by setting `expressive` to `true`.
|
||||
|
||||
<UnorderedList expressive>
|
||||
<ListItem><Link size="lg" href="#">Unordered list item</Link></ListItem>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
{ key: "name", value: "Name" },
|
||||
{ key: "port", value: "Port" },
|
||||
{ key: "rule", value: "Rule" },
|
||||
{ key: "overflow", empty: true },
|
||||
{ key: "overflow", empty: true, width: "72px" },
|
||||
];
|
||||
|
||||
const rows = [
|
||||
|
|
|
@ -8,37 +8,40 @@
|
|||
$: console.log("sortDirection", sortDirection);
|
||||
</script>
|
||||
|
||||
<Button
|
||||
kind="tertiary"
|
||||
disabled={sortKey === "port" && sortDirection === "ascending"}
|
||||
on:click={() => {
|
||||
sortKey = "port";
|
||||
sortDirection = "ascending";
|
||||
}}
|
||||
>
|
||||
Sort "port" in ascending order
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
kind="tertiary"
|
||||
disabled={sortKey === "name" && sortDirection === "descending"}
|
||||
on:click={() => {
|
||||
sortKey = "name";
|
||||
sortDirection = "descending";
|
||||
}}
|
||||
>
|
||||
Sort "name" in descending order
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
kind="ghost"
|
||||
on:click={() => {
|
||||
sortKey = null;
|
||||
sortDirection = "none";
|
||||
}}
|
||||
>
|
||||
Clear sorting
|
||||
</Button>
|
||||
<div style="margin-bottom: 1rem">
|
||||
<Button
|
||||
size="sm"
|
||||
kind="tertiary"
|
||||
disabled={sortKey === "port" && sortDirection === "ascending"}
|
||||
on:click={() => {
|
||||
sortKey = "port";
|
||||
sortDirection = "ascending";
|
||||
}}
|
||||
>
|
||||
Sort "port" in ascending order
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
kind="tertiary"
|
||||
disabled={sortKey === "name" && sortDirection === "descending"}
|
||||
on:click={() => {
|
||||
sortKey = "name";
|
||||
sortDirection = "descending";
|
||||
}}
|
||||
>
|
||||
Sort "name" in descending order
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
kind="ghost"
|
||||
on:click={() => {
|
||||
sortKey = null;
|
||||
sortDirection = "none";
|
||||
}}
|
||||
>
|
||||
Clear sorting
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<DataTable
|
||||
sortable
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<script>
|
||||
import { RecursiveList, toHierarchy } from "carbon-components-svelte";
|
||||
|
||||
const nodesFlat = [
|
||||
{ id: 1, text: "Item 1" },
|
||||
{ id: 2, text: "Item 1a", pid: 1 },
|
||||
{ id: 3, html: "<h5>HTML content</h5>", pid: 2 },
|
||||
{ id: 4, text: "Item 2" },
|
||||
{ id: 5, href: "https://svelte.dev/", pid: 4 },
|
||||
{
|
||||
id: 6,
|
||||
href: "https://svelte.dev/",
|
||||
text: "Link with custom text",
|
||||
pid: 4,
|
||||
},
|
||||
{ id: 7, text: "Item 3" },
|
||||
];
|
||||
</script>
|
||||
|
||||
<RecursiveList nodes={toHierarchy(nodesFlat, (node) => node.pid)} />
|
28
docs/src/pages/framed/TreeView/TreeViewFlatArray.svelte
Normal file
28
docs/src/pages/framed/TreeView/TreeViewFlatArray.svelte
Normal file
|
@ -0,0 +1,28 @@
|
|||
<script>
|
||||
import { TreeView, toHierarchy } from "carbon-components-svelte";
|
||||
import Analytics from "carbon-icons-svelte/lib/Analytics.svelte";
|
||||
|
||||
let nodesFlat = [
|
||||
{ id: 0, text: "AI / Machine learning", icon: Analytics },
|
||||
{ id: 1, text: "Analytics" },
|
||||
{ id: 2, text: "IBM Analytics Engine", pid: 1 },
|
||||
{ id: 3, text: "Apache Spark", pid: 2 },
|
||||
{ id: 4, text: "Hadoop", pid: 2 },
|
||||
{ id: 5, text: "IBM Cloud SQL Query", pid: 1 },
|
||||
{ id: 6, text: "IBM Db2 Warehouse on Cloud", pid: 1 },
|
||||
{ id: 7, text: "Blockchain" },
|
||||
{ id: 8, text: "IBM Blockchain Platform", pid: 7 },
|
||||
{ id: 9, text: "Databases" },
|
||||
{ id: 10, text: "IBM Cloud Databases for Elasticsearch", pid: 9 },
|
||||
{ id: 11, text: "IBM Cloud Databases for Enterprise DB", pid: 9 },
|
||||
{ id: 12, text: "IBM Cloud Databases for MongoDB", pid: 9 },
|
||||
{ id: 13, text: "IBM Cloud Databases for PostgreSQL", pid: 9 },
|
||||
{ id: 14, text: "Integration", disabled: true },
|
||||
{ id: 15, text: "IBM API Connect", disabled: true, pid: 14 },
|
||||
];
|
||||
</script>
|
||||
|
||||
<TreeView
|
||||
labelText="Cloud Products"
|
||||
nodes={toHierarchy(nodesFlat, (node) => node.pid)}
|
||||
/>
|
85
docs/src/pages/framed/UIShell/HeaderMultipleSwitcher.svelte
Normal file
85
docs/src/pages/framed/UIShell/HeaderMultipleSwitcher.svelte
Normal file
|
@ -0,0 +1,85 @@
|
|||
<script>
|
||||
import {
|
||||
Header,
|
||||
HeaderUtilities,
|
||||
HeaderAction,
|
||||
HeaderPanelLinks,
|
||||
HeaderPanelDivider,
|
||||
HeaderPanelLink,
|
||||
SkipToContent,
|
||||
Content,
|
||||
Grid,
|
||||
Row,
|
||||
Column,
|
||||
} from "carbon-components-svelte";
|
||||
import SettingsAdjust from "carbon-icons-svelte/lib/SettingsAdjust.svelte";
|
||||
import UserAvatarFilledAlt from "carbon-icons-svelte/lib/UserAvatarFilledAlt.svelte";
|
||||
|
||||
let isOpen1 = false;
|
||||
let isOpen2 = false;
|
||||
let isOpen3 = false;
|
||||
</script>
|
||||
|
||||
<Header company="IBM" platformName="Carbon Svelte" isSideNavOpen>
|
||||
<svelte:fragment slot="skip-to-content">
|
||||
<SkipToContent />
|
||||
</svelte:fragment>
|
||||
<HeaderUtilities>
|
||||
<HeaderAction
|
||||
bind:isOpen={isOpen1}
|
||||
iconDescription="Settings"
|
||||
tooltipAlignment="start"
|
||||
icon={SettingsAdjust}
|
||||
on:open={() => {
|
||||
isOpen2 = false;
|
||||
isOpen3 = false;
|
||||
}}
|
||||
>
|
||||
<HeaderPanelLinks>
|
||||
<HeaderPanelDivider>Switcher subject 1</HeaderPanelDivider>
|
||||
<HeaderPanelLink>Switcher item 1</HeaderPanelLink>
|
||||
<HeaderPanelDivider>Switcher subject 2</HeaderPanelDivider>
|
||||
<HeaderPanelLink>Switcher item 1</HeaderPanelLink>
|
||||
</HeaderPanelLinks>
|
||||
</HeaderAction>
|
||||
<HeaderAction
|
||||
bind:isOpen={isOpen2}
|
||||
iconDescription="Profile"
|
||||
icon={UserAvatarFilledAlt}
|
||||
on:open={() => {
|
||||
isOpen1 = false;
|
||||
isOpen3 = false;
|
||||
}}
|
||||
>
|
||||
<HeaderPanelLinks>
|
||||
<HeaderPanelDivider>Switcher subject 1</HeaderPanelDivider>
|
||||
<HeaderPanelLink>Switcher item 1</HeaderPanelLink>
|
||||
<HeaderPanelDivider>Switcher subject 2</HeaderPanelDivider>
|
||||
<HeaderPanelLink>Switcher item 1</HeaderPanelLink>
|
||||
</HeaderPanelLinks>
|
||||
</HeaderAction>
|
||||
<HeaderAction
|
||||
bind:isOpen={isOpen3}
|
||||
text="Switcher text"
|
||||
on:open={() => {
|
||||
isOpen1 = false;
|
||||
isOpen2 = false;
|
||||
}}
|
||||
>
|
||||
<HeaderPanelLinks>
|
||||
<HeaderPanelDivider>Switcher subject 1</HeaderPanelDivider>
|
||||
<HeaderPanelLink>Switcher item 1</HeaderPanelLink>
|
||||
</HeaderPanelLinks>
|
||||
</HeaderAction>
|
||||
</HeaderUtilities>
|
||||
</Header>
|
||||
|
||||
<Content>
|
||||
<Grid>
|
||||
<Row>
|
||||
<Column>
|
||||
<h1>Welcome</h1>
|
||||
</Column>
|
||||
</Row>
|
||||
</Grid>
|
||||
</Content>
|
|
@ -235,7 +235,7 @@
|
|||
<TileCard
|
||||
borderBottom
|
||||
title="Carbon Icons Svelte"
|
||||
subtitle="2,400+ icons"
|
||||
subtitle="2,500+ icons"
|
||||
target="_blank"
|
||||
href="https://github.com/carbon-design-system/carbon-icons-svelte"
|
||||
/>
|
||||
|
@ -247,7 +247,7 @@
|
|||
borderBottom
|
||||
borderRight
|
||||
title="Carbon Pictograms Svelte"
|
||||
subtitle="1,100+ pictograms"
|
||||
subtitle="1,300+ pictograms"
|
||||
target="_blank"
|
||||
href="https://github.com/carbon-design-system/carbon-pictograms-svelte"
|
||||
/>
|
||||
|
@ -256,7 +256,7 @@
|
|||
<TileCard
|
||||
borderBottom
|
||||
title="Carbon Charts Svelte"
|
||||
subtitle="20+ charts, powered by d3"
|
||||
subtitle="25+ charts, powered by d3"
|
||||
target="_blank"
|
||||
href="https://github.com/carbon-design-system/carbon-charts/tree/master/packages/svelte"
|
||||
/>
|
||||
|
@ -276,8 +276,7 @@
|
|||
</Content>
|
||||
|
||||
<footer>
|
||||
<dds-footer-container disable-locale-button="true" size="micro"
|
||||
></dds-footer-container>
|
||||
<dds-footer-container disable-locale-button="true" size="micro" />
|
||||
</footer>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -4,8 +4,8 @@ import { parse, walk } from "svelte/compiler";
|
|||
import slug from "remark-slug";
|
||||
import visit from "unist-util-visit";
|
||||
import { format } from "prettier";
|
||||
import pkg from "../package.json" assert { type: "json" };
|
||||
import component_api from "./src/COMPONENT_API.json" assert { type: "json" };
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
import component_api from "./src/COMPONENT_API.json" with { type: "json" };
|
||||
import fs from "node:fs";
|
||||
import Prism from "prismjs";
|
||||
import "prism-svelte";
|
||||
|
|
|
@ -5,6 +5,10 @@ export default defineConfig({
|
|||
plugins: [svelte()],
|
||||
optimizeDeps: {
|
||||
include: ["clipboard-copy", "flatpickr/dist/plugins/rangePlugin"],
|
||||
exclude: ["@sveltech/routify"],
|
||||
exclude: [
|
||||
"carbon-components-svelte",
|
||||
"carbon-icons-svelte",
|
||||
"@sveltech/routify",
|
||||
],
|
||||
},
|
||||
});
|
||||
|
|
560
examples/rollup/package-lock.json
generated
560
examples/rollup/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -5,15 +5,17 @@
|
|||
"dev": "rollup -cw",
|
||||
"build": "rollup -c"
|
||||
},
|
||||
"dependencies": {
|
||||
"carbon-components-svelte": "^0.88.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^26.0.3",
|
||||
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||
"@rollup/plugin-node-resolve": "^15.3.1",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"carbon-components-svelte": "^0.85.3",
|
||||
"carbon-preprocess-svelte": "^0.11.7",
|
||||
"rollup": "^4.25.0",
|
||||
"carbon-preprocess-svelte": "^0.11.11",
|
||||
"rollup": "^4.45.1",
|
||||
"rollup-plugin-css-only": "^4.5.2",
|
||||
"rollup-plugin-svelte": "^7.2.2",
|
||||
"svelte": "^4.2.19"
|
||||
"svelte": "^4.2.20"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import resolve from "@rollup/plugin-node-resolve";
|
|||
import { optimizeCss, optimizeImports } from "carbon-preprocess-svelte";
|
||||
import css from "rollup-plugin-css-only";
|
||||
import svelte from "rollup-plugin-svelte";
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
import terser from "@rollup/plugin-terser";
|
||||
|
||||
const production = !process.env.ROLLUP_WATCH;
|
||||
|
||||
|
|
536
examples/sveltekit/package-lock.json
generated
536
examples/sveltekit/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -6,13 +6,15 @@
|
|||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"carbon-components-svelte": "^0.88.4",
|
||||
"carbon-pictograms-svelte": "^13.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/kit": "^2.8.0",
|
||||
"@sveltejs/kit": "^2.25.2",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||
"carbon-components-svelte": "^0.85.3",
|
||||
"carbon-pictograms-svelte": "^12.11.0",
|
||||
"carbon-preprocess-svelte": "^0.11.7",
|
||||
"svelte": "^4.2.19",
|
||||
"vite": "^5.4.10"
|
||||
"carbon-preprocess-svelte": "^0.11.11",
|
||||
"svelte": "^4.2.20",
|
||||
"vite": "^5.4.20"
|
||||
}
|
||||
}
|
||||
|
|
423
examples/vite/package-lock.json
generated
423
examples/vite/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -5,11 +5,13 @@
|
|||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"carbon-components-svelte": "^0.88.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "3.1.1",
|
||||
"carbon-components-svelte": "^0.85.3",
|
||||
"carbon-preprocess-svelte": "^0.11.7",
|
||||
"svelte": "^4.2.19",
|
||||
"vite": "^5.4.10"
|
||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||
"carbon-preprocess-svelte": "^0.11.11",
|
||||
"svelte": "^4.2.20",
|
||||
"vite": "^5.4.19"
|
||||
}
|
||||
}
|
||||
|
|
1480
examples/webpack/package-lock.json
generated
1480
examples/webpack/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -4,16 +4,18 @@
|
|||
"dev": "webpack serve",
|
||||
"build": "NODE_ENV=production webpack"
|
||||
},
|
||||
"dependencies": {
|
||||
"carbon-components-svelte": "^0.88.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"carbon-components-svelte": "^0.85.3",
|
||||
"carbon-preprocess-svelte": "^0.11.7",
|
||||
"carbon-preprocess-svelte": "^0.11.11",
|
||||
"css-loader": "^7.1.2",
|
||||
"html-webpack-plugin": "^5.6.3",
|
||||
"mini-css-extract-plugin": "^2.9.2",
|
||||
"svelte": "^4.2.19",
|
||||
"svelte": "^4.2.20",
|
||||
"svelte-loader": "^3.2.4",
|
||||
"webpack": "^5.96.1",
|
||||
"webpack": "^5.100.2",
|
||||
"webpack-cli": "^5.1.4",
|
||||
"webpack-dev-server": "^5.1.0"
|
||||
"webpack-dev-server": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
|
3668
package-lock.json
generated
3668
package-lock.json
generated
File diff suppressed because it is too large
Load diff
38
package.json
38
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "carbon-components-svelte",
|
||||
"version": "0.86.1",
|
||||
"version": "0.89.7",
|
||||
"license": "Apache-2.0",
|
||||
"description": "Svelte implementation of the Carbon Design System",
|
||||
"type": "module",
|
||||
|
@ -30,11 +30,13 @@
|
|||
"css/*.css"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "vitest",
|
||||
"test:ui": "vite",
|
||||
"test:src-types": "tsc types/**/*.ts",
|
||||
"test:types": "svelte-check --workspace tests",
|
||||
"lint": "prettier --write \"**/*.{svelte,md,js,json,ts}\"",
|
||||
"lint": "prettier --write --cache \"**/*.{svelte,md,js,json,ts}\"",
|
||||
"build:css": "node scripts/build-css",
|
||||
"build:docs": "node scripts/build-docs",
|
||||
"build:docs": "node scripts/build-docs && node scripts/format-component-api",
|
||||
"postinstall": "ibmtelemetry --config=telemetry.yml",
|
||||
"release": "standard-version && npm run build:docs"
|
||||
},
|
||||
|
@ -43,19 +45,27 @@
|
|||
"flatpickr": "4.6.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^10.4.8",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@testing-library/svelte": "^5.2.8",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"carbon-components": "10.58.12",
|
||||
"carbon-icons-svelte": "^12.1.0",
|
||||
"postcss": "^8.4.16",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier-plugin-svelte": "^3.2.8",
|
||||
"carbon-icons-svelte": "^13.4.0",
|
||||
"carbon-preprocess-svelte": "^0.11.11",
|
||||
"culls": "^0.1.1",
|
||||
"jsdom": "^26.1.0",
|
||||
"postcss": "^8.5.5",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-svelte": "^3.4.0",
|
||||
"sass": "^1.49.11",
|
||||
"standard-version": "^9.5.0",
|
||||
"sveld": "^0.22.0",
|
||||
"svelte": "^4.2.10",
|
||||
"svelte-check": "^4.0.6",
|
||||
"tinyglobby": "^0.2.10",
|
||||
"typescript": "^5.6.3"
|
||||
"sveld": "^0.22.1",
|
||||
"svelte": "^4.2.20",
|
||||
"svelte-check": "^4.2.1",
|
||||
"tinyglobby": "^0.2.14",
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^3.2.3"
|
||||
},
|
||||
"standard-version": {
|
||||
"skip": {
|
||||
|
@ -72,7 +82,7 @@
|
|||
"type": "git",
|
||||
"url": "git+https://github.com/carbon-design-system/carbon-components-svelte.git"
|
||||
},
|
||||
"homepage": "https://github.com/carbon-design-system/carbon-components-svelte",
|
||||
"homepage": "https://svelte.carbondesignsystem.com/",
|
||||
"bugs": "https://github.com/carbon-design-system/carbon-components-svelte/issues",
|
||||
"keywords": [
|
||||
"carbon",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import fs from "node:fs";
|
||||
import { globSync } from "tinyglobby";
|
||||
import { sveld } from "sveld";
|
||||
import pkg from "../package.json" assert { type: "json" };
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
sveld({
|
||||
glob: true,
|
||||
|
@ -22,7 +22,7 @@ sveld({
|
|||
},
|
||||
});
|
||||
|
||||
globSync(["./src/**/*.d.ts"]).forEach((file) => {
|
||||
for (const file of globSync(["./src/**/*.d.ts"])) {
|
||||
console.log("Copying", file, " to types/");
|
||||
fs.copyFileSync(file, file.replace(/src/, "types"));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
// @ts-check
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import pkg from "../package.json" assert { type: "json" };
|
||||
|
||||
/** @type {Array<keyof typeof pkg>} */
|
||||
const keys_to_remove = ["prettier", "standard-version", "devDependencies"];
|
||||
|
||||
for (const key of keys_to_remove) {
|
||||
delete pkg[key];
|
||||
}
|
||||
|
||||
/** @type {Set<keyof typeof pkg.scripts>} */
|
||||
const scripts_to_keep = new Set(["postinstall"]);
|
||||
|
||||
for (const script in pkg.scripts) {
|
||||
// @ts-ignore
|
||||
if (!scripts_to_keep.has(script)) {
|
||||
delete pkg.scripts[script];
|
||||
}
|
||||
}
|
||||
|
||||
// Write the updated package.json file.
|
||||
const pkgPath = path.join(process.cwd(), "package.json");
|
||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
116
scripts/format-component-api.js
Normal file
116
scripts/format-component-api.js
Normal file
|
@ -0,0 +1,116 @@
|
|||
// @ts-check
|
||||
import fs from "node:fs";
|
||||
import componentApi from "../docs/src/COMPONENT_API.json" with { type: "json" };
|
||||
import { format } from "prettier";
|
||||
import plugin from "prettier/plugins/typescript";
|
||||
|
||||
const formatTypeScript = async (value) => {
|
||||
return await format(value, {
|
||||
parser: "typescript",
|
||||
plugins: [plugin],
|
||||
printWidth: 40, // Force breaking onto new lines
|
||||
bracketSameLine: false,
|
||||
});
|
||||
};
|
||||
|
||||
console.time("formatComponentApi");
|
||||
|
||||
const modified = { ...componentApi };
|
||||
|
||||
modified.components = await Promise.all(
|
||||
componentApi.components.map(async (component) => {
|
||||
component.props = await Promise.all(
|
||||
component.props.map(async (prop) => {
|
||||
if (!prop.value || !/\s{2,}/.test(prop.value)) {
|
||||
return prop;
|
||||
}
|
||||
|
||||
let normalizedValue = prop.value;
|
||||
const prefix = `const ${prop.name} = `;
|
||||
|
||||
if (prop.isFunction || prop.value.startsWith("{")) {
|
||||
normalizedValue = prefix + prop.value;
|
||||
}
|
||||
|
||||
const formatted = (await formatTypeScript(normalizedValue))
|
||||
// Remove prefix needed for formatting.
|
||||
.replace(new RegExp(`^${prefix}`), "")
|
||||
// Remove trailing semi-colon.
|
||||
.replace(/;\s*$/, "");
|
||||
|
||||
return {
|
||||
...prop,
|
||||
value: formatted,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
component.typedefs = await Promise.all(
|
||||
component.typedefs.map(async (typedef) => {
|
||||
if (!typedef.ts) {
|
||||
return typedef;
|
||||
}
|
||||
|
||||
return {
|
||||
...typedef,
|
||||
ts: await formatTypeScript(typedef.ts),
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
component.events = await Promise.all(
|
||||
component.events.map(async (event) => {
|
||||
if (event.type === "forwarded") {
|
||||
return event;
|
||||
}
|
||||
|
||||
const normalizedValue = `type EventDetail = ${event.detail}`;
|
||||
|
||||
const formatted = (await formatTypeScript(normalizedValue))
|
||||
// Remove prefix needed for formatting.
|
||||
.replace(/type EventDetail = /, "")
|
||||
// Remove trailing semi-colon.
|
||||
.replace(/;\s*$/, "");
|
||||
|
||||
return {
|
||||
...event,
|
||||
detail: formatted,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
component.slots = await Promise.all(
|
||||
component.slots.map(async (slot) => {
|
||||
if (!slot.slot_props) {
|
||||
return slot;
|
||||
}
|
||||
|
||||
let normalizedValue = slot.slot_props;
|
||||
|
||||
if (normalizedValue.startsWith("{")) {
|
||||
normalizedValue = `type SlotProps = ${normalizedValue}`;
|
||||
}
|
||||
|
||||
const formatted = (await formatTypeScript(normalizedValue))
|
||||
// Remove prefix needed for formatting.
|
||||
.replace(/type SlotProps = /, "")
|
||||
// Remove trailing semi-colon.
|
||||
.replace(/;\s*$/, "");
|
||||
|
||||
return {
|
||||
...slot,
|
||||
slot_props: formatted,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return component;
|
||||
}),
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
"./docs/src/COMPONENT_API.json",
|
||||
JSON.stringify(modified, null, 2),
|
||||
);
|
||||
|
||||
console.timeEnd("formatComponentApi");
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue