@salt-ds/lab 1.0.0-alpha.36 → 1.0.0-alpha.37

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.
Files changed (109) hide show
  1. package/css/salt-lab.css +27 -400
  2. package/dist-cjs/calendar/internal/CalendarNavigation.js +4 -8
  3. package/dist-cjs/calendar/internal/CalendarNavigation.js.map +1 -1
  4. package/dist-cjs/combo-box/useCombobox.js.map +1 -1
  5. package/dist-cjs/index.js +2 -8
  6. package/dist-cjs/index.js.map +1 -1
  7. package/dist-cjs/segmented-button-group/SegmentedButtonGroup.css.js +6 -0
  8. package/dist-cjs/segmented-button-group/SegmentedButtonGroup.css.js.map +1 -0
  9. package/dist-cjs/segmented-button-group/SegmentedButtonGroup.js +30 -0
  10. package/dist-cjs/segmented-button-group/SegmentedButtonGroup.js.map +1 -0
  11. package/dist-cjs/tabs-next/TabstripNext.css.js +1 -1
  12. package/dist-es/calendar/internal/CalendarNavigation.js +3 -7
  13. package/dist-es/calendar/internal/CalendarNavigation.js.map +1 -1
  14. package/dist-es/combo-box/useCombobox.js.map +1 -1
  15. package/dist-es/index.js +1 -4
  16. package/dist-es/index.js.map +1 -1
  17. package/dist-es/segmented-button-group/SegmentedButtonGroup.css.js +4 -0
  18. package/dist-es/segmented-button-group/SegmentedButtonGroup.css.js.map +1 -0
  19. package/dist-es/segmented-button-group/SegmentedButtonGroup.js +26 -0
  20. package/dist-es/segmented-button-group/SegmentedButtonGroup.js.map +1 -0
  21. package/dist-es/tabs-next/TabstripNext.css.js +1 -1
  22. package/dist-types/calendar/internal/CalendarNavigation.d.ts +2 -3
  23. package/dist-types/index.d.ts +1 -3
  24. package/dist-types/segmented-button-group/SegmentedButtonGroup.d.ts +4 -0
  25. package/dist-types/segmented-button-group/index.d.ts +1 -0
  26. package/package.json +2 -2
  27. package/dist-cjs/combo-box-next/ComboBoxNext.css.js +0 -6
  28. package/dist-cjs/combo-box-next/ComboBoxNext.css.js.map +0 -1
  29. package/dist-cjs/combo-box-next/ComboBoxNext.js +0 -366
  30. package/dist-cjs/combo-box-next/ComboBoxNext.js.map +0 -1
  31. package/dist-cjs/combo-box-next/useComboBoxNext.js +0 -68
  32. package/dist-cjs/combo-box-next/useComboBoxNext.js.map +0 -1
  33. package/dist-cjs/dropdown-next/DropdownNext.css.js +0 -6
  34. package/dist-cjs/dropdown-next/DropdownNext.css.js.map +0 -1
  35. package/dist-cjs/dropdown-next/DropdownNext.js +0 -335
  36. package/dist-cjs/dropdown-next/DropdownNext.js.map +0 -1
  37. package/dist-cjs/list-control/ListControlContext.js +0 -38
  38. package/dist-cjs/list-control/ListControlContext.js.map +0 -1
  39. package/dist-cjs/list-control/ListControlState.js +0 -192
  40. package/dist-cjs/list-control/ListControlState.js.map +0 -1
  41. package/dist-cjs/option/Option.css.js +0 -6
  42. package/dist-cjs/option/Option.css.js.map +0 -1
  43. package/dist-cjs/option/Option.js +0 -99
  44. package/dist-cjs/option/Option.js.map +0 -1
  45. package/dist-cjs/option/OptionGroup.css.js +0 -6
  46. package/dist-cjs/option/OptionGroup.css.js.map +0 -1
  47. package/dist-cjs/option/OptionGroup.js +0 -44
  48. package/dist-cjs/option/OptionGroup.js.map +0 -1
  49. package/dist-cjs/option/OptionList.css.js +0 -6
  50. package/dist-cjs/option/OptionList.css.js.map +0 -1
  51. package/dist-cjs/option/OptionList.js +0 -40
  52. package/dist-cjs/option/OptionList.js.map +0 -1
  53. package/dist-cjs/pill-input/PillInput.css.js +0 -6
  54. package/dist-cjs/pill-input/PillInput.css.js.map +0 -1
  55. package/dist-cjs/pill-input/PillInput.js +0 -256
  56. package/dist-cjs/pill-input/PillInput.js.map +0 -1
  57. package/dist-cjs/pill-input/useTruncatePills.js +0 -85
  58. package/dist-cjs/pill-input/useTruncatePills.js.map +0 -1
  59. package/dist-cjs/utils/useValueEffect.js +0 -40
  60. package/dist-cjs/utils/useValueEffect.js.map +0 -1
  61. package/dist-es/combo-box-next/ComboBoxNext.css.js +0 -4
  62. package/dist-es/combo-box-next/ComboBoxNext.css.js.map +0 -1
  63. package/dist-es/combo-box-next/ComboBoxNext.js +0 -362
  64. package/dist-es/combo-box-next/ComboBoxNext.js.map +0 -1
  65. package/dist-es/combo-box-next/useComboBoxNext.js +0 -64
  66. package/dist-es/combo-box-next/useComboBoxNext.js.map +0 -1
  67. package/dist-es/dropdown-next/DropdownNext.css.js +0 -4
  68. package/dist-es/dropdown-next/DropdownNext.css.js.map +0 -1
  69. package/dist-es/dropdown-next/DropdownNext.js +0 -331
  70. package/dist-es/dropdown-next/DropdownNext.js.map +0 -1
  71. package/dist-es/list-control/ListControlContext.js +0 -33
  72. package/dist-es/list-control/ListControlContext.js.map +0 -1
  73. package/dist-es/list-control/ListControlState.js +0 -187
  74. package/dist-es/list-control/ListControlState.js.map +0 -1
  75. package/dist-es/option/Option.css.js +0 -4
  76. package/dist-es/option/Option.css.js.map +0 -1
  77. package/dist-es/option/Option.js +0 -95
  78. package/dist-es/option/Option.js.map +0 -1
  79. package/dist-es/option/OptionGroup.css.js +0 -4
  80. package/dist-es/option/OptionGroup.css.js.map +0 -1
  81. package/dist-es/option/OptionGroup.js +0 -40
  82. package/dist-es/option/OptionGroup.js.map +0 -1
  83. package/dist-es/option/OptionList.css.js +0 -4
  84. package/dist-es/option/OptionList.css.js.map +0 -1
  85. package/dist-es/option/OptionList.js +0 -36
  86. package/dist-es/option/OptionList.js.map +0 -1
  87. package/dist-es/pill-input/PillInput.css.js +0 -4
  88. package/dist-es/pill-input/PillInput.css.js.map +0 -1
  89. package/dist-es/pill-input/PillInput.js +0 -252
  90. package/dist-es/pill-input/PillInput.js.map +0 -1
  91. package/dist-es/pill-input/useTruncatePills.js +0 -81
  92. package/dist-es/pill-input/useTruncatePills.js.map +0 -1
  93. package/dist-es/utils/useValueEffect.js +0 -36
  94. package/dist-es/utils/useValueEffect.js.map +0 -1
  95. package/dist-types/combo-box-next/ComboBoxNext.d.ts +0 -17
  96. package/dist-types/combo-box-next/index.d.ts +0 -1
  97. package/dist-types/combo-box-next/useComboBoxNext.d.ts +0 -30
  98. package/dist-types/dropdown-next/DropdownNext.d.ts +0 -99
  99. package/dist-types/dropdown-next/index.d.ts +0 -1
  100. package/dist-types/list-control/ListControlContext.d.ts +0 -21
  101. package/dist-types/list-control/ListControlState.d.ts +0 -70
  102. package/dist-types/option/Option.d.ts +0 -16
  103. package/dist-types/option/OptionGroup.d.ts +0 -12
  104. package/dist-types/option/OptionList.d.ts +0 -5
  105. package/dist-types/option/index.d.ts +0 -2
  106. package/dist-types/pill-input/PillInput.d.ts +0 -48
  107. package/dist-types/pill-input/index.d.ts +0 -1
  108. package/dist-types/pill-input/useTruncatePills.d.ts +0 -8
  109. package/dist-types/utils/useValueEffect.d.ts +0 -4
