@jesusgm/react-components 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +158 -0
- package/dist/components/atoms/avatar/index.d.ts +19 -0
- package/dist/components/atoms/avatar/index.js +44 -0
- package/dist/components/atoms/avatar/index.js.map +1 -0
- package/dist/components/atoms/avatar/styles.css +50 -0
- package/dist/components/atoms/badge/index.d.ts +17 -0
- package/dist/components/atoms/badge/index.js +37 -0
- package/dist/components/atoms/badge/index.js.map +1 -0
- package/dist/components/atoms/badge/styles.css +83 -0
- package/dist/components/atoms/button/index.d.ts +16 -0
- package/dist/components/atoms/button/index.js +22 -0
- package/dist/components/atoms/button/index.js.map +1 -0
- package/dist/components/atoms/button/styles.css +77 -0
- package/dist/components/atoms/checkbox/index.d.ts +13 -0
- package/dist/components/atoms/checkbox/index.js +63 -0
- package/dist/components/atoms/checkbox/index.js.map +1 -0
- package/dist/components/atoms/checkbox/styles.css +87 -0
- package/dist/components/atoms/code-highlighter/index.d.ts +8 -0
- package/dist/components/atoms/code-highlighter/index.js +24 -0
- package/dist/components/atoms/code-highlighter/index.js.map +1 -0
- package/dist/components/atoms/code-highlighter/railscasts.css +1 -0
- package/dist/components/atoms/code-highlighter/styles.css +17 -0
- package/dist/components/atoms/divider/index.d.ts +10 -0
- package/dist/components/atoms/divider/index.js +25 -0
- package/dist/components/atoms/divider/index.js.map +1 -0
- package/dist/components/atoms/divider/styles.css +56 -0
- package/dist/components/atoms/icon/index.d.ts +23 -0
- package/dist/components/atoms/icon/index.js +20 -0
- package/dist/components/atoms/icon/index.js.map +1 -0
- package/dist/components/atoms/icon/styles.css +13 -0
- package/dist/components/atoms/kbd/index.d.ts +7 -0
- package/dist/components/atoms/kbd/index.js +26 -0
- package/dist/components/atoms/kbd/index.js.map +1 -0
- package/dist/components/atoms/kbd/styles.css +29 -0
- package/dist/components/atoms/label/index.d.ts +9 -0
- package/dist/components/atoms/label/index.js +18 -0
- package/dist/components/atoms/label/index.js.map +1 -0
- package/dist/components/atoms/label/styles.css +19 -0
- package/dist/components/atoms/link/index.d.ts +12 -0
- package/dist/components/atoms/link/index.js +32 -0
- package/dist/components/atoms/link/index.js.map +1 -0
- package/dist/components/atoms/link/styles.css +54 -0
- package/dist/components/atoms/progress-bar/index.d.ts +23 -0
- package/dist/components/atoms/progress-bar/index.js +45 -0
- package/dist/components/atoms/progress-bar/index.js.map +1 -0
- package/dist/components/atoms/progress-bar/styles.css +75 -0
- package/dist/components/atoms/radio/context.d.ts +9 -0
- package/dist/components/atoms/radio/context.js +9 -0
- package/dist/components/atoms/radio/context.js.map +1 -0
- package/dist/components/atoms/radio/index.d.ts +15 -0
- package/dist/components/atoms/radio/index.js +44 -0
- package/dist/components/atoms/radio/index.js.map +1 -0
- package/dist/components/atoms/radio/radio-group.d.ts +25 -0
- package/dist/components/atoms/radio/radio-group.js +49 -0
- package/dist/components/atoms/radio/radio-group.js.map +1 -0
- package/dist/components/atoms/radio/styles.css +110 -0
- package/dist/components/atoms/skeleton/index.d.ts +15 -0
- package/dist/components/atoms/skeleton/index.js +38 -0
- package/dist/components/atoms/skeleton/index.js.map +1 -0
- package/dist/components/atoms/skeleton/styles.css +57 -0
- package/dist/components/atoms/spinner/index.d.ts +11 -0
- package/dist/components/atoms/spinner/index.js +22 -0
- package/dist/components/atoms/spinner/index.js.map +1 -0
- package/dist/components/atoms/spinner/styles.css +51 -0
- package/dist/components/atoms/switch/index.d.ts +14 -0
- package/dist/components/atoms/switch/index.js +33 -0
- package/dist/components/atoms/switch/index.js.map +1 -0
- package/dist/components/atoms/switch/styles.css +99 -0
- package/dist/components/atoms/text-input/index.d.ts +20 -0
- package/dist/components/atoms/text-input/index.js +33 -0
- package/dist/components/atoms/text-input/index.js.map +1 -0
- package/dist/components/atoms/text-input/styles.css +80 -0
- package/dist/components/atoms/textarea/index.d.ts +14 -0
- package/dist/components/atoms/textarea/index.js +43 -0
- package/dist/components/atoms/textarea/index.js.map +1 -0
- package/dist/components/atoms/textarea/styles.css +49 -0
- package/dist/components/atoms/typography/index.d.ts +30 -0
- package/dist/components/atoms/typography/index.js +30 -0
- package/dist/components/atoms/typography/index.js.map +1 -0
- package/dist/components/atoms/typography/styles.css +50 -0
- package/dist/components/atoms/video-player/index.d.ts +9 -0
- package/dist/components/atoms/video-player/index.js +17 -0
- package/dist/components/atoms/video-player/index.js.map +1 -0
- package/dist/components/atoms/video-player/styles.css +18 -0
- package/dist/components/atoms/visually-hidden/index.d.ts +7 -0
- package/dist/components/atoms/visually-hidden/index.js +13 -0
- package/dist/components/atoms/visually-hidden/index.js.map +1 -0
- package/dist/components/atoms/visually-hidden/styles.css +12 -0
- package/dist/components/hooks/index.d.ts +3 -0
- package/dist/components/hooks/index.js +4 -0
- package/dist/components/hooks/use-click-outside.d.ts +6 -0
- package/dist/components/hooks/use-click-outside.js +30 -0
- package/dist/components/hooks/use-click-outside.js.map +1 -0
- package/dist/components/hooks/use-controllable-state.d.ts +5 -0
- package/dist/components/hooks/use-controllable-state.js +22 -0
- package/dist/components/hooks/use-controllable-state.js.map +1 -0
- package/dist/components/hooks/use-focus-trap.d.ts +8 -0
- package/dist/components/hooks/use-focus-trap.js +57 -0
- package/dist/components/hooks/use-focus-trap.js.map +1 -0
- package/dist/components/index.d.ts +122 -0
- package/dist/components/index.js +74 -0
- package/dist/components/molecules/accordion/index.d.ts +27 -0
- package/dist/components/molecules/accordion/index.js +98 -0
- package/dist/components/molecules/accordion/index.js.map +1 -0
- package/dist/components/molecules/accordion/styles.css +75 -0
- package/dist/components/molecules/alert/index.d.ts +18 -0
- package/dist/components/molecules/alert/index.js +91 -0
- package/dist/components/molecules/alert/index.js.map +1 -0
- package/dist/components/molecules/alert/styles.css +97 -0
- package/dist/components/molecules/binary-clock/index.d.ts +16 -0
- package/dist/components/molecules/binary-clock/index.js +66 -0
- package/dist/components/molecules/binary-clock/index.js.map +1 -0
- package/dist/components/molecules/binary-clock/styles.css +46 -0
- package/dist/components/molecules/breadcrumb/index.d.ts +23 -0
- package/dist/components/molecules/breadcrumb/index.js +79 -0
- package/dist/components/molecules/breadcrumb/index.js.map +1 -0
- package/dist/components/molecules/breadcrumb/styles.css +61 -0
- package/dist/components/molecules/card/index.d.ts +39 -0
- package/dist/components/molecules/card/index.js +60 -0
- package/dist/components/molecules/card/index.js.map +1 -0
- package/dist/components/molecules/card/styles.css +105 -0
- package/dist/components/molecules/chart/index.d.ts +14 -0
- package/dist/components/molecules/chart/index.js +104 -0
- package/dist/components/molecules/chart/index.js.map +1 -0
- package/dist/components/molecules/conflict-resolver/components/conflictItem.d.ts +8 -0
- package/dist/components/molecules/conflict-resolver/components/conflictItem.js +58 -0
- package/dist/components/molecules/conflict-resolver/components/conflictItem.js.map +1 -0
- package/dist/components/molecules/conflict-resolver/components/styles.css +64 -0
- package/dist/components/molecules/conflict-resolver/index.d.ts +10 -0
- package/dist/components/molecules/conflict-resolver/index.js +35 -0
- package/dist/components/molecules/conflict-resolver/index.js.map +1 -0
- package/dist/components/molecules/conflict-resolver/types.d.ts +10 -0
- package/dist/components/molecules/dropable-list/draggable.d.ts +9 -0
- package/dist/components/molecules/dropable-list/draggable.js +18 -0
- package/dist/components/molecules/dropable-list/draggable.js.map +1 -0
- package/dist/components/molecules/dropable-list/index.d.ts +20 -0
- package/dist/components/molecules/dropable-list/index.js +52 -0
- package/dist/components/molecules/dropable-list/index.js.map +1 -0
- package/dist/components/molecules/dropable-list/styles.css +63 -0
- package/dist/components/molecules/dropdown-menu/index.d.ts +43 -0
- package/dist/components/molecules/dropdown-menu/index.js +226 -0
- package/dist/components/molecules/dropdown-menu/index.js.map +1 -0
- package/dist/components/molecules/dropdown-menu/styles.css +94 -0
- package/dist/components/molecules/empty-state/index.d.ts +16 -0
- package/dist/components/molecules/empty-state/index.js +32 -0
- package/dist/components/molecules/empty-state/index.js.map +1 -0
- package/dist/components/molecules/empty-state/styles.css +64 -0
- package/dist/components/molecules/file-input/index.d.ts +39 -0
- package/dist/components/molecules/file-input/index.js +121 -0
- package/dist/components/molecules/file-input/index.js.map +1 -0
- package/dist/components/molecules/file-input/styles.css +86 -0
- package/dist/components/molecules/form-field/index.d.ts +38 -0
- package/dist/components/molecules/form-field/index.js +71 -0
- package/dist/components/molecules/form-field/index.js.map +1 -0
- package/dist/components/molecules/form-field/styles.css +43 -0
- package/dist/components/molecules/list/index.d.ts +25 -0
- package/dist/components/molecules/list/index.js +30 -0
- package/dist/components/molecules/list/index.js.map +1 -0
- package/dist/components/molecules/list/styles.css +28 -0
- package/dist/components/molecules/number-stepper/index.d.ts +31 -0
- package/dist/components/molecules/number-stepper/index.js +163 -0
- package/dist/components/molecules/number-stepper/index.js.map +1 -0
- package/dist/components/molecules/number-stepper/styles.css +69 -0
- package/dist/components/molecules/pagination/index.d.ts +39 -0
- package/dist/components/molecules/pagination/index.js +111 -0
- package/dist/components/molecules/pagination/index.js.map +1 -0
- package/dist/components/molecules/pagination/styles.css +41 -0
- package/dist/components/molecules/popover/index.d.ts +22 -0
- package/dist/components/molecules/popover/index.js +76 -0
- package/dist/components/molecules/popover/index.js.map +1 -0
- package/dist/components/molecules/popover/positioning.d.ts +40 -0
- package/dist/components/molecules/popover/positioning.js +115 -0
- package/dist/components/molecules/popover/positioning.js.map +1 -0
- package/dist/components/molecules/popover/styles.css +36 -0
- package/dist/components/molecules/rating/index.d.ts +33 -0
- package/dist/components/molecules/rating/index.js +117 -0
- package/dist/components/molecules/rating/index.js.map +1 -0
- package/dist/components/molecules/rating/styles.css +94 -0
- package/dist/components/molecules/search-input/index.d.ts +23 -0
- package/dist/components/molecules/search-input/index.js +118 -0
- package/dist/components/molecules/search-input/index.js.map +1 -0
- package/dist/components/molecules/search-input/styles.css +69 -0
- package/dist/components/molecules/segmented-control/button-group.d.ts +10 -0
- package/dist/components/molecules/segmented-control/button-group.js +15 -0
- package/dist/components/molecules/segmented-control/button-group.js.map +1 -0
- package/dist/components/molecules/segmented-control/index.d.ts +38 -0
- package/dist/components/molecules/segmented-control/index.js +80 -0
- package/dist/components/molecules/segmented-control/index.js.map +1 -0
- package/dist/components/molecules/segmented-control/styles.css +130 -0
- package/dist/components/molecules/select/index.d.ts +30 -0
- package/dist/components/molecules/select/index.js +48 -0
- package/dist/components/molecules/select/index.js.map +1 -0
- package/dist/components/molecules/select/styles.css +102 -0
- package/dist/components/molecules/tabs/index.d.ts +31 -0
- package/dist/components/molecules/tabs/index.js +87 -0
- package/dist/components/molecules/tabs/index.js.map +1 -0
- package/dist/components/molecules/tabs/styles.css +87 -0
- package/dist/components/molecules/tag-cloud/index.d.ts +16 -0
- package/dist/components/molecules/tag-cloud/index.js +133 -0
- package/dist/components/molecules/tag-cloud/index.js.map +1 -0
- package/dist/components/molecules/tag-cloud/styles.css +29 -0
- package/dist/components/molecules/tooltip/index.d.ts +22 -0
- package/dist/components/molecules/tooltip/index.js +83 -0
- package/dist/components/molecules/tooltip/index.js.map +1 -0
- package/dist/components/molecules/tooltip/styles.css +30 -0
- package/dist/components/molecules/virtualized-list/index.d.ts +5 -0
- package/dist/components/molecules/virtualized-list/index.js +3 -0
- package/dist/components/molecules/virtualized-list/lista/index.d.ts +11 -0
- package/dist/components/molecules/virtualized-list/lista/index.js +30 -0
- package/dist/components/molecules/virtualized-list/lista/index.js.map +1 -0
- package/dist/components/molecules/virtualized-list/lista/styles.css +27 -0
- package/dist/components/molecules/virtualized-list/lista-slow/index.d.ts +10 -0
- package/dist/components/molecules/virtualized-list/lista-slow/index.js +17 -0
- package/dist/components/molecules/virtualized-list/lista-slow/index.js.map +1 -0
- package/dist/components/molecules/virtualized-list/row/index.d.ts +9 -0
- package/dist/components/molecules/virtualized-list/row/index.js +30 -0
- package/dist/components/molecules/virtualized-list/row/index.js.map +1 -0
- package/dist/components/molecules/virtualized-list/types.d.ts +4 -0
- package/dist/components/organisms/combobox/index.d.ts +82 -0
- package/dist/components/organisms/combobox/index.js +386 -0
- package/dist/components/organisms/combobox/index.js.map +1 -0
- package/dist/components/organisms/combobox/styles.css +269 -0
- package/dist/components/organisms/command-palette/index.d.ts +49 -0
- package/dist/components/organisms/command-palette/index.js +239 -0
- package/dist/components/organisms/command-palette/index.js.map +1 -0
- package/dist/components/organisms/command-palette/score.d.ts +12 -0
- package/dist/components/organisms/command-palette/score.js +43 -0
- package/dist/components/organisms/command-palette/score.js.map +1 -0
- package/dist/components/organisms/command-palette/styles.css +212 -0
- package/dist/components/organisms/date-picker/calendar.d.ts +29 -0
- package/dist/components/organisms/date-picker/calendar.js +178 -0
- package/dist/components/organisms/date-picker/calendar.js.map +1 -0
- package/dist/components/organisms/date-picker/date-utils.d.ts +52 -0
- package/dist/components/organisms/date-picker/date-utils.js +139 -0
- package/dist/components/organisms/date-picker/date-utils.js.map +1 -0
- package/dist/components/organisms/date-picker/index.d.ts +54 -0
- package/dist/components/organisms/date-picker/index.js +173 -0
- package/dist/components/organisms/date-picker/index.js.map +1 -0
- package/dist/components/organisms/date-picker/styles.css +179 -0
- package/dist/components/organisms/drawer/index.d.ts +16 -0
- package/dist/components/organisms/drawer/index.js +15 -0
- package/dist/components/organisms/drawer/index.js.map +1 -0
- package/dist/components/organisms/drawer/styles.css +163 -0
- package/dist/components/organisms/editor/index.d.ts +13 -0
- package/dist/components/organisms/editor/index.js +56 -0
- package/dist/components/organisms/editor/index.js.map +1 -0
- package/dist/components/organisms/editor/styles.css +61 -0
- package/dist/components/organisms/form/context.d.ts +7 -0
- package/dist/components/organisms/form/context.js +11 -0
- package/dist/components/organisms/form/context.js.map +1 -0
- package/dist/components/organisms/form/field.d.ts +18 -0
- package/dist/components/organisms/form/field.js +98 -0
- package/dist/components/organisms/form/field.js.map +1 -0
- package/dist/components/organisms/form/form-actions.d.ts +8 -0
- package/dist/components/organisms/form/form-actions.js +13 -0
- package/dist/components/organisms/form/form-actions.js.map +1 -0
- package/dist/components/organisms/form/index.d.ts +24 -0
- package/dist/components/organisms/form/index.js +215 -0
- package/dist/components/organisms/form/index.js.map +1 -0
- package/dist/components/organisms/form/styles.css +29 -0
- package/dist/components/organisms/form/types.d.ts +95 -0
- package/dist/components/organisms/form/validation.d.ts +5 -0
- package/dist/components/organisms/form/validation.js +35 -0
- package/dist/components/organisms/form/validation.js.map +1 -0
- package/dist/components/organisms/header/index.d.ts +40 -0
- package/dist/components/organisms/header/index.js +186 -0
- package/dist/components/organisms/header/index.js.map +1 -0
- package/dist/components/organisms/header/styles.css +126 -0
- package/dist/components/organisms/modal/dialog-base.d.ts +31 -0
- package/dist/components/organisms/modal/dialog-base.js +123 -0
- package/dist/components/organisms/modal/dialog-base.js.map +1 -0
- package/dist/components/organisms/modal/index.d.ts +13 -0
- package/dist/components/organisms/modal/index.js +15 -0
- package/dist/components/organisms/modal/index.js.map +1 -0
- package/dist/components/organisms/modal/styles.css +143 -0
- package/dist/components/organisms/presenter/components/slides/simple/index.d.ts +13 -0
- package/dist/components/organisms/presenter/components/slides/simple/index.js +16 -0
- package/dist/components/organisms/presenter/components/slides/simple/index.js.map +1 -0
- package/dist/components/organisms/presenter/components/slides/simple/styles.css +6 -0
- package/dist/components/organisms/presenter/index.d.ts +17 -0
- package/dist/components/organisms/presenter/index.js +63 -0
- package/dist/components/organisms/presenter/index.js.map +1 -0
- package/dist/components/organisms/presenter/styles.css +75 -0
- package/dist/components/organisms/sidebar/index.d.ts +50 -0
- package/dist/components/organisms/sidebar/index.js +157 -0
- package/dist/components/organisms/sidebar/index.js.map +1 -0
- package/dist/components/organisms/sidebar/styles.css +197 -0
- package/dist/components/organisms/slider/index.d.ts +47 -0
- package/dist/components/organisms/slider/index.js +214 -0
- package/dist/components/organisms/slider/index.js.map +1 -0
- package/dist/components/organisms/slider/styles.css +110 -0
- package/dist/components/organisms/table/components/cell/index.d.ts +8 -0
- package/dist/components/organisms/table/components/cell/index.js +11 -0
- package/dist/components/organisms/table/components/cell/index.js.map +1 -0
- package/dist/components/organisms/table/index.d.ts +29 -0
- package/dist/components/organisms/table/index.js +105 -0
- package/dist/components/organisms/table/index.js.map +1 -0
- package/dist/components/organisms/table/styles.css +66 -0
- package/dist/components/organisms/terminal/index.d.ts +15 -0
- package/dist/components/organisms/terminal/index.js +111 -0
- package/dist/components/organisms/terminal/index.js.map +1 -0
- package/dist/components/organisms/terminal/styles.css +123 -0
- package/dist/components/organisms/toast/index.d.ts +66 -0
- package/dist/components/organisms/toast/index.js +142 -0
- package/dist/components/organisms/toast/index.js.map +1 -0
- package/dist/components/organisms/toast/styles.css +138 -0
- package/dist/components/organisms/wizard/index.d.ts +44 -0
- package/dist/components/organisms/wizard/index.js +171 -0
- package/dist/components/organisms/wizard/index.js.map +1 -0
- package/dist/components/organisms/wizard/styles.css +160 -0
- package/dist/components/utils/cx.d.ts +2 -0
- package/dist/components/utils/cx.js +8 -0
- package/dist/components/utils/cx.js.map +1 -0
- package/dist/components/utils/portal/index.d.ts +9 -0
- package/dist/components/utils/portal/index.js +13 -0
- package/dist/components/utils/portal/index.js.map +1 -0
- package/dist/components/utils/theme-provider/index.d.ts +22 -0
- package/dist/components/utils/theme-provider/index.js +36 -0
- package/dist/components/utils/theme-provider/index.js.map +1 -0
- package/dist/styles.css +743 -0
- package/dist/tokens.css +299 -0
- package/package.json +390 -4
- package/README.md +0 -3
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* Segmented control */
|
|
2
|
+
.ds-segmented-control {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
gap: var(--space-1);
|
|
5
|
+
height: var(--control-height-md);
|
|
6
|
+
padding: var(--space-1);
|
|
7
|
+
border-radius: var(--radius-lg);
|
|
8
|
+
background: var(--color-neutral);
|
|
9
|
+
font-family: var(--font-sans);
|
|
10
|
+
font-size: var(--font-size-sm);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ds-segmented-control__item {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
flex: 1 1 auto;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
gap: var(--space-2);
|
|
19
|
+
min-width: 0;
|
|
20
|
+
padding: 0 var(--control-padding-x-sm);
|
|
21
|
+
border: 0;
|
|
22
|
+
border-radius: var(--radius-md);
|
|
23
|
+
background: transparent;
|
|
24
|
+
color: var(--color-text-muted);
|
|
25
|
+
font: inherit;
|
|
26
|
+
font-weight: var(--font-weight-medium);
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
transition:
|
|
30
|
+
background-color var(--duration-fast) var(--easing-standard),
|
|
31
|
+
color var(--duration-fast) var(--easing-standard),
|
|
32
|
+
box-shadow var(--duration-fast) var(--easing-standard);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ds-segmented-control__item:hover:not(:disabled):not(.ds-segmented-control__item--checked) {
|
|
36
|
+
color: var(--color-text);
|
|
37
|
+
background: var(--color-neutral-hover);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ds-segmented-control__item:focus-visible {
|
|
41
|
+
outline: var(--border-width-2) solid var(--color-focus-ring);
|
|
42
|
+
outline-offset: 2px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ds-segmented-control__item--checked {
|
|
46
|
+
background: var(--color-surface);
|
|
47
|
+
color: var(--color-text);
|
|
48
|
+
box-shadow: var(--shadow-sm);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.ds-segmented-control__item:disabled {
|
|
52
|
+
color: var(--color-text-disabled);
|
|
53
|
+
cursor: not-allowed;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.ds-segmented-control__icon {
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
font-size: var(--icon-size-sm);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ds-segmented-control__label {
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
text-overflow: ellipsis;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ds-segmented-control--sm {
|
|
67
|
+
height: var(--control-height-sm);
|
|
68
|
+
font-size: var(--font-size-xs);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.ds-segmented-control--lg {
|
|
72
|
+
height: var(--control-height-lg);
|
|
73
|
+
font-size: var(--font-size-md);
|
|
74
|
+
}
|
|
75
|
+
.ds-segmented-control--lg .ds-segmented-control__item {
|
|
76
|
+
padding: 0 var(--control-padding-x-md);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.ds-segmented-control--invalid {
|
|
80
|
+
box-shadow: inset 0 0 0 var(--border-width-1) var(--color-danger);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.ds-segmented-control--full {
|
|
84
|
+
display: flex;
|
|
85
|
+
width: 100%;
|
|
86
|
+
}
|
|
87
|
+
.ds-segmented-control--full .ds-segmented-control__item {
|
|
88
|
+
flex: 1 1 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Button group */
|
|
92
|
+
.ds-button-group {
|
|
93
|
+
display: inline-flex;
|
|
94
|
+
gap: var(--space-2);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.ds-button-group--vertical {
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ds-button-group--attached {
|
|
102
|
+
gap: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.ds-button-group--attached > .ds-button:focus-visible {
|
|
106
|
+
position: relative;
|
|
107
|
+
z-index: var(--z-raised);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Horizontal: square inner corners, overlap shared borders */
|
|
111
|
+
.ds-button-group--horizontal.ds-button-group--attached > .ds-button:not(:first-child) {
|
|
112
|
+
margin-left: calc(-1 * var(--border-width-1));
|
|
113
|
+
border-top-left-radius: 0;
|
|
114
|
+
border-bottom-left-radius: 0;
|
|
115
|
+
}
|
|
116
|
+
.ds-button-group--horizontal.ds-button-group--attached > .ds-button:not(:last-child) {
|
|
117
|
+
border-top-right-radius: 0;
|
|
118
|
+
border-bottom-right-radius: 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Vertical */
|
|
122
|
+
.ds-button-group--vertical.ds-button-group--attached > .ds-button:not(:first-child) {
|
|
123
|
+
margin-top: calc(-1 * var(--border-width-1));
|
|
124
|
+
border-top-left-radius: 0;
|
|
125
|
+
border-top-right-radius: 0;
|
|
126
|
+
}
|
|
127
|
+
.ds-button-group--vertical.ds-button-group--attached > .ds-button:not(:last-child) {
|
|
128
|
+
border-bottom-left-radius: 0;
|
|
129
|
+
border-bottom-right-radius: 0;
|
|
130
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReactNode, SelectHTMLAttributes } from "react";
|
|
2
|
+
export type SelectSize = "sm" | "md" | "lg";
|
|
3
|
+
/** One entry of the `options` prop */
|
|
4
|
+
export interface SelectOption {
|
|
5
|
+
/** Value submitted with the form */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Visible text */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Makes the option unselectable */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "size"> {
|
|
13
|
+
/** Options to render. Alternatively pass `<option>` / `<optgroup>` children */
|
|
14
|
+
options?: SelectOption[];
|
|
15
|
+
/** Text of an empty, disabled and hidden first option shown while nothing is selected */
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
/** Height and padding, from the control-size tokens */
|
|
18
|
+
size?: SelectSize;
|
|
19
|
+
/** Marks the value as invalid (sets `aria-invalid` and a danger border) */
|
|
20
|
+
invalid?: boolean;
|
|
21
|
+
/** Stretch to the container width */
|
|
22
|
+
fullWidth?: boolean;
|
|
23
|
+
/** Class name applied to the root wrapper element (the native select receives the rest of the props) */
|
|
24
|
+
className?: string;
|
|
25
|
+
/** `<option>` elements, used when `options` is not given */
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
/** Styled native `<select>`: accessible and mobile friendly. */
|
|
29
|
+
declare const Select: import("react").ForwardRefExoticComponent<SelectProps & import("react").RefAttributes<HTMLSelectElement>>;
|
|
30
|
+
export default Select;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { cx } from "../../utils/cx.js";
|
|
3
|
+
import './styles.css';/* empty css */
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/molecules/select/index.tsx
|
|
6
|
+
/** Styled native `<select>`: accessible and mobile friendly. */
|
|
7
|
+
var Select = forwardRef(function Select({ options, placeholder, size = "md", invalid = false, fullWidth = false, className, disabled, value, defaultValue, multiple, children, ...rest }, ref) {
|
|
8
|
+
const initial = value === void 0 && defaultValue === void 0 && placeholder != null && !multiple ? "" : defaultValue;
|
|
9
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
10
|
+
className: cx("ds-select", `ds-select--${size}`, invalid && "ds-select--invalid", disabled && "ds-select--disabled", fullWidth && "ds-select--full", multiple && "ds-select--multiple", className),
|
|
11
|
+
children: [/* @__PURE__ */ jsxs("select", {
|
|
12
|
+
ref,
|
|
13
|
+
className: "ds-select__field",
|
|
14
|
+
disabled,
|
|
15
|
+
multiple,
|
|
16
|
+
"aria-invalid": invalid || void 0,
|
|
17
|
+
...value !== void 0 ? { value } : {},
|
|
18
|
+
...initial !== void 0 ? { defaultValue: initial } : {},
|
|
19
|
+
...rest,
|
|
20
|
+
children: [placeholder != null && !multiple && /* @__PURE__ */ jsx("option", {
|
|
21
|
+
value: "",
|
|
22
|
+
disabled: true,
|
|
23
|
+
hidden: true,
|
|
24
|
+
children: placeholder
|
|
25
|
+
}), options ? options.map((option) => /* @__PURE__ */ jsx("option", {
|
|
26
|
+
value: option.value,
|
|
27
|
+
disabled: option.disabled,
|
|
28
|
+
children: option.label
|
|
29
|
+
}, option.value)) : children]
|
|
30
|
+
}), !multiple && /* @__PURE__ */ jsx("svg", {
|
|
31
|
+
className: "ds-select__chevron",
|
|
32
|
+
viewBox: "0 0 16 16",
|
|
33
|
+
fill: "none",
|
|
34
|
+
"aria-hidden": "true",
|
|
35
|
+
focusable: "false",
|
|
36
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
37
|
+
d: "M4 6l4 4 4-4",
|
|
38
|
+
stroke: "currentColor",
|
|
39
|
+
strokeWidth: "1.6",
|
|
40
|
+
strokeLinecap: "round",
|
|
41
|
+
strokeLinejoin: "round"
|
|
42
|
+
})
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
export { Select as default };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_jsxs","_jsx"],"sources":["../../../../src/components/molecules/select/index.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ReactNode, SelectHTMLAttributes } from \"react\";\nimport { cx } from \"../../utils/cx\";\nimport \"./styles.css\";\n\nexport type SelectSize = \"sm\" | \"md\" | \"lg\";\n\n/** One entry of the `options` prop */\nexport interface SelectOption {\n /** Value submitted with the form */\n value: string;\n /** Visible text */\n label: string;\n /** Makes the option unselectable */\n disabled?: boolean;\n}\n\nexport interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, \"size\"> {\n /** Options to render. Alternatively pass `<option>` / `<optgroup>` children */\n options?: SelectOption[];\n /** Text of an empty, disabled and hidden first option shown while nothing is selected */\n placeholder?: string;\n /** Height and padding, from the control-size tokens */\n size?: SelectSize;\n /** Marks the value as invalid (sets `aria-invalid` and a danger border) */\n invalid?: boolean;\n /** Stretch to the container width */\n fullWidth?: boolean;\n /** Class name applied to the root wrapper element (the native select receives the rest of the props) */\n className?: string;\n /** `<option>` elements, used when `options` is not given */\n children?: ReactNode;\n}\n\n/** Styled native `<select>`: accessible and mobile friendly. */\nconst Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n {\n options,\n placeholder,\n size = \"md\",\n invalid = false,\n fullWidth = false,\n className,\n disabled,\n value,\n defaultValue,\n multiple,\n children,\n ...rest\n },\n ref\n) {\n // Show the placeholder initially when the select is uncontrolled and has no default.\n const initial = value === undefined && defaultValue === undefined && placeholder != null && !multiple ? \"\" : defaultValue;\n\n return (\n <span\n className={cx(\n \"ds-select\",\n `ds-select--${size}`,\n invalid && \"ds-select--invalid\",\n disabled && \"ds-select--disabled\",\n fullWidth && \"ds-select--full\",\n multiple && \"ds-select--multiple\",\n className\n )}\n >\n <select\n ref={ref}\n className=\"ds-select__field\"\n disabled={disabled}\n multiple={multiple}\n aria-invalid={invalid || undefined}\n {...(value !== undefined ? { value } : {})}\n {...(initial !== undefined ? { defaultValue: initial } : {})}\n {...rest}\n >\n {placeholder != null && !multiple && (\n <option value=\"\" disabled hidden>\n {placeholder}\n </option>\n )}\n {options\n ? options.map((option) => (\n <option key={option.value} value={option.value} disabled={option.disabled}>\n {option.label}\n </option>\n ))\n : children}\n </select>\n {!multiple && (\n <svg className=\"ds-select__chevron\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M4 6l4 4 4-4\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </span>\n );\n});\n\nexport default Select;\n"],"mappings":";;;;;;AAmCA,IAAM,SAAS,WAA2C,SAAS,OACjE,EACE,SACA,aACA,OAAO,MACP,UAAU,OACV,YAAY,OACZ,WACA,UACA,OACA,cACA,UACA,UACA,GAAG,QAEL,KACA;CAEA,MAAM,UAAU,UAAU,KAAA,KAAa,iBAAiB,KAAA,KAAa,eAAe,QAAQ,CAAC,WAAW,KAAK;CAE7G,OACEA,qBAAC,QAAD;EACE,WAAW,GACT,aACA,cAAc,QACd,WAAW,sBACX,YAAY,uBACZ,aAAa,mBACb,YAAY,uBACZ,SACF;EATF,UAAA,CAWEA,qBAAC,UAAD;GACO;GACL,WAAU;GACA;GACA;GACV,gBAAc,WAAW,KAAA;GACzB,GAAK,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;GACxC,GAAK,YAAY,KAAA,IAAY,EAAE,cAAc,QAAQ,IAAI,CAAC;GAC1D,GAAI;GARN,UAAA,CAUG,eAAe,QAAQ,CAAC,YACvBC,oBAAC,UAAD;IAAQ,OAAM;IAAG,UAAA;IAAS,QAAA;IACvB,UAAA;GACK,CAAA,GAET,UACG,QAAQ,KAAK,WACXA,oBAAC,UAAD;IAA2B,OAAO,OAAO;IAAO,UAAU,OAAO;IAC9D,UAAA,OAAO;GACF,GAFK,OAAO,KAEZ,CACT,IACD,QACE;EACP,CAAA,GAAA,CAAC,YACAA,oBAAC,OAAD;GAAK,WAAU;GAAqB,SAAQ;GAAY,MAAK;GAAO,eAAY;GAAO,WAAU;GAC/F,UAAAA,oBAAC,QAAD;IAAM,GAAE;IAAe,QAAO;IAAe,aAAY;IAAM,eAAc;IAAQ,gBAAe;GAAS,CAAA;EAC1G,CAAA,CAEH;;AAEV,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
.ds-select {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
height: var(--control-height-md);
|
|
6
|
+
font-family: var(--font-sans);
|
|
7
|
+
font-size: var(--font-size-sm);
|
|
8
|
+
color: var(--color-text);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.ds-select__field {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 0 calc(var(--control-padding-x-md) + var(--icon-size-sm) + var(--space-2)) 0 var(--control-padding-x-md);
|
|
16
|
+
border: var(--border-width-1) solid var(--color-border-strong);
|
|
17
|
+
border-radius: var(--radius-md);
|
|
18
|
+
background: var(--color-surface);
|
|
19
|
+
color: inherit;
|
|
20
|
+
font: inherit;
|
|
21
|
+
line-height: var(--line-height-tight);
|
|
22
|
+
appearance: none;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
transition: border-color var(--duration-fast) var(--easing-standard);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ds-select__field:hover:not(:disabled) {
|
|
28
|
+
border-color: var(--color-text-subtle);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ds-select__field:focus-visible {
|
|
32
|
+
outline: var(--border-width-2) solid var(--color-focus-ring);
|
|
33
|
+
outline-offset: 2px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.ds-select__field:invalid,
|
|
37
|
+
.ds-select__field option[value=""] {
|
|
38
|
+
color: var(--color-text-subtle);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ds-select__field option {
|
|
42
|
+
color: var(--color-text);
|
|
43
|
+
background: var(--color-surface);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ds-select__chevron {
|
|
47
|
+
position: absolute;
|
|
48
|
+
right: var(--control-padding-x-md);
|
|
49
|
+
width: var(--icon-size-sm);
|
|
50
|
+
height: var(--icon-size-sm);
|
|
51
|
+
color: var(--color-text-muted);
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Sizes */
|
|
56
|
+
.ds-select--sm {
|
|
57
|
+
height: var(--control-height-sm);
|
|
58
|
+
font-size: var(--font-size-xs);
|
|
59
|
+
}
|
|
60
|
+
.ds-select--sm .ds-select__field {
|
|
61
|
+
padding: 0 calc(var(--control-padding-x-sm) + var(--icon-size-sm) + var(--space-1)) 0 var(--control-padding-x-sm);
|
|
62
|
+
}
|
|
63
|
+
.ds-select--sm .ds-select__chevron {
|
|
64
|
+
right: var(--control-padding-x-sm);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.ds-select--lg {
|
|
68
|
+
height: var(--control-height-lg);
|
|
69
|
+
font-size: var(--font-size-md);
|
|
70
|
+
}
|
|
71
|
+
.ds-select--lg .ds-select__field {
|
|
72
|
+
padding: 0 calc(var(--control-padding-x-lg) + var(--icon-size-sm) + var(--space-2)) 0 var(--control-padding-x-lg);
|
|
73
|
+
}
|
|
74
|
+
.ds-select--lg .ds-select__chevron {
|
|
75
|
+
right: var(--control-padding-x-lg);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Multiple: a list box, no fixed height or chevron */
|
|
79
|
+
.ds-select--multiple {
|
|
80
|
+
height: auto;
|
|
81
|
+
}
|
|
82
|
+
.ds-select--multiple .ds-select__field {
|
|
83
|
+
padding: var(--space-1);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ds-select--full {
|
|
87
|
+
display: flex;
|
|
88
|
+
width: 100%;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.ds-select--invalid .ds-select__field,
|
|
92
|
+
.ds-select--invalid .ds-select__field:hover:not(:disabled) {
|
|
93
|
+
border-color: var(--color-danger);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.ds-select--disabled {
|
|
97
|
+
color: var(--color-text-disabled);
|
|
98
|
+
}
|
|
99
|
+
.ds-select--disabled .ds-select__field {
|
|
100
|
+
background: var(--color-bg-subtle);
|
|
101
|
+
cursor: not-allowed;
|
|
102
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
export interface TabItem {
|
|
3
|
+
/** Unique id of the tab, used as its value */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Text or content of the tab button */
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
/** Content of the panel */
|
|
8
|
+
content: ReactNode;
|
|
9
|
+
/** The tab cannot be selected or focused with the keyboard */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type TabsOrientation = "horizontal" | "vertical";
|
|
13
|
+
export type TabsActivation = "automatic" | "manual";
|
|
14
|
+
export interface TabsProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> {
|
|
15
|
+
/** Tabs to render, in order */
|
|
16
|
+
items: TabItem[];
|
|
17
|
+
/** Id of the selected tab, controlled */
|
|
18
|
+
value?: string;
|
|
19
|
+
/** Id of the initially selected tab, uncontrolled. Default: the first enabled tab */
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
/** Called with the id of the newly selected tab */
|
|
22
|
+
onChange?: (id: string) => void;
|
|
23
|
+
/** Layout and arrow keys: Left/Right for horizontal, Up/Down for vertical. Default "horizontal" */
|
|
24
|
+
orientation?: TabsOrientation;
|
|
25
|
+
/** "automatic" selects a tab when it gets focus; "manual" requires Enter or Space. Default "automatic" */
|
|
26
|
+
activation?: TabsActivation;
|
|
27
|
+
/** Accessible label of the tab list */
|
|
28
|
+
"aria-label"?: string;
|
|
29
|
+
}
|
|
30
|
+
declare function Tabs({ items, value, defaultValue, onChange, orientation, activation, className, "aria-label": ariaLabel, ...rest }: TabsProps): import("react").JSX.Element;
|
|
31
|
+
export default Tabs;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useId, useRef } from "react";
|
|
2
|
+
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
3
|
+
import { cx } from "../../utils/cx.js";
|
|
4
|
+
import './styles.css';/* empty css */
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/molecules/tabs/index.tsx
|
|
7
|
+
function Tabs({ items, value, defaultValue, onChange, orientation = "horizontal", activation = "automatic", className, "aria-label": ariaLabel, ...rest }) {
|
|
8
|
+
const baseId = useId();
|
|
9
|
+
const firstEnabled = items.find((item) => !item.disabled)?.id ?? "";
|
|
10
|
+
const [selected, setSelected] = useControllableState(value, defaultValue ?? firstEnabled, onChange);
|
|
11
|
+
const tabRefs = useRef(/* @__PURE__ */ new Map());
|
|
12
|
+
const selectedItem = items.find((item) => item.id === selected && !item.disabled);
|
|
13
|
+
const activeId = selectedItem ? selectedItem.id : firstEnabled;
|
|
14
|
+
const tabId = (id) => `${baseId}-tab-${id}`;
|
|
15
|
+
const panelId = (id) => `${baseId}-panel-${id}`;
|
|
16
|
+
const onKeyDown = (event, currentId) => {
|
|
17
|
+
const enabled = items.filter((item) => !item.disabled);
|
|
18
|
+
if (enabled.length === 0) return;
|
|
19
|
+
const index = enabled.findIndex((item) => item.id === currentId);
|
|
20
|
+
const prevKey = orientation === "vertical" ? "ArrowUp" : "ArrowLeft";
|
|
21
|
+
const nextKey = orientation === "vertical" ? "ArrowDown" : "ArrowRight";
|
|
22
|
+
let target;
|
|
23
|
+
switch (event.key) {
|
|
24
|
+
case nextKey:
|
|
25
|
+
target = enabled[(index + 1) % enabled.length];
|
|
26
|
+
break;
|
|
27
|
+
case prevKey:
|
|
28
|
+
target = enabled[(index - 1 + enabled.length) % enabled.length];
|
|
29
|
+
break;
|
|
30
|
+
case "Home":
|
|
31
|
+
target = enabled[0];
|
|
32
|
+
break;
|
|
33
|
+
case "End":
|
|
34
|
+
target = enabled[enabled.length - 1];
|
|
35
|
+
break;
|
|
36
|
+
default: return;
|
|
37
|
+
}
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
tabRefs.current.get(target.id)?.focus();
|
|
40
|
+
if (activation === "automatic") setSelected(target.id);
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
43
|
+
className: cx("ds-tabs", `ds-tabs--${orientation}`, className),
|
|
44
|
+
...rest,
|
|
45
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
46
|
+
role: "tablist",
|
|
47
|
+
"aria-label": ariaLabel,
|
|
48
|
+
"aria-orientation": orientation,
|
|
49
|
+
className: "ds-tabs__list",
|
|
50
|
+
children: items.map((item) => {
|
|
51
|
+
const isSelected = item.id === activeId;
|
|
52
|
+
return /* @__PURE__ */ jsx("button", {
|
|
53
|
+
ref: (el) => {
|
|
54
|
+
if (el) tabRefs.current.set(item.id, el);
|
|
55
|
+
else tabRefs.current.delete(item.id);
|
|
56
|
+
},
|
|
57
|
+
type: "button",
|
|
58
|
+
role: "tab",
|
|
59
|
+
id: tabId(item.id),
|
|
60
|
+
"aria-selected": isSelected,
|
|
61
|
+
"aria-controls": panelId(item.id),
|
|
62
|
+
"aria-disabled": item.disabled || void 0,
|
|
63
|
+
disabled: item.disabled,
|
|
64
|
+
tabIndex: isSelected ? 0 : -1,
|
|
65
|
+
className: cx("ds-tabs__tab", isSelected && "ds-tabs__tab--selected"),
|
|
66
|
+
onClick: () => !item.disabled && setSelected(item.id),
|
|
67
|
+
onKeyDown: (event) => onKeyDown(event, item.id),
|
|
68
|
+
children: item.label
|
|
69
|
+
}, item.id);
|
|
70
|
+
})
|
|
71
|
+
}), items.map((item) => {
|
|
72
|
+
const isSelected = item.id === activeId;
|
|
73
|
+
return /* @__PURE__ */ jsx("div", {
|
|
74
|
+
role: "tabpanel",
|
|
75
|
+
id: panelId(item.id),
|
|
76
|
+
"aria-labelledby": tabId(item.id),
|
|
77
|
+
hidden: !isSelected,
|
|
78
|
+
tabIndex: 0,
|
|
79
|
+
className: "ds-tabs__panel",
|
|
80
|
+
children: isSelected ? item.content : null
|
|
81
|
+
}, item.id);
|
|
82
|
+
})]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
export { Tabs as default };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_jsxs","_jsx"],"sources":["../../../../src/components/molecules/tabs/index.tsx"],"sourcesContent":["import { useId, useRef, type HTMLAttributes, type KeyboardEvent, type ReactNode } from \"react\";\nimport { useControllableState } from \"../../hooks\";\nimport { cx } from \"../../utils/cx\";\nimport \"./styles.css\";\n\nexport interface TabItem {\n /** Unique id of the tab, used as its value */\n id: string;\n /** Text or content of the tab button */\n label: ReactNode;\n /** Content of the panel */\n content: ReactNode;\n /** The tab cannot be selected or focused with the keyboard */\n disabled?: boolean;\n}\n\nexport type TabsOrientation = \"horizontal\" | \"vertical\";\nexport type TabsActivation = \"automatic\" | \"manual\";\n\nexport interface TabsProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n /** Tabs to render, in order */\n items: TabItem[];\n /** Id of the selected tab, controlled */\n value?: string;\n /** Id of the initially selected tab, uncontrolled. Default: the first enabled tab */\n defaultValue?: string;\n /** Called with the id of the newly selected tab */\n onChange?: (id: string) => void;\n /** Layout and arrow keys: Left/Right for horizontal, Up/Down for vertical. Default \"horizontal\" */\n orientation?: TabsOrientation;\n /** \"automatic\" selects a tab when it gets focus; \"manual\" requires Enter or Space. Default \"automatic\" */\n activation?: TabsActivation;\n /** Accessible label of the tab list */\n \"aria-label\"?: string;\n}\n\nfunction Tabs({\n items,\n value,\n defaultValue,\n onChange,\n orientation = \"horizontal\",\n activation = \"automatic\",\n className,\n \"aria-label\": ariaLabel,\n ...rest\n}: TabsProps) {\n const baseId = useId();\n const firstEnabled = items.find((item) => !item.disabled)?.id ?? \"\";\n const [selected, setSelected] = useControllableState<string>(value, defaultValue ?? firstEnabled, onChange);\n const tabRefs = useRef<Map<string, HTMLButtonElement>>(new Map());\n\n const selectedItem = items.find((item) => item.id === selected && !item.disabled);\n const activeId = selectedItem ? selectedItem.id : firstEnabled;\n\n const tabId = (id: string) => `${baseId}-tab-${id}`;\n const panelId = (id: string) => `${baseId}-panel-${id}`;\n\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>, currentId: string) => {\n const enabled = items.filter((item) => !item.disabled);\n if (enabled.length === 0) return;\n const index = enabled.findIndex((item) => item.id === currentId);\n const prevKey = orientation === \"vertical\" ? \"ArrowUp\" : \"ArrowLeft\";\n const nextKey = orientation === \"vertical\" ? \"ArrowDown\" : \"ArrowRight\";\n let target: TabItem | undefined;\n switch (event.key) {\n case nextKey:\n target = enabled[(index + 1) % enabled.length];\n break;\n case prevKey:\n target = enabled[(index - 1 + enabled.length) % enabled.length];\n break;\n case \"Home\":\n target = enabled[0];\n break;\n case \"End\":\n target = enabled[enabled.length - 1];\n break;\n default:\n return;\n }\n event.preventDefault();\n tabRefs.current.get(target.id)?.focus();\n if (activation === \"automatic\") setSelected(target.id);\n };\n\n return (\n <div className={cx(\"ds-tabs\", `ds-tabs--${orientation}`, className)} {...rest}>\n <div\n role=\"tablist\"\n aria-label={ariaLabel}\n aria-orientation={orientation}\n className=\"ds-tabs__list\"\n >\n {items.map((item) => {\n const isSelected = item.id === activeId;\n return (\n <button\n key={item.id}\n ref={(el) => {\n if (el) tabRefs.current.set(item.id, el);\n else tabRefs.current.delete(item.id);\n }}\n type=\"button\"\n role=\"tab\"\n id={tabId(item.id)}\n aria-selected={isSelected}\n aria-controls={panelId(item.id)}\n aria-disabled={item.disabled || undefined}\n disabled={item.disabled}\n tabIndex={isSelected ? 0 : -1}\n className={cx(\"ds-tabs__tab\", isSelected && \"ds-tabs__tab--selected\")}\n onClick={() => !item.disabled && setSelected(item.id)}\n onKeyDown={(event) => onKeyDown(event, item.id)}\n >\n {item.label}\n </button>\n );\n })}\n </div>\n {items.map((item) => {\n const isSelected = item.id === activeId;\n return (\n <div\n key={item.id}\n role=\"tabpanel\"\n id={panelId(item.id)}\n aria-labelledby={tabId(item.id)}\n hidden={!isSelected}\n tabIndex={0}\n className=\"ds-tabs__panel\"\n >\n {isSelected ? item.content : null}\n </div>\n );\n })}\n </div>\n );\n}\n\nexport default Tabs;\n"],"mappings":";;;;;;AAoCA,SAAS,KAAK,EACZ,OACA,OACA,cACA,UACA,cAAc,cACd,aAAa,aACb,WACA,cAAc,WACd,GAAG,QACS;CACZ,MAAM,SAAS,MAAM;CACrB,MAAM,eAAe,MAAM,MAAM,SAAS,CAAC,KAAK,QAAQ,CAAC,EAAE,MAAM;CACjE,MAAM,CAAC,UAAU,eAAe,qBAA6B,OAAO,gBAAgB,cAAc,QAAQ;CAC1G,MAAM,UAAU,uBAAuC,IAAI,IAAI,CAAC;CAEhE,MAAM,eAAe,MAAM,MAAM,SAAS,KAAK,OAAO,YAAY,CAAC,KAAK,QAAQ;CAChF,MAAM,WAAW,eAAe,aAAa,KAAK;CAElD,MAAM,SAAS,OAAe,GAAG,OAAO,OAAO;CAC/C,MAAM,WAAW,OAAe,GAAG,OAAO,SAAS;CAEnD,MAAM,aAAa,OAAyC,cAAsB;EAChF,MAAM,UAAU,MAAM,QAAQ,SAAS,CAAC,KAAK,QAAQ;EACrD,IAAI,QAAQ,WAAW,GAAG;EAC1B,MAAM,QAAQ,QAAQ,WAAW,SAAS,KAAK,OAAO,SAAS;EAC/D,MAAM,UAAU,gBAAgB,aAAa,YAAY;EACzD,MAAM,UAAU,gBAAgB,aAAa,cAAc;EAC3D,IAAI;EACJ,QAAQ,MAAM,KAAd;GACE,KAAK;IACH,SAAS,SAAS,QAAQ,KAAK,QAAQ;IACvC;GACF,KAAK;IACH,SAAS,SAAS,QAAQ,IAAI,QAAQ,UAAU,QAAQ;IACxD;GACF,KAAK;IACH,SAAS,QAAQ;IACjB;GACF,KAAK;IACH,SAAS,QAAQ,QAAQ,SAAS;IAClC;GACF,SACE;EACJ;EACA,MAAM,eAAe;EACrB,QAAQ,QAAQ,IAAI,OAAO,EAAE,CAAC,EAAE,MAAM;EACtC,IAAI,eAAe,aAAa,YAAY,OAAO,EAAE;CACvD;CAEA,OACEA,qBAAC,OAAD;EAAK,WAAW,GAAG,WAAW,YAAY,eAAe,SAAS;EAAG,GAAI;EAAzE,UAAA,CACEC,oBAAC,OAAD;GACE,MAAK;GACL,cAAY;GACZ,oBAAkB;GAClB,WAAU;GAET,UAAA,MAAM,KAAK,SAAS;IACnB,MAAM,aAAa,KAAK,OAAO;IAC/B,OACEA,oBAAC,UAAD;KAEE,MAAM,OAAO;MACX,IAAI,IAAI,QAAQ,QAAQ,IAAI,KAAK,IAAI,EAAE;WAClC,QAAQ,QAAQ,OAAO,KAAK,EAAE;KACrC;KACA,MAAK;KACL,MAAK;KACL,IAAI,MAAM,KAAK,EAAE;KACjB,iBAAe;KACf,iBAAe,QAAQ,KAAK,EAAE;KAC9B,iBAAe,KAAK,YAAY,KAAA;KAChC,UAAU,KAAK;KACf,UAAU,aAAa,IAAI;KAC3B,WAAW,GAAG,gBAAgB,cAAc,wBAAwB;KACpE,eAAe,CAAC,KAAK,YAAY,YAAY,KAAK,EAAE;KACpD,YAAY,UAAU,UAAU,OAAO,KAAK,EAAE;KAE7C,UAAA,KAAK;IACA,GAlBD,KAAK,EAkBJ;GAEZ,CAAC;EACE,CAAA,GACJ,MAAM,KAAK,SAAS;GACnB,MAAM,aAAa,KAAK,OAAO;GAC/B,OACEA,oBAAC,OAAD;IAEE,MAAK;IACL,IAAI,QAAQ,KAAK,EAAE;IACnB,mBAAiB,MAAM,KAAK,EAAE;IAC9B,QAAQ,CAAC;IACT,UAAU;IACV,WAAU;IAET,UAAA,aAAa,KAAK,UAAU;GAC1B,GATE,KAAK,EASP;EAET,CAAC,CACE;;AAET"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.ds-tabs {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--space-4);
|
|
5
|
+
font-family: var(--font-sans);
|
|
6
|
+
color: var(--color-text);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.ds-tabs--vertical {
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
align-items: flex-start;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.ds-tabs__list {
|
|
15
|
+
display: flex;
|
|
16
|
+
gap: var(--space-1);
|
|
17
|
+
border-bottom: var(--border-width-1) solid var(--color-border);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ds-tabs--vertical .ds-tabs__list {
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
flex-shrink: 0;
|
|
23
|
+
border-bottom: 0;
|
|
24
|
+
border-right: var(--border-width-1) solid var(--color-border);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ds-tabs__tab {
|
|
28
|
+
position: relative;
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
gap: var(--space-2);
|
|
32
|
+
height: var(--control-height-md);
|
|
33
|
+
padding: 0 var(--control-padding-x-md);
|
|
34
|
+
margin-bottom: calc(var(--border-width-1) * -1);
|
|
35
|
+
border: 0;
|
|
36
|
+
border-bottom: var(--border-width-2) solid transparent;
|
|
37
|
+
border-radius: var(--radius-md) var(--radius-md) 0 0;
|
|
38
|
+
background: transparent;
|
|
39
|
+
color: var(--color-text-muted);
|
|
40
|
+
font-family: inherit;
|
|
41
|
+
font-size: var(--font-size-sm);
|
|
42
|
+
font-weight: var(--font-weight-medium);
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
transition:
|
|
46
|
+
color var(--duration-fast) var(--easing-standard),
|
|
47
|
+
background-color var(--duration-fast) var(--easing-standard),
|
|
48
|
+
border-color var(--duration-fast) var(--easing-standard);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.ds-tabs--vertical .ds-tabs__tab {
|
|
52
|
+
justify-content: flex-start;
|
|
53
|
+
margin-bottom: 0;
|
|
54
|
+
margin-right: calc(var(--border-width-1) * -1);
|
|
55
|
+
border-bottom: 0;
|
|
56
|
+
border-right: var(--border-width-2) solid transparent;
|
|
57
|
+
border-radius: var(--radius-md) 0 0 var(--radius-md);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.ds-tabs__tab:hover:not(:disabled) {
|
|
61
|
+
background: var(--color-neutral);
|
|
62
|
+
color: var(--color-text);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.ds-tabs__tab--selected {
|
|
66
|
+
border-color: var(--color-primary);
|
|
67
|
+
color: var(--color-primary-text);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.ds-tabs__tab:disabled {
|
|
71
|
+
color: var(--color-text-disabled);
|
|
72
|
+
cursor: not-allowed;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.ds-tabs__tab:focus-visible,
|
|
76
|
+
.ds-tabs__panel:focus-visible {
|
|
77
|
+
outline: var(--border-width-2) solid var(--color-focus-ring);
|
|
78
|
+
outline-offset: 2px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ds-tabs__panel {
|
|
82
|
+
flex: 1;
|
|
83
|
+
min-width: 0;
|
|
84
|
+
border-radius: var(--radius-md);
|
|
85
|
+
font-size: var(--font-size-sm);
|
|
86
|
+
line-height: var(--line-height-normal);
|
|
87
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Tag {
|
|
2
|
+
id: string | number;
|
|
3
|
+
name: string;
|
|
4
|
+
/** Relevance from 0 to 100: bigger font (and maybe bold above 90) */
|
|
5
|
+
percentage: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TagCloudProps {
|
|
8
|
+
/** Tags to show */
|
|
9
|
+
tags?: Tag[];
|
|
10
|
+
/** Seconds between re-shuffles (0 disables the animation) */
|
|
11
|
+
interval?: number;
|
|
12
|
+
/** Height of the cloud area (any CSS length) */
|
|
13
|
+
height?: string;
|
|
14
|
+
}
|
|
15
|
+
declare function TagCloud({ tags, interval, height }: TagCloudProps): import("react").JSX.Element;
|
|
16
|
+
export default TagCloud;
|