@arbor-education/design-system.components 0.6.0 → 0.7.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/CHANGELOG.md +25 -0
- package/dist/components/avatar/Avatar.d.ts +1 -1
- package/dist/components/avatar/Avatar.d.ts.map +1 -1
- package/dist/components/avatar/Avatar.js +1 -1
- package/dist/components/avatar/Avatar.js.map +1 -1
- package/dist/components/avatar/Avatar.stories.d.ts.map +1 -1
- package/dist/components/avatar/Avatar.stories.js +7 -0
- package/dist/components/avatar/Avatar.stories.js.map +1 -1
- package/dist/components/badge/Badge.d.ts +12 -0
- package/dist/components/badge/Badge.d.ts.map +1 -0
- package/dist/components/badge/Badge.js +6 -0
- package/dist/components/badge/Badge.js.map +1 -0
- package/dist/components/badge/Badge.stories.d.ts +10 -0
- package/dist/components/badge/Badge.stories.d.ts.map +1 -0
- package/dist/components/badge/Badge.stories.js +51 -0
- package/dist/components/badge/Badge.stories.js.map +1 -0
- package/dist/components/badge/Badge.test.d.ts +2 -0
- package/dist/components/badge/Badge.test.d.ts.map +1 -0
- package/dist/components/badge/Badge.test.js +23 -0
- package/dist/components/badge/Badge.test.js.map +1 -0
- package/dist/components/card/Card.js +1 -1
- package/dist/components/card/Card.js.map +1 -1
- package/dist/components/combobox/Combobox.d.ts +16 -0
- package/dist/components/combobox/Combobox.d.ts.map +1 -0
- package/dist/components/combobox/Combobox.js +195 -0
- package/dist/components/combobox/Combobox.js.map +1 -0
- package/dist/components/combobox/Combobox.stories.d.ts +24 -0
- package/dist/components/combobox/Combobox.stories.d.ts.map +1 -0
- package/dist/components/combobox/Combobox.stories.js +246 -0
- package/dist/components/combobox/Combobox.stories.js.map +1 -0
- package/dist/components/combobox/Combobox.test.d.ts +2 -0
- package/dist/components/combobox/Combobox.test.d.ts.map +1 -0
- package/dist/components/combobox/Combobox.test.js +798 -0
- package/dist/components/combobox/Combobox.test.js.map +1 -0
- package/dist/components/combobox/ComboboxButtonTrigger.d.ts +28 -0
- package/dist/components/combobox/ComboboxButtonTrigger.d.ts.map +1 -0
- package/dist/components/combobox/ComboboxButtonTrigger.js +64 -0
- package/dist/components/combobox/ComboboxButtonTrigger.js.map +1 -0
- package/dist/components/combobox/ComboboxListbox.d.ts +44 -0
- package/dist/components/combobox/ComboboxListbox.d.ts.map +1 -0
- package/dist/components/combobox/ComboboxListbox.js +37 -0
- package/dist/components/combobox/ComboboxListbox.js.map +1 -0
- package/dist/components/combobox/ComboboxOptionRow.d.ts +23 -0
- package/dist/components/combobox/ComboboxOptionRow.d.ts.map +1 -0
- package/dist/components/combobox/ComboboxOptionRow.js +27 -0
- package/dist/components/combobox/ComboboxOptionRow.js.map +1 -0
- package/dist/components/combobox/ComboboxTrigger.d.ts +35 -0
- package/dist/components/combobox/ComboboxTrigger.d.ts.map +1 -0
- package/dist/components/combobox/ComboboxTrigger.js +15 -0
- package/dist/components/combobox/ComboboxTrigger.js.map +1 -0
- package/dist/components/combobox/buildListboxDisplayOptions.d.ts +3 -0
- package/dist/components/combobox/buildListboxDisplayOptions.d.ts.map +1 -0
- package/dist/components/combobox/buildListboxDisplayOptions.js +13 -0
- package/dist/components/combobox/buildListboxDisplayOptions.js.map +1 -0
- package/dist/components/combobox/buildListboxDisplayOptions.test.d.ts +2 -0
- package/dist/components/combobox/buildListboxDisplayOptions.test.d.ts.map +1 -0
- package/dist/components/combobox/buildListboxDisplayOptions.test.js +22 -0
- package/dist/components/combobox/buildListboxDisplayOptions.test.js.map +1 -0
- package/dist/components/combobox/comboboxKeyboardTypes.d.ts +41 -0
- package/dist/components/combobox/comboboxKeyboardTypes.d.ts.map +1 -0
- package/dist/components/combobox/comboboxKeyboardTypes.js +2 -0
- package/dist/components/combobox/comboboxKeyboardTypes.js.map +1 -0
- package/dist/components/combobox/highlightLabel.d.ts +10 -0
- package/dist/components/combobox/highlightLabel.d.ts.map +1 -0
- package/dist/components/combobox/highlightLabel.js +18 -0
- package/dist/components/combobox/highlightLabel.js.map +1 -0
- package/dist/components/combobox/normaliseComboboxQuery.d.ts +2 -0
- package/dist/components/combobox/normaliseComboboxQuery.d.ts.map +1 -0
- package/dist/components/combobox/normaliseComboboxQuery.js +2 -0
- package/dist/components/combobox/normaliseComboboxQuery.js.map +1 -0
- package/dist/components/combobox/types.d.ts +46 -0
- package/dist/components/combobox/types.d.ts.map +1 -0
- package/dist/components/combobox/types.js +2 -0
- package/dist/components/combobox/types.js.map +1 -0
- package/dist/components/combobox/useChipSelection.d.ts +11 -0
- package/dist/components/combobox/useChipSelection.d.ts.map +1 -0
- package/dist/components/combobox/useChipSelection.js +35 -0
- package/dist/components/combobox/useChipSelection.js.map +1 -0
- package/dist/components/combobox/useComboboxChipKeyboard.d.ts +3 -0
- package/dist/components/combobox/useComboboxChipKeyboard.d.ts.map +1 -0
- package/dist/components/combobox/useComboboxChipKeyboard.js +103 -0
- package/dist/components/combobox/useComboboxChipKeyboard.js.map +1 -0
- package/dist/components/combobox/useComboboxChipKeyboard.test.d.ts +2 -0
- package/dist/components/combobox/useComboboxChipKeyboard.test.d.ts.map +1 -0
- package/dist/components/combobox/useComboboxChipKeyboard.test.js +116 -0
- package/dist/components/combobox/useComboboxChipKeyboard.test.js.map +1 -0
- package/dist/components/combobox/useComboboxKeyboard.d.ts +4 -0
- package/dist/components/combobox/useComboboxKeyboard.d.ts.map +1 -0
- package/dist/components/combobox/useComboboxKeyboard.js +68 -0
- package/dist/components/combobox/useComboboxKeyboard.js.map +1 -0
- package/dist/components/combobox/useComboboxListboxDom.d.ts +11 -0
- package/dist/components/combobox/useComboboxListboxDom.d.ts.map +1 -0
- package/dist/components/combobox/useComboboxListboxDom.js +15 -0
- package/dist/components/combobox/useComboboxListboxDom.js.map +1 -0
- package/dist/components/combobox/useComboboxListboxKeyboard.d.ts +3 -0
- package/dist/components/combobox/useComboboxListboxKeyboard.d.ts.map +1 -0
- package/dist/components/combobox/useComboboxListboxKeyboard.js +143 -0
- package/dist/components/combobox/useComboboxListboxKeyboard.js.map +1 -0
- package/dist/components/combobox/useComboboxListboxKeyboard.test.d.ts +2 -0
- package/dist/components/combobox/useComboboxListboxKeyboard.test.d.ts.map +1 -0
- package/dist/components/combobox/useComboboxListboxKeyboard.test.js +152 -0
- package/dist/components/combobox/useComboboxListboxKeyboard.test.js.map +1 -0
- package/dist/components/combobox/useComboboxPopoverBehavior.d.ts +38 -0
- package/dist/components/combobox/useComboboxPopoverBehavior.d.ts.map +1 -0
- package/dist/components/combobox/useComboboxPopoverBehavior.js +104 -0
- package/dist/components/combobox/useComboboxPopoverBehavior.js.map +1 -0
- package/dist/components/combobox/useComboboxState.d.ts +27 -0
- package/dist/components/combobox/useComboboxState.d.ts.map +1 -0
- package/dist/components/combobox/useComboboxState.js +122 -0
- package/dist/components/combobox/useComboboxState.js.map +1 -0
- package/dist/components/combobox/useElementWidth.d.ts +2 -0
- package/dist/components/combobox/useElementWidth.d.ts.map +1 -0
- package/dist/components/combobox/useElementWidth.js +31 -0
- package/dist/components/combobox/useElementWidth.js.map +1 -0
- package/dist/components/combobox/useVisibleChips.d.ts +21 -0
- package/dist/components/combobox/useVisibleChips.d.ts.map +1 -0
- package/dist/components/combobox/useVisibleChips.js +59 -0
- package/dist/components/combobox/useVisibleChips.js.map +1 -0
- package/dist/components/combobox/useVisibleChips.test.d.ts +2 -0
- package/dist/components/combobox/useVisibleChips.test.d.ts.map +1 -0
- package/dist/components/combobox/useVisibleChips.test.js +81 -0
- package/dist/components/combobox/useVisibleChips.test.js.map +1 -0
- package/dist/components/dot/Dot.d.ts +8 -0
- package/dist/components/dot/Dot.d.ts.map +1 -0
- package/dist/components/dot/Dot.js +6 -0
- package/dist/components/dot/Dot.js.map +1 -0
- package/dist/components/dot/Dot.stories.d.ts +15 -0
- package/dist/components/dot/Dot.stories.d.ts.map +1 -0
- package/dist/components/dot/Dot.stories.js +25 -0
- package/dist/components/dot/Dot.stories.js.map +1 -0
- package/dist/components/dot/Dot.test.d.ts +2 -0
- package/dist/components/dot/Dot.test.d.ts.map +1 -0
- package/dist/components/dot/Dot.test.js +19 -0
- package/dist/components/dot/Dot.test.js.map +1 -0
- package/dist/components/formField/FormField.d.ts +8 -4
- package/dist/components/formField/FormField.d.ts.map +1 -1
- package/dist/components/formField/FormField.js +7 -6
- package/dist/components/formField/FormField.js.map +1 -1
- package/dist/components/formField/FormField.stories.d.ts +1 -0
- package/dist/components/formField/FormField.stories.d.ts.map +1 -1
- package/dist/components/formField/FormField.stories.js +13 -1
- package/dist/components/formField/FormField.stories.js.map +1 -1
- package/dist/components/formField/FormField.test.js +10 -0
- package/dist/components/formField/FormField.test.js.map +1 -1
- package/dist/components/icon/allowedIcons.d.ts +1 -0
- package/dist/components/icon/allowedIcons.d.ts.map +1 -1
- package/dist/components/icon/allowedIcons.js +2 -1
- package/dist/components/icon/allowedIcons.js.map +1 -1
- package/dist/components/progress/Progress.stories.d.ts +49 -49
- package/dist/components/singleUser/SingleUser.d.ts +15 -0
- package/dist/components/singleUser/SingleUser.d.ts.map +1 -0
- package/dist/components/singleUser/SingleUser.js +9 -0
- package/dist/components/singleUser/SingleUser.js.map +1 -0
- package/dist/components/singleUser/SingleUser.stories.d.ts +11 -0
- package/dist/components/singleUser/SingleUser.stories.d.ts.map +1 -0
- package/dist/components/singleUser/SingleUser.stories.js +52 -0
- package/dist/components/singleUser/SingleUser.stories.js.map +1 -0
- package/dist/components/singleUser/SingleUser.test.d.ts +2 -0
- package/dist/components/singleUser/SingleUser.test.d.ts.map +1 -0
- package/dist/components/singleUser/SingleUser.test.js +30 -0
- package/dist/components/singleUser/SingleUser.test.js.map +1 -0
- package/dist/components/tabs/TabsItem.stories.d.ts +2 -2
- package/dist/components/tag/Tag.d.ts +9 -6
- package/dist/components/tag/Tag.d.ts.map +1 -1
- package/dist/components/tag/Tag.js +8 -2
- package/dist/components/tag/Tag.js.map +1 -1
- package/dist/components/tag/Tag.stories.d.ts +11 -6
- package/dist/components/tag/Tag.stories.d.ts.map +1 -1
- package/dist/components/tag/Tag.stories.js +68 -4
- package/dist/components/tag/Tag.stories.js.map +1 -1
- package/dist/components/tag/Tag.test.js +86 -50
- package/dist/components/tag/Tag.test.js.map +1 -1
- package/dist/components/toggle/Toggle.d.ts +3 -0
- package/dist/components/toggle/Toggle.d.ts.map +1 -0
- package/dist/components/toggle/Toggle.js +8 -0
- package/dist/components/toggle/Toggle.js.map +1 -0
- package/dist/components/toggle/Toggle.stories.d.ts +97 -0
- package/dist/components/toggle/Toggle.stories.d.ts.map +1 -0
- package/dist/components/toggle/Toggle.stories.js +186 -0
- package/dist/components/toggle/Toggle.stories.js.map +1 -0
- package/dist/components/toggle/Toggle.test.d.ts +2 -0
- package/dist/components/toggle/Toggle.test.d.ts.map +1 -0
- package/dist/components/toggle/Toggle.test.js +58 -0
- package/dist/components/toggle/Toggle.test.js.map +1 -0
- package/dist/index.css +656 -25
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +34 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -25
- package/dist/index.js.map +1 -1
- package/dist/mocks/comboboxStoryOptions.d.ts +5 -0
- package/dist/mocks/comboboxStoryOptions.d.ts.map +1 -0
- package/dist/mocks/comboboxStoryOptions.js +22 -0
- package/dist/mocks/comboboxStoryOptions.js.map +1 -0
- package/dist/utils/isSelectAllChord.d.ts +5 -0
- package/dist/utils/isSelectAllChord.d.ts.map +1 -0
- package/dist/utils/isSelectAllChord.js +7 -0
- package/dist/utils/isSelectAllChord.js.map +1 -0
- package/dist/utils/isSelectAllChord.test.d.ts +2 -0
- package/dist/utils/isSelectAllChord.test.d.ts.map +1 -0
- package/dist/utils/isSelectAllChord.test.js +19 -0
- package/dist/utils/isSelectAllChord.test.js.map +1 -0
- package/dist/utils/nextCircularIndex.d.ts +3 -0
- package/dist/utils/nextCircularIndex.d.ts.map +1 -0
- package/dist/utils/nextCircularIndex.js +10 -0
- package/dist/utils/nextCircularIndex.js.map +1 -0
- package/dist/utils/nextCircularIndex.test.d.ts +2 -0
- package/dist/utils/nextCircularIndex.test.d.ts.map +1 -0
- package/dist/utils/nextCircularIndex.test.js +23 -0
- package/dist/utils/nextCircularIndex.test.js.map +1 -0
- package/dist/utils/scrollElementIntoViewById.d.ts +2 -0
- package/dist/utils/scrollElementIntoViewById.d.ts.map +1 -0
- package/dist/utils/scrollElementIntoViewById.js +16 -0
- package/dist/utils/scrollElementIntoViewById.js.map +1 -0
- package/dist/utils/scrollElementIntoViewById.test.d.ts +2 -0
- package/dist/utils/scrollElementIntoViewById.test.d.ts.map +1 -0
- package/dist/utils/scrollElementIntoViewById.test.js +31 -0
- package/dist/utils/scrollElementIntoViewById.test.js.map +1 -0
- package/package.json +1 -1
- package/src/components/avatar/Avatar.stories.tsx +8 -0
- package/src/components/avatar/Avatar.tsx +3 -3
- package/src/components/badge/Badge.stories.tsx +74 -0
- package/src/components/badge/Badge.test.tsx +28 -0
- package/src/components/badge/Badge.tsx +35 -0
- package/src/components/badge/badge.scss +86 -0
- package/src/components/card/Card.tsx +1 -1
- package/src/components/combobox/Combobox.stories.tsx +340 -0
- package/src/components/combobox/Combobox.test.tsx +1160 -0
- package/src/components/combobox/Combobox.tsx +434 -0
- package/src/components/combobox/ComboboxButtonTrigger.tsx +195 -0
- package/src/components/combobox/ComboboxListbox.tsx +224 -0
- package/src/components/combobox/ComboboxOptionRow.tsx +128 -0
- package/src/components/combobox/ComboboxTrigger.tsx +134 -0
- package/src/components/combobox/buildListboxDisplayOptions.test.ts +24 -0
- package/src/components/combobox/buildListboxDisplayOptions.ts +12 -0
- package/src/components/combobox/combobox.scss +390 -0
- package/src/components/combobox/comboboxKeyboardTypes.ts +45 -0
- package/src/components/combobox/highlightLabel.tsx +42 -0
- package/src/components/combobox/normaliseComboboxQuery.ts +1 -0
- package/src/components/combobox/types.ts +53 -0
- package/src/components/combobox/useChipSelection.ts +53 -0
- package/src/components/combobox/useComboboxChipKeyboard.test.tsx +141 -0
- package/src/components/combobox/useComboboxChipKeyboard.ts +121 -0
- package/src/components/combobox/useComboboxKeyboard.ts +108 -0
- package/src/components/combobox/useComboboxListboxDom.ts +36 -0
- package/src/components/combobox/useComboboxListboxKeyboard.test.tsx +186 -0
- package/src/components/combobox/useComboboxListboxKeyboard.ts +172 -0
- package/src/components/combobox/useComboboxPopoverBehavior.ts +179 -0
- package/src/components/combobox/useComboboxState.ts +232 -0
- package/src/components/combobox/useElementWidth.ts +40 -0
- package/src/components/combobox/useVisibleChips.test.tsx +91 -0
- package/src/components/combobox/useVisibleChips.ts +100 -0
- package/src/components/dot/Dot.stories.tsx +41 -0
- package/src/components/dot/Dot.test.tsx +21 -0
- package/src/components/dot/Dot.tsx +18 -0
- package/src/components/dot/dot.scss +35 -0
- package/src/components/formField/FormField.stories.tsx +30 -1
- package/src/components/formField/FormField.test.tsx +20 -0
- package/src/components/formField/FormField.tsx +11 -5
- package/src/components/formField/inputs/number/numberInput.scss +12 -4
- package/src/components/icon/allowedIcons.tsx +2 -0
- package/src/components/pill/pill.scss +4 -6
- package/src/components/singleUser/SingleUser.stories.tsx +63 -0
- package/src/components/singleUser/SingleUser.test.tsx +61 -0
- package/src/components/singleUser/SingleUser.tsx +45 -0
- package/src/components/singleUser/singleUser.scss +14 -0
- package/src/components/tag/Tag.stories.tsx +88 -6
- package/src/components/tag/Tag.test.tsx +110 -44
- package/src/components/tag/Tag.tsx +38 -14
- package/src/components/tag/tag.scss +45 -30
- package/src/components/toggle/Toggle.stories.tsx +239 -0
- package/src/components/toggle/Toggle.test.tsx +66 -0
- package/src/components/toggle/Toggle.tsx +12 -0
- package/src/components/toggle/toggle.scss +126 -0
- package/src/index.scss +5 -0
- package/src/index.ts +47 -31
- package/src/mocks/comboboxStoryOptions.ts +25 -0
- package/src/tokens.scss +33 -4
- package/src/utils/isSelectAllChord.test.ts +24 -0
- package/src/utils/isSelectAllChord.ts +8 -0
- package/src/utils/nextCircularIndex.test.ts +26 -0
- package/src/utils/nextCircularIndex.ts +15 -0
- package/src/utils/scrollElementIntoViewById.test.ts +38 -0
- package/src/utils/scrollElementIntoViewById.ts +20 -0
- package/tokens/json/Arbor.json +3828 -3704
|
@@ -27,15 +27,61 @@ declare const meta: {
|
|
|
27
27
|
value?: number | null | undefined | undefined;
|
|
28
28
|
max?: number | undefined;
|
|
29
29
|
getValueLabel?: ((value: number, max: number) => string) | undefined;
|
|
30
|
-
color?: string | undefined | undefined;
|
|
31
|
-
role?: import("react").AriaRole | undefined;
|
|
32
30
|
className?: string | undefined | undefined;
|
|
33
|
-
|
|
31
|
+
defaultChecked?: boolean | undefined | undefined;
|
|
32
|
+
defaultValue?: string | number | readonly string[] | undefined;
|
|
33
|
+
suppressContentEditableWarning?: boolean | undefined | undefined;
|
|
34
34
|
suppressHydrationWarning?: boolean | undefined | undefined;
|
|
35
|
+
accessKey?: string | undefined | undefined;
|
|
36
|
+
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {}) | undefined;
|
|
37
|
+
autoFocus?: boolean | undefined | undefined;
|
|
38
|
+
contentEditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only" | undefined;
|
|
39
|
+
contextMenu?: string | undefined | undefined;
|
|
40
|
+
dir?: string | undefined | undefined;
|
|
41
|
+
draggable?: (boolean | "true" | "false") | undefined;
|
|
42
|
+
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
|
|
43
|
+
hidden?: boolean | undefined | undefined;
|
|
35
44
|
id?: string | undefined | undefined;
|
|
36
45
|
lang?: string | undefined | undefined;
|
|
46
|
+
nonce?: string | undefined | undefined;
|
|
47
|
+
slot?: string | undefined | undefined;
|
|
48
|
+
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
37
49
|
style?: import("react").CSSProperties | undefined;
|
|
38
50
|
tabIndex?: number | undefined | undefined;
|
|
51
|
+
title?: string | undefined | undefined;
|
|
52
|
+
translate?: "yes" | "no" | undefined | undefined;
|
|
53
|
+
radioGroup?: string | undefined | undefined;
|
|
54
|
+
role?: import("react").AriaRole | undefined;
|
|
55
|
+
about?: string | undefined | undefined;
|
|
56
|
+
content?: string | undefined | undefined;
|
|
57
|
+
datatype?: string | undefined | undefined;
|
|
58
|
+
inlist?: any;
|
|
59
|
+
prefix?: string | undefined | undefined;
|
|
60
|
+
property?: string | undefined | undefined;
|
|
61
|
+
rel?: string | undefined | undefined;
|
|
62
|
+
resource?: string | undefined | undefined;
|
|
63
|
+
rev?: string | undefined | undefined;
|
|
64
|
+
typeof?: string | undefined | undefined;
|
|
65
|
+
vocab?: string | undefined | undefined;
|
|
66
|
+
autoCorrect?: string | undefined | undefined;
|
|
67
|
+
autoSave?: string | undefined | undefined;
|
|
68
|
+
color?: string | undefined | undefined;
|
|
69
|
+
itemProp?: string | undefined | undefined;
|
|
70
|
+
itemScope?: boolean | undefined | undefined;
|
|
71
|
+
itemType?: string | undefined | undefined;
|
|
72
|
+
itemID?: string | undefined | undefined;
|
|
73
|
+
itemRef?: string | undefined | undefined;
|
|
74
|
+
results?: number | undefined | undefined;
|
|
75
|
+
security?: string | undefined | undefined;
|
|
76
|
+
unselectable?: "on" | "off" | undefined | undefined;
|
|
77
|
+
popover?: "" | "auto" | "manual" | undefined | undefined;
|
|
78
|
+
popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
|
|
79
|
+
popoverTarget?: string | undefined | undefined;
|
|
80
|
+
inert?: boolean | undefined | undefined;
|
|
81
|
+
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
|
|
82
|
+
is?: string | undefined | undefined;
|
|
83
|
+
exportparts?: string | undefined | undefined;
|
|
84
|
+
part?: string | undefined | undefined;
|
|
39
85
|
"aria-activedescendant"?: string | undefined | undefined;
|
|
40
86
|
"aria-atomic"?: (boolean | "true" | "false") | undefined;
|
|
41
87
|
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
|
|
@@ -262,52 +308,6 @@ declare const meta: {
|
|
|
262
308
|
onTransitionStart?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
|
|
263
309
|
onTransitionStartCapture?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
|
|
264
310
|
key?: import("react").Key | null | undefined;
|
|
265
|
-
defaultChecked?: boolean | undefined | undefined;
|
|
266
|
-
defaultValue?: string | number | readonly string[] | undefined;
|
|
267
|
-
suppressContentEditableWarning?: boolean | undefined | undefined;
|
|
268
|
-
accessKey?: string | undefined | undefined;
|
|
269
|
-
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {}) | undefined;
|
|
270
|
-
autoFocus?: boolean | undefined | undefined;
|
|
271
|
-
contentEditable?: "inherit" | (boolean | "true" | "false") | "plaintext-only" | undefined;
|
|
272
|
-
contextMenu?: string | undefined | undefined;
|
|
273
|
-
dir?: string | undefined | undefined;
|
|
274
|
-
draggable?: (boolean | "true" | "false") | undefined;
|
|
275
|
-
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
|
|
276
|
-
hidden?: boolean | undefined | undefined;
|
|
277
|
-
nonce?: string | undefined | undefined;
|
|
278
|
-
slot?: string | undefined | undefined;
|
|
279
|
-
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
280
|
-
title?: string | undefined | undefined;
|
|
281
|
-
translate?: "yes" | "no" | undefined | undefined;
|
|
282
|
-
radioGroup?: string | undefined | undefined;
|
|
283
|
-
about?: string | undefined | undefined;
|
|
284
|
-
content?: string | undefined | undefined;
|
|
285
|
-
datatype?: string | undefined | undefined;
|
|
286
|
-
inlist?: any;
|
|
287
|
-
property?: string | undefined | undefined;
|
|
288
|
-
rel?: string | undefined | undefined;
|
|
289
|
-
resource?: string | undefined | undefined;
|
|
290
|
-
rev?: string | undefined | undefined;
|
|
291
|
-
typeof?: string | undefined | undefined;
|
|
292
|
-
vocab?: string | undefined | undefined;
|
|
293
|
-
autoCorrect?: string | undefined | undefined;
|
|
294
|
-
autoSave?: string | undefined | undefined;
|
|
295
|
-
itemProp?: string | undefined | undefined;
|
|
296
|
-
itemScope?: boolean | undefined | undefined;
|
|
297
|
-
itemType?: string | undefined | undefined;
|
|
298
|
-
itemID?: string | undefined | undefined;
|
|
299
|
-
itemRef?: string | undefined | undefined;
|
|
300
|
-
results?: number | undefined | undefined;
|
|
301
|
-
security?: string | undefined | undefined;
|
|
302
|
-
unselectable?: "on" | "off" | undefined | undefined;
|
|
303
|
-
popover?: "" | "auto" | "manual" | undefined | undefined;
|
|
304
|
-
popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
|
|
305
|
-
popoverTarget?: string | undefined | undefined;
|
|
306
|
-
inert?: boolean | undefined | undefined;
|
|
307
|
-
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
|
|
308
|
-
is?: string | undefined | undefined;
|
|
309
|
-
exportparts?: string | undefined | undefined;
|
|
310
|
-
part?: string | undefined | undefined;
|
|
311
311
|
asChild?: boolean | undefined;
|
|
312
312
|
indicatorClassName?: string | undefined;
|
|
313
313
|
}>) => import("react/jsx-runtime").JSX.Element)[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AvatarProps, type AvatarSize } from '../avatar/Avatar';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type SingleUserProps = {
|
|
4
|
+
label: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
avatarClassName?: string;
|
|
7
|
+
size?: AvatarSize;
|
|
8
|
+
} & Omit<AvatarProps, 'className' | 'alt' | 'size'>;
|
|
9
|
+
export declare const SingleUser: React.ForwardRefExoticComponent<{
|
|
10
|
+
label: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
avatarClassName?: string;
|
|
13
|
+
size?: AvatarSize;
|
|
14
|
+
} & Omit<AvatarProps, "size" | "alt" | "className"> & React.RefAttributes<HTMLSpanElement>>;
|
|
15
|
+
//# sourceMappingURL=SingleUser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleUser.d.ts","sourceRoot":"","sources":["../../../src/components/singleUser/SingleUser.tsx"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;AAEpD,eAAO,MAAM,UAAU;WANd,MAAM;gBACD,MAAM;sBACA,MAAM;WACjB,UAAU;2FAkClB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { Avatar } from '../avatar/Avatar';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export const SingleUser = React.forwardRef(({ label, className, avatarClassName, size = 'small', ...avatarProps }, ref) => {
|
|
6
|
+
return (_jsxs("span", { ref: ref, className: classNames('ds-single-user', className), children: [_jsx(Avatar, { ...avatarProps, size: size, "aria-hidden": "true", alt: "", className: avatarClassName }), _jsx("span", { className: "ds-single-user__label", children: label })] }));
|
|
7
|
+
});
|
|
8
|
+
SingleUser.displayName = 'SingleUser';
|
|
9
|
+
//# sourceMappingURL=SingleUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleUser.js","sourceRoot":"","sources":["../../../src/components/singleUser/SingleUser.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,MAAM,EAAqC,MAAM,0BAA0B,CAAC;AACrF,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CACxC,CACE,EACE,KAAK,EACL,SAAS,EACT,eAAe,EACf,IAAI,GAAG,OAAO,EACd,GAAG,WAAW,EACf,EACD,GAAG,EACH,EAAE;IACF,OAAO,CACL,gBACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,aAGlD,KAAC,MAAM,OACD,WAAW,EACf,IAAI,EAAE,IAAI,iBACE,MAAM,EAClB,GAAG,EAAC,EAAE,EACN,SAAS,EAAE,eAAe,GAC1B,EAEF,eAAM,SAAS,EAAC,uBAAuB,YACpC,KAAK,GACD,IACF,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { SingleUser } from './SingleUser';
|
|
3
|
+
declare const meta: Meta<typeof SingleUser>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SingleUser>;
|
|
6
|
+
export declare const WithImage: Story;
|
|
7
|
+
export declare const WithInitials: Story;
|
|
8
|
+
export declare const Placeholder: Story;
|
|
9
|
+
export declare const MediumAvatar: Story;
|
|
10
|
+
export declare const LongLabel: Story;
|
|
11
|
+
//# sourceMappingURL=SingleUser.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleUser.stories.d.ts","sourceRoot":"","sources":["../../../src/components/singleUser/SingleUser.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CAIjC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,UAAU,CAAC,CAAC;AAiBzC,eAAO,MAAM,SAAS,EAAE,KAKsD,CAAC;AAE/E,eAAO,MAAM,YAAY,EAAE,KAK0B,CAAC;AAEtD,eAAO,MAAM,WAAW,EAAE,KAIgE,CAAC;AAE3F,eAAO,MAAM,YAAY,EAAE,KAOsD,CAAC;AAElF,eAAO,MAAM,SAAS,EAAE,KAKuE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SingleUser } from './SingleUser';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Components/SingleUser',
|
|
4
|
+
component: SingleUser,
|
|
5
|
+
tags: ['autodocs'],
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
const withDescription = (story, description) => ({
|
|
9
|
+
...story,
|
|
10
|
+
parameters: {
|
|
11
|
+
...story.parameters,
|
|
12
|
+
docs: {
|
|
13
|
+
...story.parameters?.docs,
|
|
14
|
+
description: {
|
|
15
|
+
story: description,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const sampleSrc = 'https://i.pravatar.cc/150?img=12';
|
|
21
|
+
export const WithImage = withDescription({
|
|
22
|
+
args: {
|
|
23
|
+
label: 'Jordan Matthews',
|
|
24
|
+
src: sampleSrc,
|
|
25
|
+
},
|
|
26
|
+
}, 'Displays `SingleUser` with an avatar image and the default small layout.');
|
|
27
|
+
export const WithInitials = withDescription({
|
|
28
|
+
args: {
|
|
29
|
+
label: 'Riley Chen',
|
|
30
|
+
initials: 'RC',
|
|
31
|
+
},
|
|
32
|
+
}, 'Uses initials when no image source is provided.');
|
|
33
|
+
export const Placeholder = withDescription({
|
|
34
|
+
args: {
|
|
35
|
+
label: 'Invited user',
|
|
36
|
+
},
|
|
37
|
+
}, 'Shows the placeholder avatar treatment when neither image nor initials are supplied.');
|
|
38
|
+
export const MediumAvatar = withDescription({
|
|
39
|
+
name: 'Size override (medium)',
|
|
40
|
+
args: {
|
|
41
|
+
label: 'Taylor Brooks',
|
|
42
|
+
initials: 'TB',
|
|
43
|
+
size: 'medium',
|
|
44
|
+
},
|
|
45
|
+
}, 'Demonstrates overriding the default avatar size within the SingleUser pill.');
|
|
46
|
+
export const LongLabel = withDescription({
|
|
47
|
+
args: {
|
|
48
|
+
label: 'Dr. Alexandrina Constantinopolous-Worthington',
|
|
49
|
+
initials: 'AC',
|
|
50
|
+
},
|
|
51
|
+
}, 'Exercises the component with a longer label so text wrapping and spacing can be reviewed.');
|
|
52
|
+
//# sourceMappingURL=SingleUser.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleUser.stories.js","sourceRoot":"","sources":["../../../src/components/singleUser/SingleUser.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,IAAI,GAA4B;IACpC,KAAK,EAAE,uBAAuB;IAC9B,SAAS,EAAE,UAAU;IACrB,IAAI,EAAE,CAAC,UAAU,CAAC;CACnB,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,eAAe,GAAG,CAAC,KAAY,EAAE,WAAmB,EAAS,EAAE,CAAC,CAAC;IACrE,GAAG,KAAK;IACR,UAAU,EAAE;QACV,GAAG,KAAK,CAAC,UAAU;QACnB,IAAI,EAAE;YACJ,GAAG,KAAK,CAAC,UAAU,EAAE,IAAI;YACzB,WAAW,EAAE;gBACX,KAAK,EAAE,WAAW;aACnB;SACF;KACF;CACF,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,kCAAkC,CAAC;AAErD,MAAM,CAAC,MAAM,SAAS,GAAU,eAAe,CAAC;IAC9C,IAAI,EAAE;QACJ,KAAK,EAAE,iBAAiB;QACxB,GAAG,EAAE,SAAS;KACf;CACF,EAAE,0EAA0E,CAAC,CAAC;AAE/E,MAAM,CAAC,MAAM,YAAY,GAAU,eAAe,CAAC;IACjD,IAAI,EAAE;QACJ,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE,IAAI;KACf;CACF,EAAE,iDAAiD,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,WAAW,GAAU,eAAe,CAAC;IAChD,IAAI,EAAE;QACJ,KAAK,EAAE,cAAc;KACtB;CACF,EAAE,sFAAsF,CAAC,CAAC;AAE3F,MAAM,CAAC,MAAM,YAAY,GAAU,eAAe,CAAC;IACjD,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE;QACJ,KAAK,EAAE,eAAe;QACtB,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,QAAQ;KACf;CACF,EAAE,6EAA6E,CAAC,CAAC;AAElF,MAAM,CAAC,MAAM,SAAS,GAAU,eAAe,CAAC;IAC9C,IAAI,EAAE;QACJ,KAAK,EAAE,+CAA+C;QACtD,QAAQ,EAAE,IAAI;KACf;CACF,EAAE,2FAA2F,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleUser.test.d.ts","sourceRoot":"","sources":["../../../src/components/singleUser/SingleUser.test.tsx"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import '@testing-library/jest-dom/vitest';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { describe, expect, test } from 'vitest';
|
|
5
|
+
import { SingleUser } from './SingleUser';
|
|
6
|
+
describe('SingleUser', () => {
|
|
7
|
+
test('renders label text', () => {
|
|
8
|
+
render(_jsx(SingleUser, { label: "Jamie Smith", initials: "JS" }));
|
|
9
|
+
expect(screen.getByText('Jamie Smith')).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
test('hides Avatar from screen readers', () => {
|
|
12
|
+
const { container } = render(_jsx(SingleUser, { label: "Pat Lee", initials: "PL" }));
|
|
13
|
+
const avatar = container.querySelector('.ds-avatar');
|
|
14
|
+
expect(avatar).toHaveAttribute('aria-hidden', 'true');
|
|
15
|
+
});
|
|
16
|
+
test('defaults Avatar to small size', () => {
|
|
17
|
+
const { container } = render(_jsx(SingleUser, { label: "Sam", initials: "S" }));
|
|
18
|
+
expect(container.querySelector('.ds-avatar--small')).toBeInTheDocument();
|
|
19
|
+
});
|
|
20
|
+
test('allows size override', () => {
|
|
21
|
+
const { container } = render(_jsx(SingleUser, { label: "Sam", initials: "S", size: "medium" }));
|
|
22
|
+
expect(container.querySelector('.ds-avatar--medium')).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
test('applies className to root and avatarClassName to Avatar', () => {
|
|
25
|
+
const { container } = render(_jsx(SingleUser, { label: "User", initials: "U", className: "my-chip", avatarClassName: "my-avatar" }));
|
|
26
|
+
expect(container.querySelector('.ds-single-user.my-chip')).toBeInTheDocument();
|
|
27
|
+
expect(container.querySelector('.ds-avatar.my-avatar')).toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=SingleUser.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleUser.test.js","sourceRoot":"","sources":["../../../src/components/singleUser/SingleUser.test.tsx"],"names":[],"mappings":";AAAA,OAAO,kCAAkC,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAC9B,MAAM,CACJ,KAAC,UAAU,IACT,KAAK,EAAC,aAAa,EACnB,QAAQ,EAAC,IAAI,GACb,CACH,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC5C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,UAAU,IACT,KAAK,EAAC,SAAS,EACf,QAAQ,EAAC,IAAI,GACb,CACH,CAAC;QACF,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QACrD,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACzC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,UAAU,IACT,KAAK,EAAC,KAAK,EACX,QAAQ,EAAC,GAAG,GACZ,CACH,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC3E,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAChC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,UAAU,IACT,KAAK,EAAC,KAAK,EACX,QAAQ,EAAC,GAAG,EACZ,IAAI,EAAC,QAAQ,GACb,CACH,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACnE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,UAAU,IACT,KAAK,EAAC,MAAM,EACZ,QAAQ,EAAC,GAAG,EACZ,SAAS,EAAC,SAAS,EACnB,eAAe,EAAC,WAAW,GAC3B,CACH,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC/E,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -25,7 +25,7 @@ declare const meta: {
|
|
|
25
25
|
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {}) | undefined;
|
|
26
26
|
autoFocus?: boolean | undefined | undefined;
|
|
27
27
|
className?: string | undefined | undefined;
|
|
28
|
-
contentEditable?:
|
|
28
|
+
contentEditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only" | undefined;
|
|
29
29
|
contextMenu?: string | undefined | undefined;
|
|
30
30
|
dir?: string | undefined | undefined;
|
|
31
31
|
draggable?: (boolean | "true" | "false") | undefined;
|
|
@@ -310,7 +310,7 @@ declare const meta: {
|
|
|
310
310
|
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {}) | undefined;
|
|
311
311
|
autoFocus?: boolean | undefined | undefined;
|
|
312
312
|
className?: string | undefined | undefined;
|
|
313
|
-
contentEditable?:
|
|
313
|
+
contentEditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only" | undefined;
|
|
314
314
|
contextMenu?: string | undefined | undefined;
|
|
315
315
|
dir?: string | undefined | undefined;
|
|
316
316
|
draggable?: (boolean | "true" | "false") | undefined;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export type TagColor = 'neutral' | 'orange' | 'blue' | 'green' | 'purple' | 'teal' | 'salmon' | 'yellow';
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
text: string;
|
|
2
|
+
export type TagProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
5
4
|
color?: TagColor;
|
|
6
|
-
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
slotStart?: React.ReactNode;
|
|
7
|
+
slotEnd?: React.ReactNode;
|
|
8
|
+
onRemove?: () => void;
|
|
9
|
+
removeLabel?: string;
|
|
10
|
+
removeButtonTabIndex?: 0 | -1;
|
|
7
11
|
};
|
|
8
|
-
export declare const Tag: ({
|
|
9
|
-
export {};
|
|
12
|
+
export declare const Tag: ({ children, color, selected, slotStart, slotEnd, onRemove, removeLabel, removeButtonTabIndex, }: TagProps) => React.JSX.Element;
|
|
10
13
|
//# sourceMappingURL=Tag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["../../../src/components/tag/Tag.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["../../../src/components/tag/Tag.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,QAAQ,GAAG,SAAS,GAC5B,QAAQ,GACR,MAAM,GACN,OAAO,GACP,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,QAAQ,CAAC;AAEb,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,GAAG,GAAI,iGASjB,QAAQ,KAAG,KAAK,CAAC,GAAG,CAAC,OAyBvB,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { Icon } from '../icon/Icon';
|
|
4
|
+
export const Tag = ({ children, color = 'neutral', selected = false, slotStart, slotEnd, onRemove, removeLabel = 'Remove', removeButtonTabIndex = 0, }) => {
|
|
5
|
+
return (_jsxs("span", { className: classNames('ds-tag', `ds-tag--${color}`, {
|
|
6
|
+
'ds-tag--selected': selected,
|
|
7
|
+
}), children: [slotStart && _jsx("span", { className: "ds-tag__slot-start", children: slotStart }), _jsx("span", { className: "ds-tag__label", children: children }), slotEnd && _jsx("span", { className: "ds-tag__slot-end", children: slotEnd }), onRemove && (_jsx("button", { type: "button", className: "ds-tag__remove", "aria-label": removeLabel, onClick: (e) => {
|
|
8
|
+
e.stopPropagation();
|
|
9
|
+
onRemove();
|
|
10
|
+
}, tabIndex: removeButtonTabIndex, children: _jsx(Icon, { name: "x", size: 12 }) }))] }));
|
|
5
11
|
};
|
|
6
12
|
//# sourceMappingURL=Tag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../../src/components/tag/Tag.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../../src/components/tag/Tag.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAsB5C,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,EAClB,QAAQ,EACR,KAAK,GAAG,SAAS,EACjB,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,WAAW,GAAG,QAAQ,EACtB,oBAAoB,GAAG,CAAC,GACf,EAAqB,EAAE;IAChC,OAAO,CACL,gBAAM,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,WAAW,KAAK,EAAE,EAAE;YACxD,kBAAkB,EAAE,QAAQ;SAC7B,CAAC,aAEC,SAAS,IAAI,eAAM,SAAS,EAAC,oBAAoB,YAAE,SAAS,GAAQ,EACrE,eAAM,SAAS,EAAC,eAAe,YAAE,QAAQ,GAAQ,EAChD,OAAO,IAAI,eAAM,SAAS,EAAC,kBAAkB,YAAE,OAAO,GAAQ,EAC9D,QAAQ,IAAI,CACX,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,gBAAgB,gBACd,WAAW,EACvB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAC;oBACpB,QAAQ,EAAE,CAAC;gBACb,CAAC,EACD,QAAQ,EAAE,oBAAoB,YAE9B,KAAC,IAAI,IAAC,IAAI,EAAC,GAAG,EAAC,IAAI,EAAE,EAAE,GAAI,GACpB,CACV,IACI,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import type { Meta } from '@storybook/react-vite';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { Tag } from './Tag';
|
|
3
3
|
declare const meta: Meta<typeof Tag>;
|
|
4
|
-
export declare const Default: {
|
|
5
|
-
args: {
|
|
6
|
-
text: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
4
|
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Tag>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithColour: Story;
|
|
8
|
+
export declare const Selected: Story;
|
|
9
|
+
export declare const WithDot: Story;
|
|
10
|
+
export declare const WithIcon: Story;
|
|
11
|
+
export declare const Removable: Story;
|
|
12
|
+
export declare const RemovableWithIcon: Story;
|
|
13
|
+
export declare const WithSlotEnd: Story;
|
|
14
|
+
export declare const AllColours: Story;
|
|
10
15
|
//# sourceMappingURL=Tag.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.stories.d.ts","sourceRoot":"","sources":["../../../src/components/tag/Tag.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"Tag.stories.d.ts","sourceRoot":"","sources":["../../../src/components/tag/Tag.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAI5D,OAAO,EAAE,GAAG,EAAiB,MAAM,OAAO,CAAC;AAE3C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,GAAG,CAY1B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,GAAG,CAAC,CAAC;AAelC,eAAO,MAAM,OAAO,EAAE,KAEsC,CAAC;AAE7D,eAAO,MAAM,UAAU,EAAE,KAEoC,CAAC;AAE9D,eAAO,MAAM,QAAQ,EAAE,KAE4F,CAAC;AAEpH,eAAO,MAAM,OAAO,EAAE,KAK6C,CAAC;AAEpE,eAAO,MAAM,QAAQ,EAAE,KAKqC,CAAC;AAE7D,eAAO,MAAM,SAAS,EAAE,KAM4H,CAAC;AAErJ,eAAO,MAAM,iBAAiB,EAAE,KAOiC,CAAC;AAElE,eAAO,MAAM,WAAW,EAAE,KAK6B,CAAC;AAIxD,eAAO,MAAM,UAAU,EAAE,KAQsC,CAAC"}
|
|
@@ -1,13 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fn } from '@storybook/test';
|
|
3
|
+
import { Dot } from '../dot/Dot';
|
|
4
|
+
import { Icon } from '../icon/Icon';
|
|
1
5
|
import { Tag } from './Tag';
|
|
2
6
|
const meta = {
|
|
3
7
|
tags: ['autodocs'],
|
|
4
8
|
title: 'Components/Tag',
|
|
5
9
|
component: Tag,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component: 'Displays compact tag content with optional start/end slots and removable actions. Removable tags keep their remove button in the tab order by default; composite parents such as Combobox can pass `removeButtonTabIndex={-1}` for roving tab focus.',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
10
16
|
},
|
|
11
17
|
};
|
|
12
18
|
export default meta;
|
|
19
|
+
const withDescription = (story, description) => ({
|
|
20
|
+
...story,
|
|
21
|
+
parameters: {
|
|
22
|
+
...story.parameters,
|
|
23
|
+
docs: {
|
|
24
|
+
...story.parameters?.docs,
|
|
25
|
+
description: {
|
|
26
|
+
story: description,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
export const Default = withDescription({
|
|
32
|
+
args: { children: 'Tag content' },
|
|
33
|
+
}, 'Shows the default neutral Tag with plain text content.');
|
|
34
|
+
export const WithColour = withDescription({
|
|
35
|
+
args: { children: 'Blue tag', color: 'blue' },
|
|
36
|
+
}, 'Applies one of the semantic colour variants to the Tag.');
|
|
37
|
+
export const Selected = withDescription({
|
|
38
|
+
args: { children: 'Selected tag', color: 'blue', selected: true },
|
|
39
|
+
}, 'Shows the selected treatment, which intentionally prioritises selection styling over the base colour variant.');
|
|
40
|
+
export const WithDot = withDescription({
|
|
41
|
+
args: {
|
|
42
|
+
children: 'With dot',
|
|
43
|
+
slotStart: _jsx(Dot, { colour: "purple" }),
|
|
44
|
+
},
|
|
45
|
+
}, 'Uses `slotStart` to render a decorative dot before the label.');
|
|
46
|
+
export const WithIcon = withDescription({
|
|
47
|
+
args: {
|
|
48
|
+
children: 'Alice Johnson',
|
|
49
|
+
slotStart: _jsx(Icon, { name: "user", size: 12 }),
|
|
50
|
+
},
|
|
51
|
+
}, 'Uses `slotStart` to show an icon before the Tag label.');
|
|
52
|
+
export const Removable = withDescription({
|
|
53
|
+
args: {
|
|
54
|
+
children: 'Removable tag',
|
|
55
|
+
onRemove: fn(),
|
|
56
|
+
removeLabel: 'Remove removable tag',
|
|
57
|
+
},
|
|
58
|
+
}, 'Demonstrates a removable Tag with the default close affordance and a custom accessible remove label. The remove button is tabbable by default.');
|
|
59
|
+
export const RemovableWithIcon = withDescription({
|
|
60
|
+
args: {
|
|
61
|
+
children: 'Alice Johnson',
|
|
62
|
+
slotStart: _jsx(Icon, { name: "user", size: 12 }),
|
|
63
|
+
onRemove: fn(),
|
|
64
|
+
removeLabel: 'Remove Alice Johnson',
|
|
65
|
+
},
|
|
66
|
+
}, 'Combines a leading icon with the removable Tag interaction.');
|
|
67
|
+
export const WithSlotEnd = withDescription({
|
|
68
|
+
args: {
|
|
69
|
+
children: 'Custom end',
|
|
70
|
+
slotEnd: _jsx(Icon, { name: "chevron-down", size: 12 }),
|
|
71
|
+
},
|
|
72
|
+
}, 'Uses `slotEnd` to render trailing custom content.');
|
|
73
|
+
const allColours = ['neutral', 'orange', 'blue', 'green', 'purple', 'teal', 'salmon', 'yellow'];
|
|
74
|
+
export const AllColours = withDescription({
|
|
75
|
+
render: () => (_jsx("div", { style: { display: 'flex', flexWrap: 'wrap', gap: 8 }, children: allColours.map(color => (_jsx(Tag, { color: color, children: color }, color))) })),
|
|
76
|
+
}, 'Displays every available Tag colour variant side by side.');
|
|
13
77
|
//# sourceMappingURL=Tag.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.stories.js","sourceRoot":"","sources":["../../../src/components/tag/Tag.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Tag.stories.js","sourceRoot":"","sources":["../../../src/components/tag/Tag.stories.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,57 +1,93 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
3
3
|
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
5
|
import '@testing-library/jest-dom/vitest';
|
|
6
|
+
import { Tag } from './Tag';
|
|
7
|
+
import { Dot } from '../dot/Dot';
|
|
6
8
|
describe('Tag', () => {
|
|
7
|
-
test('
|
|
8
|
-
render(_jsx(Tag, {
|
|
9
|
-
expect(screen.getByText(
|
|
10
|
-
});
|
|
11
|
-
test('
|
|
12
|
-
render(_jsx(Tag, {
|
|
13
|
-
expect(
|
|
14
|
-
});
|
|
15
|
-
test('
|
|
16
|
-
render(_jsx(Tag, {
|
|
17
|
-
expect(
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
test('
|
|
25
|
-
render(_jsx(Tag, {
|
|
26
|
-
expect(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
expect(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
9
|
+
test('renders children as text content', () => {
|
|
10
|
+
render(_jsx(Tag, { children: "Hello" }));
|
|
11
|
+
expect(screen.getByText('Hello')).toBeInTheDocument();
|
|
12
|
+
});
|
|
13
|
+
test('has default color neutral', () => {
|
|
14
|
+
const { container } = render(_jsx(Tag, { children: "Neutral" }));
|
|
15
|
+
expect(container.querySelector('.ds-tag')).toHaveClass('ds-tag--neutral');
|
|
16
|
+
});
|
|
17
|
+
test('applies custom color class', () => {
|
|
18
|
+
const { container } = render(_jsx(Tag, { color: "blue", children: "Blue" }));
|
|
19
|
+
expect(container.querySelector('.ds-tag')).toHaveClass('ds-tag--blue');
|
|
20
|
+
});
|
|
21
|
+
test('applies selected class when selected is true', () => {
|
|
22
|
+
const { container } = render(_jsx(Tag, { selected: true, children: "Selected" }));
|
|
23
|
+
expect(container.querySelector('.ds-tag')).toHaveClass('ds-tag--selected');
|
|
24
|
+
});
|
|
25
|
+
describe('slotStart', () => {
|
|
26
|
+
test('renders slotStart content', () => {
|
|
27
|
+
const { container } = render(_jsx(Tag, { slotStart: _jsx(Dot, { colour: "purple" }), children: "With dot" }));
|
|
28
|
+
expect(container.querySelector('.ds-tag__slot-start .ds-dot--purple')).toBeInTheDocument();
|
|
29
|
+
expect(container.querySelector('.ds-tag__slot-start .ds-dot')).toHaveAttribute('aria-hidden', 'true');
|
|
30
|
+
});
|
|
31
|
+
test('does not render slot-start wrapper when slotStart is not provided', () => {
|
|
32
|
+
const { container } = render(_jsx(Tag, { children: "No slot" }));
|
|
33
|
+
expect(container.querySelector('.ds-tag__slot-start')).not.toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe('slotEnd', () => {
|
|
37
|
+
test('renders slotEnd content', () => {
|
|
38
|
+
const { container } = render(_jsx(Tag, { slotEnd: _jsx("span", { children: "End" }), children: "With end" }));
|
|
39
|
+
expect(container.querySelector('.ds-tag__slot-end')).toHaveTextContent('End');
|
|
40
|
+
});
|
|
41
|
+
test('does not render slot-end wrapper when slotEnd is not provided', () => {
|
|
42
|
+
const { container } = render(_jsx(Tag, { children: "No slot" }));
|
|
43
|
+
expect(container.querySelector('.ds-tag__slot-end')).not.toBeInTheDocument();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('onRemove', () => {
|
|
47
|
+
test('renders remove button when onRemove is provided', () => {
|
|
48
|
+
render(_jsx(Tag, { onRemove: () => { }, children: "Removable" }));
|
|
49
|
+
expect(screen.getByRole('button', { name: 'Remove' })).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
test('uses a custom remove label when provided', () => {
|
|
52
|
+
render(_jsx(Tag, { onRemove: () => { }, removeLabel: "Remove Alice Johnson", children: "Removable" }));
|
|
53
|
+
expect(screen.getByRole('button', { name: 'Remove Alice Johnson' })).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
test('keeps the remove button in the tab order by default', () => {
|
|
56
|
+
render(_jsx(Tag, { onRemove: () => { }, children: "Removable" }));
|
|
57
|
+
expect(screen.getByRole('button', { name: 'Remove' })).toHaveAttribute('tabindex', '0');
|
|
58
|
+
});
|
|
59
|
+
test('allows composite parents to remove the button from the tab order', () => {
|
|
60
|
+
render(_jsx(Tag, { onRemove: () => { }, removeButtonTabIndex: -1, children: "Removable" }));
|
|
61
|
+
expect(screen.getByRole('button', { name: 'Remove' })).toHaveAttribute('tabindex', '-1');
|
|
62
|
+
});
|
|
63
|
+
test('does not render remove button when onRemove is not provided', () => {
|
|
64
|
+
render(_jsx(Tag, { children: "Static" }));
|
|
65
|
+
expect(screen.queryByRole('button', { name: 'Remove' })).not.toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
test('fires onRemove callback when close button is clicked', async () => {
|
|
68
|
+
const onRemove = vi.fn();
|
|
69
|
+
render(_jsx(Tag, { onRemove: onRemove, children: "Removable" }));
|
|
70
|
+
await userEvent.click(screen.getByRole('button', { name: 'Remove' }));
|
|
71
|
+
expect(onRemove).toHaveBeenCalledOnce();
|
|
72
|
+
});
|
|
73
|
+
test('stops event propagation on remove click', async () => {
|
|
74
|
+
const onRemove = vi.fn();
|
|
75
|
+
const outerClick = vi.fn();
|
|
76
|
+
render(_jsx("div", { onClick: outerClick, children: _jsx(Tag, { onRemove: onRemove, children: "Removable" }) }));
|
|
77
|
+
await userEvent.click(screen.getByRole('button', { name: 'Remove' }));
|
|
78
|
+
expect(onRemove).toHaveBeenCalledOnce();
|
|
79
|
+
expect(outerClick).not.toHaveBeenCalled();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('combined slots', () => {
|
|
83
|
+
test('renders slotStart, children, slotEnd, and remove button in correct order', () => {
|
|
84
|
+
const { container } = render(_jsx(Tag, { slotStart: _jsx("span", { children: "S" }), slotEnd: _jsx("span", { children: "E" }), onRemove: () => { }, children: "Label" }));
|
|
85
|
+
const tag = container.querySelector('.ds-tag');
|
|
86
|
+
const children = Array.from(tag.children);
|
|
87
|
+
expect(children[0]).toHaveClass('ds-tag__slot-start');
|
|
88
|
+
expect(children[1]).toHaveClass('ds-tag__label');
|
|
89
|
+
expect(children[2]).toHaveClass('ds-tag__slot-end');
|
|
90
|
+
expect(children[3]).toHaveClass('ds-tag__remove');
|
|
55
91
|
});
|
|
56
92
|
});
|
|
57
93
|
});
|