@@ -1,95 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useRef, useMemo, useEffect } from 'react';
3
- import { makePrefixer, useId, useForkRef, Checkbox } from '@salt-ds/core';
4
- import { clsx } from 'clsx';
5
- import { useListControlContext } from '../list-control/ListControlContext.js';
6
- import { useWindow } from '@salt-ds/window';
7
- import { useComponentCssInjection } from '@salt-ds/styles';
8
- import css_248z from './Option.css.js';
9
-
10
- const withBaseName = makePrefixer("saltOption");
11
- const Option = forwardRef(function Option2(props, ref) {
12
- const {
13
- className,
14
- children,
15
- disabled,
16
- onClick,
17
- id: idProp,
18
- value,
19
- ...rest
20
- } = props;
21
- const targetWindow = useWindow();
22
- useComponentCssInjection({
23
- testId: "salt-option",
24
- css: css_248z,
25
- window: targetWindow
26
- });
27
- const optionRef = useRef(null);
28
- const id = useId(idProp);
29
- const {
30
- setActive,
31
- activeState,
32
- multiselect,
33
- select,
34
- register,
35
- selectedState,
36
- focusVisibleState,
37
- valueToString
38
- } = useListControlContext();
39
- const selected = selectedState.includes(value);
40
- const active = (activeState == null ? void 0 : activeState.id) === id;
41
- const optionValue = useMemo(
42
- () => ({
43
- id: String(id),
44
- disabled: Boolean(disabled),
45
- value
46
- }),
47
- [id, disabled, value]
48
- );
49
- const handleClick = (event) => {
50
- if (disabled || id == void 0) {
51
- return;
52
- }
53
- setActive(optionValue);
54
- select(event, optionValue);
55
- onClick == null ? void 0 : onClick(event);
56
- };
57
- const handleMouseOver = () => {
58
- setActive(optionValue);
59
- };
60
- useEffect(() => {
61
- if (id && optionRef.current) {
62
- return register(optionValue, optionRef.current);
63
- }
64
- }, [optionValue, id, register]);
65
- const handleRef = useForkRef(optionRef, ref);
66
- return /* @__PURE__ */ jsxs("div", {
67
- "aria-disabled": disabled ? "true" : void 0,
68
- "aria-selected": selected,
69
- className: clsx(
70
- withBaseName(),
71
- {
72
- [withBaseName("active")]: active,
73
- [withBaseName("focusVisible")]: focusVisibleState && active
74
- },
75
- className
76
- ),
77
- ref: handleRef,
78
- role: "option",
79
- id,
80
- onClick: handleClick,
81
- onMouseOver: handleMouseOver,
82
- ...rest,
83
- children: [
84
- multiselect && /* @__PURE__ */ jsx(Checkbox, {
85
- checked: selected,
86
- "aria-hidden": "true",
87
- inputProps: { tabIndex: -1 }
88
- }),
89
- children != null ? children : valueToString(value)
90
- ]
91
- });
92
- });
93
-
94
- export { Option };
95
- //# sourceMappingURL=Option.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Option.js","sources":["../src/option/Option.tsx"],"sourcesContent":["import {\n ComponentPropsWithoutRef,\n forwardRef,\n MouseEvent,\n ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { Checkbox, makePrefixer, useForkRef, useId } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport {\n OptionValue,\n useListControlContext,\n} from \"../list-control/ListControlContext\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport optionCss from \"./Option.css\";\n\nexport interface OptionProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * If `true`, the option will be disabled.\n */\n disabled?: boolean;\n /**\n * The value of the option.\n */\n value: unknown;\n /**\n * The content of the option.\n */\n children?: ReactNode;\n}\n\nconst withBaseName = makePrefixer(\"saltOption\");\n\nexport const Option = forwardRef<HTMLDivElement, OptionProps>(function Option(\n props,\n ref\n) {\n const {\n className,\n children,\n disabled,\n onClick,\n id: idProp,\n value,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-option\",\n css: optionCss,\n window: targetWindow,\n });\n\n const optionRef = useRef(null);\n const id = useId(idProp);\n\n const {\n setActive,\n activeState,\n multiselect,\n select,\n register,\n selectedState,\n focusVisibleState,\n valueToString,\n } = useListControlContext();\n\n const selected = selectedState.includes(value);\n const active = activeState?.id === id;\n\n const optionValue: OptionValue<unknown> = useMemo(\n () => ({\n id: String(id),\n disabled: Boolean(disabled),\n value,\n }),\n [id, disabled, value]\n );\n\n const handleClick = (event: MouseEvent<HTMLDivElement>) => {\n if (disabled || id == undefined) {\n return;\n }\n\n // set active descendent\n setActive(optionValue);\n\n // handle selection\n select(event, optionValue);\n\n onClick?.(event);\n };\n\n const handleMouseOver = () => {\n setActive(optionValue);\n };\n\n useEffect(() => {\n if (id && optionRef.current) {\n return register(optionValue, optionRef.current);\n }\n }, [optionValue, id, register]);\n\n const handleRef = useForkRef(optionRef, ref);\n\n return (\n <div\n aria-disabled={disabled ? \"true\" : undefined}\n aria-selected={selected}\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"active\")]: active,\n [withBaseName(\"focusVisible\")]: focusVisibleState && active,\n },\n className\n )}\n ref={handleRef}\n role=\"option\"\n id={id}\n onClick={handleClick}\n onMouseOver={handleMouseOver}\n {...rest}\n >\n {multiselect && (\n <Checkbox\n checked={selected}\n aria-hidden=\"true\"\n inputProps={{ tabIndex: -1 }}\n />\n )}\n {children ?? valueToString(value)}\n </div>\n );\n});\n"],"names":["Option","optionCss"],"mappings":";;;;;;;;;AAkCA,MAAM,YAAA,GAAe,aAAa,YAAY,CAAA,CAAA;AAEvC,MAAM,MAAS,GAAA,UAAA,CAAwC,S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QACZ,UAAA,EAAY,EAAE,QAAA,EAAU,CAAG,CAAA,EAAA;AAAA,OAC7B,CAAA;AAAA,MAED,QAAA,IAAA,IAAA,GAAA,QAAA,GAAY,cAAc,KAAK,CAAA;AAAA,KAAA;AAAA,GAClC,CAAA,CAAA;AAEJ,CAAC;;;;"}
@@ -1,4 +0,0 @@
1
- var css_248z = ".saltOptionGroup-label {\n background: var(--salt-container-primary-background);\n color: var(--salt-text-secondary-foreground);\n font-size: var(--salt-text-label-fontSize);\n font-weight: var(--salt-text-label-fontWeight-strong);\n height: calc(var(--salt-size-base) + var(--salt-spacing-100));\n padding-left: var(--salt-spacing-100);\n padding-right: var(--salt-spacing-100);\n display: flex;\n align-items: center;\n position: sticky;\n top: 0;\n z-index: 2;\n}\n";
2
-
3
- export { css_248z as default };
4
- //# sourceMappingURL=OptionGroup.css.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptionGroup.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,40 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import { makePrefixer, useId } from '@salt-ds/core';
4
- import { clsx } from 'clsx';
5
- import { useWindow } from '@salt-ds/window';
6
- import { useComponentCssInjection } from '@salt-ds/styles';
7
- import css_248z from './OptionGroup.css.js';
8
-
9
- const withBaseName = makePrefixer("saltOptionGroup");
10
- const OptionGroup = forwardRef(
11
- function OptionGroup2(props, ref) {
12
- const { className, children, label, ...rest } = props;
13
- const targetWindow = useWindow();
14
- useComponentCssInjection({
15
- testId: "salt-option-group",
16
- css: css_248z,
17
- window: targetWindow
18
- });
19
- const labelId = useId();
20
- return /* @__PURE__ */ jsxs("div", {
21
- "aria-labelledby": labelId,
22
- className: clsx(withBaseName(), className),
23
- role: "group",
24
- ref,
25
- ...rest,
26
- children: [
27
- /* @__PURE__ */ jsx("div", {
28
- "aria-hidden": true,
29
- className: withBaseName("label"),
30
- id: labelId,
31
- children: label
32
- }),
33
- children
34
- ]
35
- });
36
- }
37
- );
38
-
39
- export { OptionGroup };
40
- //# sourceMappingURL=OptionGroup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptionGroup.js","sources":["../src/option/OptionGroup.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, forwardRef, ReactNode } from \"react\";\nimport { makePrefixer, useId } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport optionGroupCss from \"./OptionGroup.css\";\n\nexport interface OptionGroupProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * The label of the option group.\n */\n label?: string;\n /**\n * Options to be rendered inside the option group.\n */\n children?: ReactNode;\n}\n\nconst withBaseName = makePrefixer(\"saltOptionGroup\");\nexport const OptionGroup = forwardRef<HTMLDivElement, OptionGroupProps>(\n function OptionGroup(props, ref) {\n const { className, children, label, ...rest } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-option-group\",\n css: optionGroupCss,\n window: targetWindow,\n });\n\n const labelId = useId();\n\n return (\n <div\n aria-labelledby={labelId}\n className={clsx(withBaseName(), className)}\n role=\"group\"\n ref={ref}\n {...rest}\n >\n <div aria-hidden className={withBaseName(\"label\")} id={labelId}>\n {label}\n </div>\n {children}\n </div>\n );\n }\n);\n"],"names":["OptionGroup","optionGroupCss"],"mappings":";;;;;;;;AAkBA,MAAM,YAAA,GAAe,aAAa,iBAAiB,CAAA,CAAA;AAC5C,MAAM,WAAc,GAAA,UAAA;AAAA,EACzB,SAASA,YAAY,CAAA,KAAA,EAAO,GAAK,EAAA;AAC/B,IAAA,MAAM,EAAE,SAAA,EAAW,QAAU,EAAA,KAAA,EAAA,GAAU,MAAS,GAAA,KAAA,CAAA;AAEhD,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,mBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAA,MAAM,UAAU,KAAM,EAAA,CAAA;AAEtB,IAAA,uBACG,IAAA,CAAA,KAAA,EAAA;AAAA,MACC,iBAAiB,EAAA,OAAA;AAAA,MACjB,SAAW,EAAA,IAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,MACzC,IAAK,EAAA,OAAA;AAAA,MACL,GAAA;AAAA,MACC,GAAG,IAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,wBAAC,GAAA,CAAA,KAAA,EAAA;AAAA,UAAI,aAAW,EAAA,IAAA;AAAA,UAAC,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,UAAG,EAAI,EAAA,OAAA;AAAA,UACpD,QAAA,EAAA,KAAA;AAAA,SACH,CAAA;AAAA,QACC,QAAA;AAAA,OAAA;AAAA,KACH,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
@@ -1,4 +0,0 @@
1
- var css_248z = ".saltOptionList {\n background: var(--salt-container-primary-background);\n border: var(--salt-size-border) var(--salt-selectable-borderStyle-selected) var(--salt-selectable-borderColor-selected);\n overflow: hidden;\n overflow-y: auto;\n position: relative;\n z-index: var(--salt-zIndex-flyover);\n box-shadow: var(--salt-overlayable-shadow-popout);\n max-height: inherit;\n min-height: inherit;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n gap: var(--salt-size-border);\n}\n\n.saltOptionList-collapsed {\n display: none;\n}\n";
2
-
3
- export { css_248z as default };
4
- //# sourceMappingURL=OptionList.css.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptionList.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,36 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import { clsx } from 'clsx';
4
- import { makePrefixer } from '@salt-ds/core';
5
- import { useWindow } from '@salt-ds/window';
6
- import { useComponentCssInjection } from '@salt-ds/styles';
7
- import css_248z from './OptionList.css.js';
8
-
9
- const withBaseName = makePrefixer("saltOptionList");
10
- const OptionList = forwardRef(
11
- function OptionList2(props, ref) {
12
- const { children, className, collapsed, ...rest } = props;
13
- const targetWindow = useWindow();
14
- useComponentCssInjection({
15
- testId: "salt-option-list",
16
- css: css_248z,
17
- window: targetWindow
18
- });
19
- return /* @__PURE__ */ jsx("div", {
20
- role: "listbox",
21
- className: clsx(
22
- withBaseName(),
23
- {
24
- [withBaseName("collapsed")]: collapsed
25
- },
26
- className
27
- ),
28
- ref,
29
- ...rest,
30
- children
31
- });
32
- }
33
- );
34
-
35
- export { OptionList };
36
- //# sourceMappingURL=OptionList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptionList.js","sources":["../src/option/OptionList.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, forwardRef } from \"react\";\nimport { clsx } from \"clsx\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport optionListCss from \"./OptionList.css\";\n\nexport interface OptionListProps extends ComponentPropsWithoutRef<\"div\"> {\n collapsed?: boolean;\n}\n\nconst withBaseName = makePrefixer(\"saltOptionList\");\n\nexport const OptionList = forwardRef<HTMLDivElement, OptionListProps>(\n function OptionList(props, ref) {\n const { children, className, collapsed, ...rest } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-option-list\",\n css: optionListCss,\n window: targetWindow,\n });\n\n return (\n <div\n role=\"listbox\"\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"collapsed\")]: collapsed,\n },\n className\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </div>\n );\n }\n);\n"],"names":["OptionList","optionListCss"],"mappings":";;;;;;;;AAWA,MAAM,YAAA,GAAe,aAAa,gBAAgB,CAAA,CAAA;AAE3C,MAAM,UAAa,GAAA,UAAA;AAAA,EACxB,SAASA,WAAW,CAAA,KAAA,EAAO,GAAK,EAAA;AAC9B,IAAA,MAAM,EAAE,QAAA,EAAU,SAAW,EAAA,SAAA,EAAA,GAAc,MAAS,GAAA,KAAA,CAAA;AAEpD,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,kBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAA,uBACG,GAAA,CAAA,KAAA,EAAA;AAAA,MACC,IAAK,EAAA,SAAA;AAAA,MACL,SAAW,EAAA,IAAA;AAAA,QACT,YAAa,EAAA;AAAA,QACb;AAAA,UACE,CAAC,YAAa,CAAA,WAAW,CAAI,GAAA,SAAA;AAAA,SAC/B;AAAA,QACA,SAAA;AAAA,OACF;AAAA,MACA,GAAA;AAAA,MACC,GAAG,IAAA;AAAA,MAEH,QAAA;AAAA,KACH,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
@@ -1,4 +0,0 @@
1
- var css_248z = "/* Style applied to the root element */\n.saltPillInput {\n --input-borderColor: var(--salt-editable-borderColor);\n --input-borderStyle: var(--salt-editable-borderStyle);\n --input-outlineColor: var(--salt-focused-outlineColor);\n --input-borderWidth: var(--salt-size-border);\n\n align-items: center;\n background: var(--saltInput-background, var(--input-background));\n color: var(--saltInput-color, var(--salt-content-primary-foreground));\n display: inline-flex;\n font-family: var(--salt-text-fontFamily);\n font-size: var(--saltInput-fontSize, var(--salt-text-fontSize));\n line-height: var(--saltInput-lineHeight, var(--salt-text-lineHeight));\n min-height: var(--saltInput-minHeight, var(--salt-size-base));\n min-width: var(--saltInput-minWidth, 4em);\n padding-left: var(--saltInput-paddingLeft, var(--salt-spacing-50));\n padding-right: var(--saltInput-paddingRight, var(--salt-spacing-100));\n position: relative;\n width: 100%;\n box-sizing: border-box;\n}\n\n.saltPillInput-truncate {\n height: var(--salt-size-base);\n}\n\n.saltPillInput-truncate .saltPillInput-inputWrapper {\n flex-wrap: nowrap;\n}\n\n.saltPillInput:hover {\n --input-borderStyle: var(--salt-editable-borderStyle-hover);\n --input-borderColor: var(--salt-editable-borderColor-hover);\n\n background: var(--saltInput-background-hover, var(--input-background-hover));\n cursor: var(--salt-editable-cursor-hover);\n}\n\n.saltPillInput:active {\n --input-borderColor: var(--salt-editable-borderColor-active);\n --input-borderStyle: var(--salt-editable-borderStyle-active);\n --input-borderWidth: var(--salt-editable-borderWidth-active);\n\n background: var(--saltInput-background-active, var(--input-background-active));\n cursor: var(--salt-editable-cursor-active);\n}\n\n/* Class applied if `variant=\"primary\"` */\n.saltPillInput-primary {\n --input-background: var(--salt-editable-primary-background);\n --input-background-active: var(--salt-editable-primary-background-active);\n --input-background-hover: var(--salt-editable-primary-background-hover);\n --input-background-disabled: var(--salt-editable-primary-background-disabled);\n --input-background-readonly: var(--salt-editable-primary-background-readonly);\n}\n\n/* Class applied if `variant=\"secondary\"` */\n.saltPillInput-secondary {\n --input-background: var(--salt-editable-secondary-background);\n --input-background-active: var(--salt-editable-secondary-background-active);\n --input-background-hover: var(--salt-editable-secondary-background-active);\n --input-background-disabled: var(--salt-editable-secondary-background-disabled);\n --input-background-readonly: var(--salt-editable-secondary-background-readonly);\n}\n\n/* Style applied to input if `validationState=\"error\"` */\n.saltPillInput-error,\n.saltPillInput-error:hover {\n --input-background: var(--salt-status-error-background);\n --input-background-active: var(--salt-status-error-background);\n --input-background-hover: var(--salt-status-error-background);\n --input-borderColor: var(--salt-status-error-borderColor);\n --input-outlineColor: var(--salt-status-error-borderColor);\n}\n\n/* Style applied to input if `validationState=\"warning\"` */\n.saltPillInput-warning,\n.saltPillInput-warning:hover {\n --input-background: var(--salt-status-warning-background);\n --input-background-active: var(--salt-status-warning-background);\n --input-background-hover: var(--salt-status-warning-background);\n --input-borderColor: var(--salt-status-warning-borderColor);\n --input-outlineColor: var(--salt-status-warning-borderColor);\n}\n\n/* Style applied to input if `validationState=\"success\"` */\n.saltPillInput-success,\n.saltPillInput-success:hover {\n --input-background: var(--salt-status-success-background);\n --input-background-active: var(--salt-status-success-background);\n --input-background-hover: var(--salt-status-success-background);\n --input-borderColor: var(--salt-status-success-borderColor);\n --input-outlineColor: var(--salt-status-success-borderColor);\n}\n\n/* Style applied to inner input component */\n.saltPillInput-input {\n background: none;\n border: none;\n box-sizing: content-box;\n color: inherit;\n cursor: inherit;\n display: block;\n flex: 1;\n font: inherit;\n height: 100%;\n letter-spacing: var(--saltInput-letterSpacing, 0);\n margin: 0;\n min-width: 0;\n overflow: hidden;\n padding: 0;\n text-align: var(--input-textAlign);\n width: 100%;\n}\n\n/* Reset in the class */\n.saltPillInput-input:focus {\n outline: none;\n}\n\n/* Style applied to selected input */\n.saltPillInput-input::selection {\n background: var(--salt-content-foreground-highlight);\n}\n\n/* Style applied to placeholder text */\n.saltPillInput-input::placeholder {\n color: var(--salt-content-secondary-foreground);\n font-weight: var(--salt-text-fontWeight-small);\n}\n\n/* Styling when focused */\n.saltPillInput-focused {\n --input-borderColor: var(--input-outlineColor);\n --input-borderWidth: var(--salt-editable-borderWidth-active);\n\n outline: var(--saltInput-outline, var(--salt-focused-outlineWidth) var(--salt-focused-outlineStyle) var(--input-outlineColor));\n}\n\n/* Style applied if `readOnly={true}` */\n.saltPillInput.saltPillInput-readOnly {\n --input-borderColor: var(--salt-editable-borderColor-readonly);\n --input-borderStyle: var(--salt-editable-borderStyle-readonly);\n --input-borderWidth: var(--salt-size-border);\n\n background: var(--input-background-readonly);\n cursor: var(--salt-editable-cursor-readonly);\n}\n\n/* Styling when focused if `disabled={true}` */\n.saltPillInput-focused.saltPillInput-disabled {\n --input-borderWidth: var(--salt-size-border);\n outline: none;\n}\n\n/* Styling when focused if `readOnly={true}` */\n.saltPillInput-focused.saltPillInput-readOnly {\n --input-borderWidth: var(--salt-size-border);\n}\n\n/* Style applied to selected input if `disabled={true}` */\n.saltPillInput-disabled .saltPillInput-input::selection {\n background: none;\n}\n\n/* Style applied to input if `disabled={true}` */\n.saltPillInput.saltPillInput-disabled,\n.saltPillInput.saltPillInput-disabled:hover,\n.saltPillInput.saltPillInput-disabled:active {\n --input-borderColor: var(--salt-editable-borderColor-disabled);\n --input-borderStyle: var(--salt-editable-borderStyle-disabled);\n --input-borderWidth: var(--salt-size-border);\n\n background: var(--input-background-disabled);\n cursor: var(--salt-editable-cursor-disabled);\n color: var(--saltInput-color-disabled, var(--salt-content-primary-foreground-disabled));\n}\n\n.saltPillInput-activationIndicator {\n left: 0;\n bottom: 0;\n width: 100%;\n position: absolute;\n border-bottom: var(--input-borderWidth) var(--input-borderStyle) var(--input-borderColor);\n}\n\n/* Style applied to start adornments */\n.saltPillInput-startAdornmentContainer {\n align-items: center;\n display: inline-flex;\n padding-right: var(--salt-spacing-100);\n column-gap: var(--salt-spacing-100);\n}\n\n/* Style applied to end adornments */\n.saltPillInput-endAdornmentContainer {\n align-items: center;\n display: inline-flex;\n padding-left: var(--salt-spacing-100);\n padding-top: var(--salt-spacing-50);\n column-gap: var(--salt-spacing-100);\n align-self: flex-start;\n}\n\n.saltPillInput-readOnly .saltPillInput-startAdornmentContainer {\n margin-left: var(--salt-spacing-50);\n}\n\n.saltPillInput-startAdornmentContainer .saltButton ~ .saltButton {\n margin-left: calc(-1 * var(--salt-spacing-50));\n}\n.saltPillInput-endAdornmentContainer .saltButton ~ .saltButton {\n margin-left: calc(-1 * var(--salt-spacing-50));\n}\n\n.saltPillInput-startAdornmentContainer .saltButton:first-child {\n margin-left: calc(var(--salt-spacing-50) * -1);\n}\n.saltPillInput-endAdornmentContainer .saltButton:last-child {\n margin-right: calc(var(--salt-spacing-50) * -1);\n}\n\n.saltPillInput-startAdornmentContainer > .saltButton,\n.saltPillInput-endAdornmentContainer > .saltButton {\n --saltButton-padding: var(--salt-spacing-50);\n --saltButton-height: calc(var(--salt-size-base) - var(--salt-spacing-100));\n}\n\n.saltPillInput-inputWrapper {\n display: flex;\n gap: var(--salt-spacing-50);\n align-items: center;\n flex: 1;\n padding: var(--salt-spacing-50) 0;\n flex-wrap: wrap;\n max-height: inherit;\n height: inherit;\n overflow-y: auto;\n box-sizing: border-box;\n}\n\n.saltPillInput-pillList {\n display: contents;\n}\n\n.saltPillInput .saltPill:focus-visible {\n background: var(--salt-selectable-background-hover);\n outline: none;\n}\n\n.saltPillInput .saltPill:hover {\n background: var(--salt-selectable-background-hover);\n}\n\n.saltPillInput .saltPill:active {\n background: var(--salt-actionable-primary-background-active);\n --saltPill-color: var(--salt-actionable-primary-foreground-active);\n --saltIcon-color: var(--salt-actionable-primary-foreground-active);\n}\n\ndiv[role=\"listitem\"] {\n display: inline;\n}\n\n.saltPillInput-overflowIndicator {\n width: calc(var(--salt-size-base) - var(--salt-spacing-100));\n height: calc(var(--salt-size-base) - var(--salt-spacing-100));\n display: flex;\n align-items: center;\n justify-content: center;\n}\n";
2
-
3
- export { css_248z as default };
4
- //# sourceMappingURL=PillInput.css.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PillInput.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,252 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { clsx } from 'clsx';
3
- import { forwardRef, useState, useRef } from 'react';
4
- import { useComponentCssInjection } from '@salt-ds/styles';
5
- import { useWindow } from '@salt-ds/window';
6
- import { makePrefixer, useFormFieldProps, useControlled, useId, useForkRef, Pill, StatusAdornment } from '@salt-ds/core';
7
- import css_248z from './PillInput.css.js';
8
- import { CloseIcon, OverflowMenuIcon } from '@salt-ds/icons';
9
- import { useTruncatePills } from './useTruncatePills.js';
10
-
11
- const withBaseName = makePrefixer("saltPillInput");
12
- const PillInput = forwardRef(function PillInput2({
13
- "aria-activedescendant": ariaActiveDescendant,
14
- "aria-expanded": ariaExpanded,
15
- "aria-owns": ariaOwns,
16
- className: classNameProp,
17
- disabled,
18
- emptyReadOnlyMarker = "\u2014",
19
- endAdornment,
20
- hidePillClose,
21
- id: idProp,
22
- inputProps = {},
23
- inputRef: inputRefProp,
24
- placeholder,
25
- pills = [],
26
- onPillRemove,
27
- readOnly: readOnlyProp,
28
- role,
29
- startAdornment,
30
- style,
31
- textAlign = "left",
32
- value: valueProp,
33
- defaultValue: defaultValueProp = valueProp === void 0 ? "" : void 0,
34
- validationStatus: validationStatusProp,
35
- variant = "primary",
36
- truncate,
37
- ...other
38
- }, ref) {
39
- const targetWindow = useWindow();
40
- useComponentCssInjection({
41
- testId: "salt-pill-input",
42
- css: css_248z,
43
- window: targetWindow
44
- });
45
- const {
46
- a11yProps: {
47
- "aria-describedby": formFieldDescribedBy,
48
- "aria-labelledby": formFieldLabelledBy
49
- } = {},
50
- disabled: formFieldDisabled,
51
- readOnly: formFieldReadOnly,
52
- necessity: formFieldRequired,
53
- validationStatus: formFieldValidationStatus
54
- } = useFormFieldProps();
55
- const restA11yProps = {
56
- "aria-activedescendant": ariaActiveDescendant,
57
- "aria-expanded": ariaExpanded,
58
- "aria-owns": ariaOwns
59
- };
60
- const isDisabled = disabled || formFieldDisabled;
61
- const isReadOnly = readOnlyProp || formFieldReadOnly;
62
- const validationStatus = formFieldValidationStatus != null ? formFieldValidationStatus : validationStatusProp;
63
- const [focusedPillIndex, setFocusedPillIndex] = useState(-1);
64
- const isEmptyReadOnly = isReadOnly && !defaultValueProp && !valueProp;
65
- const defaultValue = isEmptyReadOnly ? emptyReadOnlyMarker : defaultValueProp;
66
- const {
67
- "aria-describedby": inputDescribedBy,
68
- "aria-labelledby": inputLabelledBy,
69
- onChange,
70
- required: inputPropsRequired,
71
- onKeyDown: inputOnKeyDown,
72
- ...restInputProps
73
- } = inputProps;
74
- const isRequired = formFieldRequired ? ["required", "asterisk"].includes(formFieldRequired) : inputPropsRequired;
75
- const [value, setValue] = useControlled({
76
- controlled: valueProp,
77
- default: defaultValue,
78
- name: "Input",
79
- state: "value"
80
- });
81
- const { visiblePills, pillListRef } = useTruncatePills({
82
- pills,
83
- enable: truncate && pills.length > 0
84
- });
85
- const id = useId(idProp);
86
- const pillListId = `${id}-optionsList`;
87
- const pillElementsRef = useRef([]);
88
- const inputRef = useRef(null);
89
- const handleInputRef = useForkRef(inputRef, inputRefProp);
90
- const handleChange = (event) => {
91
- const value2 = event.target.value;
92
- setValue(value2);
93
- onChange == null ? void 0 : onChange(event);
94
- };
95
- const handleKeyDown = (event) => {
96
- var _a;
97
- const target = event.currentTarget;
98
- if (target.selectionStart === 0 && target.selectionEnd == 0) {
99
- const lastPillIndex = pills.length - 1;
100
- const lastPill = pills[lastPillIndex];
101
- if (event.key === "Backspace" && lastPill) {
102
- event.preventDefault();
103
- onPillRemove == null ? void 0 : onPillRemove(event, lastPillIndex);
104
- } else if (event.key === "ArrowLeft") {
105
- event.preventDefault();
106
- (_a = pillElementsRef.current[lastPillIndex]) == null ? void 0 : _a.focus();
107
- }
108
- }
109
- inputOnKeyDown == null ? void 0 : inputOnKeyDown(event);
110
- };
111
- const handlePillKeyDown = (event) => {
112
- var _a, _b, _c, _d, _e, _f;
113
- const target = event.currentTarget;
114
- const index = Number(target.dataset.index);
115
- if (event.key === "ArrowLeft") {
116
- event.preventDefault();
117
- (_a = pillElementsRef.current[index - 1]) == null ? void 0 : _a.focus();
118
- } else if (event.key === "ArrowRight") {
119
- event.preventDefault();
120
- if (index === pills.length - 1) {
121
- (_b = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _b.focus();
122
- } else {
123
- (_c = pillElementsRef.current[index + 1]) == null ? void 0 : _c.focus();
124
- }
125
- } else if (event.key == "Delete" || event.key === "Backspace") {
126
- event.preventDefault();
127
- onPillRemove == null ? void 0 : onPillRemove(event, index);
128
- if (pills.length === 1) {
129
- (_d = inputRef.current) == null ? void 0 : _d.focus();
130
- } else if (index === pills.length - 1) {
131
- (_e = pillElementsRef.current[pills.length - 2]) == null ? void 0 : _e.focus();
132
- } else {
133
- (_f = pillElementsRef.current[index]) == null ? void 0 : _f.focus();
134
- }
135
- }
136
- };
137
- const handlePillClick = (event) => {
138
- var _a;
139
- const target = event.currentTarget;
140
- const index = Number(target.dataset.index);
141
- onPillRemove == null ? void 0 : onPillRemove(event, index);
142
- (_a = inputRef.current) == null ? void 0 : _a.focus();
143
- };
144
- const inputStyle = {
145
- "--input-textAlign": textAlign,
146
- ...style
147
- };
148
- return /* @__PURE__ */ jsxs("div", {
149
- className: clsx(
150
- withBaseName(),
151
- withBaseName(variant),
152
- {
153
- [withBaseName("disabled")]: isDisabled,
154
- [withBaseName("readOnly")]: isReadOnly,
155
- [withBaseName("truncate")]: truncate,
156
- [withBaseName(validationStatus || "")]: validationStatus
157
- },
158
- classNameProp
159
- ),
160
- ref,
161
- style: inputStyle,
162
- ...other,
163
- children: [
164
- startAdornment && /* @__PURE__ */ jsx("div", {
165
- className: withBaseName("startAdornmentContainer"),
166
- children: startAdornment
167
- }),
168
- /* @__PURE__ */ jsxs("div", {
169
- className: withBaseName("inputWrapper"),
170
- ref: pillListRef,
171
- children: [
172
- /* @__PURE__ */ jsxs("div", {
173
- role: "list",
174
- className: withBaseName("pillList"),
175
- "aria-labelledby": clsx(formFieldLabelledBy, pillListId),
176
- "aria-label": "Selected Options",
177
- id: pillListId,
178
- children: [
179
- visiblePills == null ? void 0 : visiblePills.map((pill, index) => /* @__PURE__ */ jsx("div", {
180
- role: "listitem",
181
- children: /* @__PURE__ */ jsxs(Pill, {
182
- "data-index": index,
183
- disabled,
184
- ref: (element) => {
185
- if (element) {
186
- pillElementsRef.current[index] = element;
187
- } else {
188
- pillElementsRef.current = pillElementsRef.current.filter(
189
- (pillEl) => pillEl !== element
190
- );
191
- }
192
- },
193
- onFocus: () => setFocusedPillIndex(index),
194
- onKeyDown: handlePillKeyDown,
195
- onClick: handlePillClick,
196
- tabIndex: focusedPillIndex === -1 || focusedPillIndex === index ? 0 : -1,
197
- children: [
198
- pill,
199
- !hidePillClose && /* @__PURE__ */ jsx(CloseIcon, {
200
- "aria-label": "click to close"
201
- })
202
- ]
203
- })
204
- }, index)),
205
- visiblePills.length < pills.length && /* @__PURE__ */ jsx("div", {
206
- role: "listitem",
207
- children: /* @__PURE__ */ jsx("div", {
208
- "data-overflowindicator": true,
209
- className: withBaseName("overflowIndicator"),
210
- children: /* @__PURE__ */ jsx(OverflowMenuIcon, {
211
- "aria-hidden": true
212
- })
213
- })
214
- })
215
- ]
216
- }),
217
- /* @__PURE__ */ jsx("input", {
218
- "aria-describedby": clsx(formFieldDescribedBy, inputDescribedBy),
219
- "aria-labelledby": clsx(formFieldLabelledBy, inputLabelledBy),
220
- className: clsx(withBaseName("input"), inputProps == null ? void 0 : inputProps.className),
221
- disabled: isDisabled,
222
- id,
223
- readOnly: isReadOnly,
224
- ref: handleInputRef,
225
- role,
226
- tabIndex: isDisabled ? -1 : 0,
227
- onChange: handleChange,
228
- onKeyDown: handleKeyDown,
229
- placeholder,
230
- value,
231
- ...restA11yProps,
232
- ...restInputProps,
233
- required: isRequired
234
- })
235
- ]
236
- }),
237
- !isDisabled && !isReadOnly && validationStatus && /* @__PURE__ */ jsx(StatusAdornment, {
238
- status: validationStatus
239
- }),
240
- endAdornment && /* @__PURE__ */ jsx("div", {
241
- className: withBaseName("endAdornmentContainer"),
242
- children: endAdornment
243
- }),
244
- /* @__PURE__ */ jsx("div", {
245
- className: withBaseName("activationIndicator")
246
- })
247
- ]
248
- });
249
- });
250
-
251
- export { PillInput };
252
- //# sourceMappingURL=PillInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PillInput.js","sources":["../src/pill-input/PillInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEvent,\n KeyboardEvent,\n SyntheticEvent,\n ComponentPropsWithoutRef,\n MouseEvent,\n ForwardedRef,\n forwardRef,\n InputHTMLAttributes,\n ReactNode,\n Ref,\n useState,\n useRef,\n} from \"react\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport {\n makePrefixer,\n useControlled,\n useFormFieldProps,\n StatusAdornment,\n useId,\n Pill,\n useForkRef,\n} from \"@salt-ds/core\";\n\nimport pillInputCss from \"./PillInput.css\";\nimport { CloseIcon, OverflowMenuIcon } from \"@salt-ds/icons\";\nimport { useTruncatePills } from \"./useTruncatePills\";\n\nconst withBaseName = makePrefixer(\"saltPillInput\");\n\nexport interface PillInputProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"defaultValue\">,\n Pick<\n ComponentPropsWithoutRef<\"input\">,\n \"disabled\" | \"value\" | \"defaultValue\" | \"placeholder\"\n > {\n /**\n * The marker to use in an empty read only Input.\n * Use `''` to disable this feature. Defaults to '—'.\n */\n emptyReadOnlyMarker?: string;\n /**\n * End adornment component\n */\n endAdornment?: ReactNode;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.\n */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n /**\n * Optional ref for the input component\n */\n inputRef?: Ref<HTMLInputElement>;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n * The tokens to display in the input.\n */\n pills?: any[];\n onPillRemove?: (event: SyntheticEvent, index: number) => void;\n /**\n * Start adornment component\n */\n startAdornment?: ReactNode;\n /**\n * Alignment of text within container. Defaults to \"left\"\n */\n textAlign?: \"left\" | \"center\" | \"right\";\n /**\n * Validation status.\n */\n validationStatus?: \"error\" | \"warning\" | \"success\";\n /**\n * Styling variant. Defaults to \"primary\".\n */\n variant?: \"primary\" | \"secondary\";\n hidePillClose?: boolean;\n truncate?: boolean;\n}\n\nexport const PillInput = forwardRef(function PillInput<Item>(\n {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n className: classNameProp,\n disabled,\n emptyReadOnlyMarker = \"—\",\n endAdornment,\n hidePillClose,\n id: idProp,\n inputProps = {},\n inputRef: inputRefProp,\n placeholder,\n pills = [],\n onPillRemove,\n readOnly: readOnlyProp,\n role,\n startAdornment,\n style,\n textAlign = \"left\",\n value: valueProp,\n defaultValue: defaultValueProp = valueProp === undefined ? \"\" : undefined,\n validationStatus: validationStatusProp,\n variant = \"primary\",\n truncate,\n ...other\n }: PillInputProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-pill-input\",\n css: pillInputCss,\n window: targetWindow,\n });\n\n const {\n a11yProps: {\n \"aria-describedby\": formFieldDescribedBy,\n \"aria-labelledby\": formFieldLabelledBy,\n } = {},\n disabled: formFieldDisabled,\n readOnly: formFieldReadOnly,\n necessity: formFieldRequired,\n validationStatus: formFieldValidationStatus,\n } = useFormFieldProps();\n\n const restA11yProps = {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n };\n\n const isDisabled = disabled || formFieldDisabled;\n const isReadOnly = readOnlyProp || formFieldReadOnly;\n const validationStatus = formFieldValidationStatus ?? validationStatusProp;\n\n const [focusedPillIndex, setFocusedPillIndex] = useState(-1);\n\n const isEmptyReadOnly = isReadOnly && !defaultValueProp && !valueProp;\n const defaultValue = isEmptyReadOnly ? emptyReadOnlyMarker : defaultValueProp;\n\n const {\n \"aria-describedby\": inputDescribedBy,\n \"aria-labelledby\": inputLabelledBy,\n onChange,\n required: inputPropsRequired,\n onKeyDown: inputOnKeyDown,\n ...restInputProps\n } = inputProps;\n\n const isRequired = formFieldRequired\n ? [\"required\", \"asterisk\"].includes(formFieldRequired)\n : inputPropsRequired;\n\n const [value, setValue] = useControlled({\n controlled: valueProp,\n default: defaultValue,\n name: \"Input\",\n state: \"value\",\n });\n\n const { visiblePills, pillListRef } = useTruncatePills({\n pills,\n enable: truncate && pills.length > 0,\n });\n\n const id = useId(idProp);\n const pillListId = `${id}-optionsList`;\n\n const pillElementsRef = useRef<HTMLElement[]>([]);\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleInputRef = useForkRef(inputRef, inputRefProp);\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n setValue(value);\n onChange?.(event);\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n const target = event.currentTarget;\n if (target.selectionStart === 0 && target.selectionEnd == 0) {\n const lastPillIndex = pills.length - 1;\n const lastPill = pills[lastPillIndex];\n if (event.key === \"Backspace\" && lastPill) {\n event.preventDefault();\n onPillRemove?.(event, lastPillIndex);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n // Move focus to last pill\n pillElementsRef.current[lastPillIndex]?.focus();\n }\n }\n\n inputOnKeyDown?.(event);\n };\n\n const handlePillKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n const target = event.currentTarget;\n const index = Number(target.dataset.index);\n if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n // Move focus to previous pill\n pillElementsRef.current[index - 1]?.focus();\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n // Move focus to next pill or input\n if (index === pills.length - 1) {\n inputRef?.current?.focus();\n } else {\n pillElementsRef.current[index + 1]?.focus();\n }\n } else if (event.key == \"Delete\" || event.key === \"Backspace\") {\n event.preventDefault();\n onPillRemove?.(event, index);\n\n if (pills.length === 1) {\n inputRef.current?.focus();\n } else if (index === pills.length - 1) {\n pillElementsRef.current[pills.length - 2]?.focus();\n } else {\n pillElementsRef.current[index]?.focus();\n }\n }\n };\n\n const handlePillClick = (event: MouseEvent<HTMLButtonElement>) => {\n const target = event.currentTarget;\n const index = Number(target.dataset.index);\n onPillRemove?.(event, index);\n inputRef.current?.focus();\n };\n\n const inputStyle = {\n \"--input-textAlign\": textAlign,\n ...style,\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n withBaseName(variant),\n {\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"readOnly\")]: isReadOnly,\n [withBaseName(\"truncate\")]: truncate,\n [withBaseName(validationStatus || \"\")]: validationStatus,\n },\n classNameProp\n )}\n ref={ref}\n style={inputStyle}\n {...other}\n >\n {startAdornment && (\n <div className={withBaseName(\"startAdornmentContainer\")}>\n {startAdornment}\n </div>\n )}\n <div className={withBaseName(\"inputWrapper\")} ref={pillListRef}>\n <div\n role=\"list\"\n className={withBaseName(\"pillList\")}\n aria-labelledby={clsx(formFieldLabelledBy, pillListId)}\n aria-label=\"Selected Options\"\n id={pillListId}\n >\n {visiblePills?.map((pill, index) => (\n <div role=\"listitem\" key={index}>\n <Pill\n data-index={index}\n disabled={disabled}\n ref={(element) => {\n if (element) {\n pillElementsRef.current[index] = element;\n } else {\n pillElementsRef.current = pillElementsRef.current.filter(\n (pillEl) => pillEl !== element\n );\n }\n }}\n onFocus={() => setFocusedPillIndex(index)}\n onKeyDown={handlePillKeyDown}\n onClick={handlePillClick}\n tabIndex={\n focusedPillIndex === -1 || focusedPillIndex === index ? 0 : -1\n }\n >\n {pill}\n {!hidePillClose && <CloseIcon aria-label=\"click to close\" />}\n </Pill>\n </div>\n ))}\n {visiblePills.length < pills.length && (\n <div role=\"listitem\">\n <div\n data-overflowindicator\n className={withBaseName(\"overflowIndicator\")}\n >\n <OverflowMenuIcon aria-hidden />\n </div>\n </div>\n )}\n </div>\n <input\n aria-describedby={clsx(formFieldDescribedBy, inputDescribedBy)}\n aria-labelledby={clsx(formFieldLabelledBy, inputLabelledBy)}\n className={clsx(withBaseName(\"input\"), inputProps?.className)}\n disabled={isDisabled}\n id={id}\n readOnly={isReadOnly}\n ref={handleInputRef}\n role={role}\n tabIndex={isDisabled ? -1 : 0}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n value={value}\n {...restA11yProps}\n {...restInputProps}\n required={isRequired}\n />\n </div>\n {!isDisabled && !isReadOnly && validationStatus && (\n <StatusAdornment status={validationStatus} />\n )}\n {endAdornment && (\n <div className={withBaseName(\"endAdornmentContainer\")}>\n {endAdornment}\n </div>\n )}\n <div className={withBaseName(\"activationIndicator\")} />\n </div>\n );\n});\n"],"names":["PillInput","pillInputCss","value"],"mappings":";;;;;;;;;;AA+BA,MAAM,YAAA,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AAA,GACvD,CAAA,CAAA;AAEJ,CAAC;;;;"}
@@ -1,81 +0,0 @@
1
- import { useRef, useCallback } from 'react';
2
- import { useIsomorphicLayoutEffect } from '@salt-ds/core';
3
- import { useValueEffect } from '../utils/useValueEffect.js';
4
- import { useWindow } from '@salt-ds/window';
5
- import 'react/jsx-runtime';
6
- import { useResizeObserver } from '../responsive/useResizeObserver.js';
7
-
8
- function useTruncatePills({
9
- pills,
10
- enable
11
- }) {
12
- const pillListRef = useRef(null);
13
- const [{ visibleCount }, setVisibleItems] = useValueEffect({
14
- visibleCount: pills.length
15
- });
16
- const targetWindow = useWindow();
17
- const updateOverflow = useCallback(() => {
18
- if (!enable) {
19
- return;
20
- }
21
- const computeVisible = (visibleCount2) => {
22
- const pillList = pillListRef.current;
23
- if (pillList && targetWindow) {
24
- let pillElements = Array.from(
25
- pillList.querySelectorAll('[role="listitem"]')
26
- );
27
- const maxWidth = pillList.getBoundingClientRect().width;
28
- const listGap = parseInt(targetWindow.getComputedStyle(pillList).gap);
29
- let isShowingOverflow = pillList.querySelector(
30
- "[data-overflowindicator]"
31
- );
32
- let currentSize = 0;
33
- let newVisibleCount = 0;
34
- if (isShowingOverflow) {
35
- let pill = pillElements.pop();
36
- if (pill) {
37
- let pillWidth = pill.getBoundingClientRect().width;
38
- currentSize += pillWidth + listGap;
39
- }
40
- }
41
- for (let pill of pillElements) {
42
- let pillWidth = pill.getBoundingClientRect().width;
43
- currentSize += pillWidth + listGap;
44
- if (Math.round(currentSize) <= Math.round(maxWidth)) {
45
- newVisibleCount++;
46
- } else {
47
- break;
48
- }
49
- }
50
- return newVisibleCount;
51
- }
52
- return visibleCount2;
53
- };
54
- setVisibleItems(function* () {
55
- yield {
56
- visibleCount: pills.length
57
- };
58
- let newVisibleCount = computeVisible(pills.length);
59
- let isMeasuring = newVisibleCount < pills.length && newVisibleCount > 0;
60
- yield {
61
- visibleCount: newVisibleCount
62
- };
63
- if (isMeasuring) {
64
- newVisibleCount = computeVisible(visibleCount);
65
- yield {
66
- visibleCount: newVisibleCount
67
- };
68
- }
69
- });
70
- }, [pills, setVisibleItems, enable, targetWindow]);
71
- useIsomorphicLayoutEffect(updateOverflow, [updateOverflow, pills]);
72
- useResizeObserver(pillListRef, ["width"], updateOverflow, true);
73
- return {
74
- pillListRef,
75
- visibleCount,
76
- visiblePills: enable ? pills.slice(0, visibleCount) : pills
77
- };
78
- }
79
-
80
- export { useTruncatePills };
81
- //# sourceMappingURL=useTruncatePills.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTruncatePills.js","sources":["../src/pill-input/useTruncatePills.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"@salt-ds/core\";\nimport { useValueEffect } from \"../utils/useValueEffect\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useResizeObserver } from \"../responsive\";\n\nexport function useTruncatePills({\n pills,\n enable,\n}: {\n pills: string[];\n enable?: boolean;\n}) {\n const pillListRef = useRef<HTMLDivElement>(null);\n const [{ visibleCount }, setVisibleItems] = useValueEffect({\n visibleCount: pills.length,\n });\n const targetWindow = useWindow();\n\n const updateOverflow = useCallback(() => {\n if (!enable) {\n return;\n }\n\n const computeVisible = (visibleCount: number) => {\n const pillList = pillListRef.current;\n\n if (pillList && targetWindow) {\n let pillElements = Array.from(\n pillList.querySelectorAll('[role=\"listitem\"]')\n ) as HTMLLIElement[];\n const maxWidth = pillList.getBoundingClientRect().width;\n const listGap = parseInt(targetWindow.getComputedStyle(pillList).gap);\n let isShowingOverflow = pillList.querySelector(\n \"[data-overflowindicator]\"\n );\n\n let currentSize = 0;\n let newVisibleCount = 0;\n\n if (isShowingOverflow) {\n let pill = pillElements.pop();\n if (pill) {\n let pillWidth = pill.getBoundingClientRect().width;\n currentSize += pillWidth + listGap;\n }\n }\n\n for (let pill of pillElements) {\n let pillWidth = pill.getBoundingClientRect().width;\n currentSize += pillWidth + listGap;\n\n if (Math.round(currentSize) <= Math.round(maxWidth)) {\n newVisibleCount++;\n } else {\n break;\n }\n }\n return newVisibleCount;\n }\n return visibleCount;\n };\n\n setVisibleItems(function* () {\n // Show all\n yield {\n visibleCount: pills.length,\n };\n\n // Measure the visible count\n let newVisibleCount = computeVisible(pills.length);\n let isMeasuring = newVisibleCount < pills.length && newVisibleCount > 0;\n yield {\n visibleCount: newVisibleCount,\n };\n\n // ensure the visible count is correct\n if (isMeasuring) {\n newVisibleCount = computeVisible(visibleCount);\n yield {\n visibleCount: newVisibleCount,\n };\n }\n });\n }, [pills, setVisibleItems, enable, targetWindow]);\n\n useIsomorphicLayoutEffect(updateOverflow, [updateOverflow, pills]);\n useResizeObserver(pillListRef, [\"width\"], updateOverflow, true);\n\n return {\n pillListRef,\n visibleCount,\n visiblePills: enable ? pills.slice(0, visibleCount) : pills,\n };\n}\n"],"names":["visibleCount"],"mappings":";;;;;;;AAMO,SAAS,gBAAiB,CAAA;AAAA,EAC/B,KAAA;AAAA,EACA,MAAA;AACF,CAGG,EAAA;AACD,EAAM,MAAA,WAAA,GAAc,OAAuB,IAAI,CAAA,CAAA;AAC/C,EAAA,MAAM,CAAC,EAAE,YAAA,EAAgB,EAAA,eAAe,IAAI,cAAe,CAAA;AAAA,IACzD,cAAc,KAAM,CAAA,MAAA;AAAA,GACrB,CAAA,CAAA;AACD,EAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAE/B,EAAM,MAAA,cAAA,GAAiB,YAAY,MAAM;AACvC,IAAA,IAAI,CAAC,MAAQ,EAAA;AACX,MAAA,OAAA;AAAA,KACF;AAEA,IAAM,MAAA,cAAA,GAAiB,CAACA,aAAyB,KAAA;AAC/C,MAAA,MAAM,WAAW,WAAY,CAAA,OAAA,CAAA;AAE7B,MAAA,IAAI,YAAY,YAAc,EAAA;AAC5B,QAAA,IAAI,eAAe,KAAM,CAAA,IAAA;AAAA,UACvB,QAAA,CAAS,iBAAiB,mBAAmB,CAAA;AAAA,SAC/C,CAAA;AACA,QAAM,MAAA,QAAA,GAAW,Q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