@chayns-ui/core 0.9.1 → 0.9.2

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.
@@ -4,90 +4,71 @@
4
4
  min-inline-size: 0;
5
5
  }
6
6
 
7
- .chayns-combo-box__input {
7
+ .chayns-combo-box__trigger {
8
8
  box-sizing: border-box;
9
+ display: flex;
10
+ align-items: center;
11
+ justify-content: space-between;
9
12
  inline-size: 100%;
10
13
  min-block-size: calc(1.2em + 2 * var(--input-py) + 3px);
11
- padding: var(--input-py) var(--k36) var(--input-py) var(--input-px);
14
+ padding: var(--input-py) var(--input-px);
12
15
  border: 1.5px solid var(--input-border);
13
16
  border-radius: 10px;
14
17
  background: var(--surface);
15
18
  color: var(--text);
19
+ cursor: pointer;
16
20
  font: inherit;
17
21
  line-height: 1.2;
18
22
  outline: none;
23
+ text-align: start;
19
24
  transition:
20
25
  border-color 0.18s ease,
21
26
  box-shadow 0.18s ease;
22
27
  }
23
28
 
24
- .chayns-combo-box__input:focus {
29
+ .chayns-combo-box__trigger:focus-visible {
25
30
  border-color: var(--accent);
26
31
  box-shadow: 0 0 0 var(--focus-ring-size)
27
32
  rgb(var(--focus-ring-rgb), var(--focus-ring-alpha-soft));
28
33
  }
29
34
 
35
+ .chayns-combo-box__trigger:disabled {
36
+ cursor: not-allowed;
37
+ }
38
+
39
+ .chayns-combo-box__value {
40
+ min-inline-size: 0;
41
+ overflow: hidden;
42
+ text-overflow: ellipsis;
43
+ white-space: nowrap;
44
+ }
45
+
30
46
  .chayns-combo-box__label {
31
47
  position: absolute;
32
48
  inset-block-start: 0;
33
49
  inset-inline-start: 10px;
34
50
  padding-inline: var(--k5);
35
51
  background: var(--surface);
36
- color: var(--text-3);
52
+ color: var(--accent);
37
53
  font-size: var(--fs-body);
38
54
  line-height: 1.2;
39
55
  pointer-events: none;
40
- transform: translateY(calc(var(--input-py) + 1.5px + 0.6em - 50%));
56
+ transform: translateY(-50%) scale(0.8);
41
57
  transform-origin: left center;
42
- transition:
43
- transform 0.2s cubic-bezier(0.22, 0.61, 0.36, 1),
44
- color 0.15s ease;
45
58
  white-space: nowrap;
46
59
  }
47
60
 
48
61
  .chayns-combo-box__chevron {
49
- position: absolute;
50
- inset-block-start: 50%;
51
- inset-inline-end: var(--input-px);
52
62
  display: inline-flex;
63
+ flex: none;
53
64
  align-items: center;
54
65
  justify-content: center;
55
66
  color: var(--muted);
56
- pointer-events: none;
57
- transform: translateY(-50%);
58
67
  transition: transform 0.18s ease;
59
68
  }
60
69
 
61
70
  .chayns-combo-box--open .chayns-combo-box__chevron {
62
- transform: translateY(-50%) rotate(180deg);
63
- }
64
-
65
- .chayns-combo-box--open .chayns-combo-box__label,
66
- .chayns-combo-box__input:not(:placeholder-shown) + .chayns-combo-box__label {
67
- color: var(--accent);
68
- transform: translateY(-50%) scale(0.8);
69
- }
70
-
71
- .chayns-combo-box__chips {
72
- position: absolute;
73
- inset: 1.5px var(--input-px) auto;
74
- display: flex;
75
- flex-wrap: wrap;
76
- gap: var(--k5);
77
- pointer-events: none;
78
- transform: translateY(var(--input-py));
79
- }
80
-
81
- .chayns-combo-box__chip {
82
- display: inline-flex;
83
- align-items: center;
84
- gap: var(--k5);
85
- padding: var(--k3) var(--k9);
86
- border-radius: 999px;
87
- background: var(--accent);
88
- color: var(--on-accent);
89
- font-size: var(--fs-caption);
90
- font-weight: 500;
71
+ transform: rotate(180deg);
91
72
  }
92
73
 
93
74
  .chayns-combo-box__popup {
@@ -107,16 +88,18 @@
107
88
  .chayns-combo-box__option {
108
89
  display: flex;
109
90
  align-items: center;
110
- min-block-size: var(--k40);
111
- padding: var(--k9) var(--k12);
91
+ min-block-size: var(--k32);
92
+ padding: var(--k6) var(--k12);
112
93
  border-radius: 8px;
113
94
  color: var(--text);
114
95
  cursor: pointer;
115
96
  font-size: var(--fs-body);
97
+ outline: none;
116
98
  }
117
99
 
118
100
  .chayns-combo-box__option:hover,
119
- .chayns-combo-box__option--active {
101
+ .chayns-combo-box__option--active,
102
+ .chayns-combo-box__option:focus-visible {
120
103
  background: var(--surface-alt);
121
104
  }
122
105
 
@@ -125,6 +108,11 @@
125
108
  font-weight: 600;
126
109
  }
127
110
 
111
+ .chayns-combo-box__option--disabled {
112
+ cursor: not-allowed;
113
+ opacity: 0.5;
114
+ }
115
+
128
116
  .chayns-combo-box__checkbox {
129
117
  display: inline-flex;
130
118
  flex: none;
@@ -152,9 +140,13 @@
152
140
  transform: rotate(-45deg) translate(1px, -1px);
153
141
  }
154
142
 
143
+ .chayns-combo-box__checkmark {
144
+ margin-inline-start: auto;
145
+ color: var(--accent);
146
+ }
147
+
155
148
  @media (prefers-reduced-motion: reduce) {
156
- .chayns-combo-box__input,
157
- .chayns-combo-box__label,
149
+ .chayns-combo-box__trigger,
158
150
  .chayns-combo-box__chevron {
159
151
  transition: none;
160
152
  }
@@ -18,7 +18,7 @@ export declare const BUTTON_VARIANTS: readonly ["primary", "outline", "ghost", "
18
18
  * Brands icons are rendered as a single icon and must not be combined with
19
19
  * `far` or `fas`.
20
20
  */
21
- export type ButtonIcon = `fa-${string}` | `fab fa-${string}`;
21
+ export type ButtonIcon = `fa-${string}` | `fab fa-${string}` | `ts-${string}`;
22
22
  /**
23
23
  * @description Visible content that gives a `Button` its accessible name.
24
24
  * Excludes `boolean`, `null` and `undefined` so a `Button` can never be
@@ -1 +1 @@
1
- {"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../src/components/button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEvE;;;GAGG;AACH,eAAO,MAAM,eAAe,oDAKiB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,MAAM,EAAE,GAAG,UAAU,MAAM,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Q,EAAE,aAAa,CAAC;CACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Button.types.js","names":[],"sources":["../../../src/components/button/Button.types.ts"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\n\n/**\n * @description Supported visual emphasis levels for {@link ButtonProps} and\n * `IconButtonProps`. Milestone 1 supports exactly these four values; there is\n * no default variant and no fifth value.\n * @see {@link https://tappqa.tobit.com/Bodywork/DesignSystem/#buttons | DesignSystem — Buttons & Aktionen}\n */\nexport type ButtonVariant = 'primary' | 'outline' | 'ghost' | 'danger';\n\n/**\n * Runtime representation of the finite Button variant contract.\n * Keep this list as the single source for Storybook controls and iteration.\n */\nexport const BUTTON_VARIANTS = [\n 'primary',\n 'outline',\n 'ghost',\n 'danger',\n] as const satisfies readonly ButtonVariant[];\n\n/**\n * @description A FontAwesome Classic icon name (e.g. `fa-plus`) or a\n * FontAwesome Brands icon including its style prefix (e.g. `fab fa-github`).\n * Classic icons resolve the matching Regular and Solid weights internally;\n * Brands icons are rendered as a single icon and must not be combined with\n * `far` or `fas`.\n */\nexport type ButtonIcon = `fa-${string}` | `fab fa-${string}`;\n\n/**\n * @description Visible content that gives a `Button` its accessible name.\n * Excludes `boolean`, `null` and `undefined` so a `Button` can never be\n * rendered without real, visible label content.\n */\nexport type ButtonContent = Exclude<ReactNode, boolean | null | undefined>;\n\n/**\n * @description Props for a visible-label native action button. Renders a\n * native `<button>` and forwards all remaining native button props, events,\n * `className` and `ref`.\n */\nexport interface ButtonProps extends Omit<ComponentPropsWithRef<'button'>, 'children'> {\n /**\n * @description Visual emphasis that communicates the action's role within\n * its action scope. At most one `primary` action should exist per closed\n * action scope (page, card, dialog, drawer, form, wizard step, or closed\n * accordion content).\n */\n variant: ButtonVariant;\n\n /**\n * @description Optional leading FontAwesome Classic or Brands icon name.\n * Always rendered before `children`; there is no trailing-icon or icon-only\n * mode on `Button` itself — use `IconButton` for an icon-only action.\n */\n icon?: ButtonIcon;\n\n /**\n * Shows a spinner while preserving the button label and prevents repeated\n * activation through the native disabled state.\n */\n loading?: boolean;\n\n /**\n * @description Visible, non-empty content used as the button label. Loading\n * preserves this content while adding a spinner.\n */\n children: ButtonContent;\n}\n"],"mappings":";;;;;AAcA,IAAa,kBAAkB;CAC7B;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"Button.types.js","names":[],"sources":["../../../src/components/button/Button.types.ts"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\n\n/**\n * @description Supported visual emphasis levels for {@link ButtonProps} and\n * `IconButtonProps`. Milestone 1 supports exactly these four values; there is\n * no default variant and no fifth value.\n * @see {@link https://tappqa.tobit.com/Bodywork/DesignSystem/#buttons | DesignSystem — Buttons & Aktionen}\n */\nexport type ButtonVariant = 'primary' | 'outline' | 'ghost' | 'danger';\n\n/**\n * Runtime representation of the finite Button variant contract.\n * Keep this list as the single source for Storybook controls and iteration.\n */\nexport const BUTTON_VARIANTS = [\n 'primary',\n 'outline',\n 'ghost',\n 'danger',\n] as const satisfies readonly ButtonVariant[];\n\n/**\n * @description A FontAwesome Classic icon name (e.g. `fa-plus`) or a\n * FontAwesome Brands icon including its style prefix (e.g. `fab fa-github`).\n * Classic icons resolve the matching Regular and Solid weights internally;\n * Brands icons are rendered as a single icon and must not be combined with\n * `far` or `fas`.\n */\nexport type ButtonIcon = `fa-${string}` | `fab fa-${string}` | `ts-${string}`;\n\n/**\n * @description Visible content that gives a `Button` its accessible name.\n * Excludes `boolean`, `null` and `undefined` so a `Button` can never be\n * rendered without real, visible label content.\n */\nexport type ButtonContent = Exclude<ReactNode, boolean | null | undefined>;\n\n/**\n * @description Props for a visible-label native action button. Renders a\n * native `<button>` and forwards all remaining native button props, events,\n * `className` and `ref`.\n */\nexport interface ButtonProps extends Omit<ComponentPropsWithRef<'button'>, 'children'> {\n /**\n * @description Visual emphasis that communicates the action's role within\n * its action scope. At most one `primary` action should exist per closed\n * action scope (page, card, dialog, drawer, form, wizard step, or closed\n * accordion content).\n */\n variant: ButtonVariant;\n\n /**\n * @description Optional leading FontAwesome Classic or Brands icon name.\n * Always rendered before `children`; there is no trailing-icon or icon-only\n * mode on `Button` itself — use `IconButton` for an icon-only action.\n */\n icon?: ButtonIcon;\n\n /**\n * Shows a spinner while preserving the button label and prevents repeated\n * activation through the native disabled state.\n */\n loading?: boolean;\n\n /**\n * @description Visible, non-empty content used as the button label. Loading\n * preserves this content while adding a spinner.\n */\n children: ButtonContent;\n}\n"],"mappings":";;;;;AAcA,IAAa,kBAAkB;CAC7B;CACA;CACA;CACA;AACF"}
@@ -1,11 +1,11 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  //#region src/components/button/button-icon/ButtonIcon.tsx
3
3
  var ButtonIcon = ({ icon }) => {
4
- const isBrandIcon = icon.startsWith("fab ");
4
+ const isPlainIcon = icon.startsWith("fab ") || icon.startsWith("ts-");
5
5
  return /* @__PURE__ */ jsx("span", {
6
6
  "aria-hidden": "true",
7
7
  className: "chayns-button-icon",
8
- children: isBrandIcon ? /* @__PURE__ */ jsx("span", {
8
+ children: isPlainIcon ? /* @__PURE__ */ jsx("span", {
9
9
  className: "chayns-button-icon__weight",
10
10
  children: /* @__PURE__ */ jsx("i", { className: icon })
11
11
  }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonIcon.js","names":[],"sources":["../../../../src/components/button/button-icon/ButtonIcon.tsx"],"sourcesContent":["import type { ButtonIcon as ButtonIconName } from '../Button.types.js';\n\ninterface ButtonIconProps {\n icon: ButtonIconName;\n}\n\nconst ButtonIcon = ({ icon }: ButtonIconProps) => {\n const isBrandIcon = icon.startsWith('fab ');\n\n return (\n <span aria-hidden=\"true\" className=\"chayns-button-icon\">\n {isBrandIcon ? (\n <span className=\"chayns-button-icon__weight\">\n <i className={icon} />\n </span>\n ) : (\n <>\n <span className=\"chayns-button-icon__weight\">\n <i className={`far ${icon}`} />\n </span>\n <span className=\"chayns-button-icon__weight chayns-button-icon__weight--active\">\n <i className={`fas ${icon}`} />\n </span>\n </>\n )}\n </span>\n );\n};\n\nexport default ButtonIcon;\n"],"mappings":";;AAMA,IAAM,cAAc,EAAE,WAA4B;CAChD,MAAM,cAAc,KAAK,WAAW,MAAM;CAE1C,OACE,oBAAC,QAAD;EAAM,eAAY;EAAO,WAAU;EAChC,UAAA,cACC,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,KAAD,EAAG,WAAW,KAAO,CAAA;EACjB,CAAA,IAEN,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,KAAD,EAAG,WAAW,OAAO,OAAS,CAAA;EAC1B,CAAA,GACN,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,KAAD,EAAG,WAAW,OAAO,OAAS,CAAA;EAC1B,CAAA,CACN,EAAA,CAAA;CAEA,CAAA;AAEV"}
1
+ {"version":3,"file":"ButtonIcon.js","names":[],"sources":["../../../../src/components/button/button-icon/ButtonIcon.tsx"],"sourcesContent":["import type { ButtonIcon as ButtonIconName } from '../Button.types.js';\n\ninterface ButtonIconProps {\n icon: ButtonIconName;\n}\n\nconst ButtonIcon = ({ icon }: ButtonIconProps) => {\n const isPlainIcon = icon.startsWith('fab ') || icon.startsWith('ts-');\n\n return (\n <span aria-hidden=\"true\" className=\"chayns-button-icon\">\n {isPlainIcon ? (\n <span className=\"chayns-button-icon__weight\">\n <i className={icon} />\n </span>\n ) : (\n <>\n <span className=\"chayns-button-icon__weight\">\n <i className={`far ${icon}`} />\n </span>\n <span className=\"chayns-button-icon__weight chayns-button-icon__weight--active\">\n <i className={`fas ${icon}`} />\n </span>\n </>\n )}\n </span>\n );\n};\n\nexport default ButtonIcon;\n"],"mappings":";;AAMA,IAAM,cAAc,EAAE,WAA4B;CAChD,MAAM,cAAc,KAAK,WAAW,MAAM,KAAK,KAAK,WAAW,KAAK;CAEpE,OACE,oBAAC,QAAD;EAAM,eAAY;EAAO,WAAU;EAChC,UAAA,cACC,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,KAAD,EAAG,WAAW,KAAO,CAAA;EACjB,CAAA,IAEN,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,KAAD,EAAG,WAAW,OAAO,OAAS,CAAA;EAC1B,CAAA,GACN,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,KAAD,EAAG,WAAW,OAAO,OAAS,CAAA;EAC1B,CAAA,CACN,EAAA,CAAA;CAEA,CAAA;AAEV"}
@@ -1,5 +1,5 @@
1
1
  import type { ComboBoxOptionProps } from './ComboBox.types.js';
2
- declare const ComboBox: import("react").ForwardRefExoticComponent<(Omit<import("./ComboBox.types.js").ComboBoxSingleProps, "ref"> | Omit<import("./ComboBox.types.js").ComboBoxMultipleProps, "ref">) & import("react").RefAttributes<HTMLInputElement>> & {
2
+ declare const ComboBox: import("react").ForwardRefExoticComponent<(Omit<import("./ComboBox.types.js").ComboBoxSingleProps, "ref"> | Omit<import("./ComboBox.types.js").ComboBoxMultipleProps, "ref">) & import("react").RefAttributes<HTMLButtonElement>> & {
3
3
  Option: import("react").ForwardRefExoticComponent<Omit<ComboBoxOptionProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
4
4
  };
5
5
  export default ComboBox;
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.d.ts","sourceRoot":"","sources":["../../../src/components/combo-box/ComboBox.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,qBAAqB,CAAC;AA2U9E,QAAA,MAAM,QAAQ;;CAA0C,CAAC;AAEzD,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"ComboBox.d.ts","sourceRoot":"","sources":["../../../src/components/combo-box/ComboBox.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,qBAAqB,CAAC;AAqW9E,QAAA,MAAM,QAAQ;;CAA0C,CAAC;AAEzD,eAAe,QAAQ,CAAC"}
@@ -13,88 +13,100 @@ function getOptionElements(children) {
13
13
  });
14
14
  return options;
15
15
  }
16
- var Option = forwardRef(function Option({ children, className, value, ...optionProps }, ref) {
16
+ var Option = forwardRef(function Option({ children, className, disabled = false, value, ...optionProps }, ref) {
17
17
  const comboBox = useComboBoxContext();
18
- const isVisible = comboBox.visibleValues.includes(value);
19
18
  const isSelected = comboBox.isSelected(value);
19
+ const isActive = comboBox.activeValue === value;
20
20
  const resolvedClassName = [
21
21
  "chayns-combo-box__option",
22
22
  isSelected ? "chayns-combo-box__option--selected" : "",
23
- comboBox.activeValue === value ? "chayns-combo-box__option--active" : "",
23
+ isActive ? "chayns-combo-box__option--active" : "",
24
+ disabled ? "chayns-combo-box__option--disabled" : "",
24
25
  className
25
26
  ].filter(Boolean).join(" ");
26
- if (!isVisible) return null;
27
27
  return /* @__PURE__ */ jsxs("div", {
28
28
  ...optionProps,
29
+ "aria-disabled": disabled || void 0,
29
30
  "aria-selected": isSelected,
30
31
  className: resolvedClassName,
31
32
  id: comboBox.optionId(value),
32
- onMouseDown: (event) => event.preventDefault(),
33
33
  onClick: (event) => {
34
34
  optionProps.onClick?.(event);
35
- if (!event.defaultPrevented) comboBox.select(value);
35
+ if (!event.defaultPrevented && !disabled) comboBox.select(value);
36
36
  },
37
37
  onKeyDown: (event) => {
38
38
  optionProps.onKeyDown?.(event);
39
- if (!event.defaultPrevented && (event.key === "Enter" || event.key === " ")) {
39
+ if (!event.defaultPrevented && !disabled && (event.key === "Enter" || event.key === " ")) {
40
40
  event.preventDefault();
41
41
  comboBox.select(value);
42
42
  }
43
43
  },
44
44
  ref,
45
45
  role: "option",
46
- tabIndex: -1,
47
- children: [comboBox.multiple ? /* @__PURE__ */ jsx("span", {
48
- "aria-hidden": "true",
49
- className: "chayns-combo-box__checkbox",
50
- "data-checked": isSelected || void 0
51
- }) : null, children]
46
+ tabIndex: isActive && !disabled ? 0 : -1,
47
+ children: [
48
+ comboBox.multiple ? /* @__PURE__ */ jsx("span", {
49
+ "aria-hidden": "true",
50
+ className: "chayns-combo-box__checkbox",
51
+ "data-checked": isSelected || void 0
52
+ }) : null,
53
+ children,
54
+ !comboBox.multiple && isSelected ? /* @__PURE__ */ jsx("span", {
55
+ "aria-hidden": "true",
56
+ className: "chayns-combo-box__checkmark",
57
+ children: /* @__PURE__ */ jsx("i", { className: "fas fa-check" })
58
+ }) : null
59
+ ]
52
60
  });
53
61
  });
54
62
  var ComboBoxRoot = forwardRef(function ComboBoxRoot(props, ref) {
55
- const { "aria-label": ariaLabel, children, className, defaultValue, disabled, id, multiple = false, onValueChange, openOnFocus = true, placeholder, value, ...inputProps } = props;
63
+ const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, className, defaultValue, disabled, id, multiple = false, onClick, onKeyDown, onValueChange, placeholder, value, ...buttonProps } = props;
56
64
  const generatedId = useId();
57
- const inputId = id ?? generatedId;
58
- const listboxId = `${inputId}-listbox`;
65
+ const triggerId = id ?? generatedId;
66
+ const listboxId = `${triggerId}-listbox`;
67
+ const labelId = `${triggerId}-label`;
59
68
  const rootRef = useRef(null);
60
- const inputRef = useRef(null);
69
+ const triggerRef = useRef(null);
61
70
  const optionElements = useMemo(() => getOptionElements(children), [children]);
62
71
  const optionMap = useMemo(() => new Map(optionElements.map((option) => [option.props.value, option])), [optionElements]);
72
+ const focusableValues = optionElements.filter((option) => !option.props.disabled).map((option) => option.props.value);
63
73
  const defaultValues = multiple ? defaultValue?.map((option) => option.props.value) ?? [] : [];
64
74
  const controlledValues = multiple ? value?.map((option) => option.props.value) ?? [] : [];
65
75
  const [uncontrolledValue, setUncontrolledValue] = useState(multiple ? "" : defaultValue ?? "");
66
76
  const [uncontrolledValues, setUncontrolledValues] = useState(defaultValues);
67
- const [inputText, setInputText] = useState(multiple ? "" : defaultValue ?? "");
68
77
  const [open, setOpen] = useState(false);
69
78
  const [activeValue, setActiveValue] = useState();
70
79
  const isControlled = value !== void 0;
71
80
  const selectedValue = multiple ? "" : isControlled ? value : uncontrolledValue;
72
81
  const selectedValues = multiple ? isControlled ? controlledValues : uncontrolledValues : [];
73
- const normalizedFilter = inputText.trim().toLocaleLowerCase();
74
- const visibleValues = optionElements.filter((option) => {
75
- const label = getOptionLabel(option.props.children).toLocaleLowerCase();
76
- return normalizedFilter === "" || label.includes(normalizedFilter);
77
- }).map((option) => option.props.value);
82
+ const selectedOptions = selectedValues.map((selected) => optionMap.get(selected)).filter((option) => option !== void 0);
83
+ const selectedOption = optionMap.get(selectedValue);
84
+ const displayValue = multiple ? selectedOptions.map((option) => getOptionLabel(option.props.children)).join(", ") : selectedOption === void 0 ? "" : getOptionLabel(selectedOption.props.children);
85
+ const resolvedClassName = ["chayns-combo-box", open ? "chayns-combo-box--open" : ""].filter(Boolean).join(" ");
86
+ const triggerClassName = ["chayns-combo-box__trigger", className].filter(Boolean).join(" ");
87
+ const accessibleName = ariaLabelledBy ?? (ariaLabel === void 0 && placeholder !== void 0 ? labelId : void 0);
88
+ if (ariaLabel === void 0 && ariaLabelledBy === void 0 && placeholder === void 0) throw new Error("ComboBox requires placeholder, aria-label or aria-labelledby.");
78
89
  useEffect(() => {
79
- if (open && activeValue === void 0) setActiveValue(visibleValues[0]);
90
+ if (!open || activeValue === void 0) return;
91
+ document.getElementById(`${listboxId}-${activeValue.replace(/[^a-zA-Z0-9_-]/g, "-")}`)?.focus();
80
92
  }, [
81
93
  activeValue,
82
- open,
83
- visibleValues
94
+ listboxId,
95
+ open
84
96
  ]);
85
97
  useEffect(() => {
86
98
  if (!open) return;
87
99
  function closeOnOutsidePress(event) {
88
100
  if (event.target instanceof Node && !rootRef.current?.contains(event.target)) {
89
- commitInput();
90
101
  setOpen(false);
102
+ setActiveValue(void 0);
91
103
  }
92
104
  }
93
105
  document.addEventListener("pointerdown", closeOnOutsidePress);
94
106
  return () => document.removeEventListener("pointerdown", closeOnOutsidePress);
95
- });
96
- function setInputElement(element) {
97
- inputRef.current = element;
107
+ }, [open]);
108
+ function setTriggerElement(element) {
109
+ triggerRef.current = element;
98
110
  if (typeof ref === "function") ref(element);
99
111
  else if (ref !== null) ref.current = element;
100
112
  }
@@ -107,120 +119,111 @@ var ComboBoxRoot = forwardRef(function ComboBoxRoot(props, ref) {
107
119
  const nextOptions = nextValues.map((nextValue) => optionMap.get(nextValue)).filter((option) => option !== void 0);
108
120
  onValueChange?.(nextOptions);
109
121
  }
110
- function commitInput() {
111
- if (!multiple && inputText !== selectedValue) emitValue(inputText);
122
+ function closeAndFocusTrigger() {
123
+ setOpen(false);
124
+ setActiveValue(void 0);
125
+ triggerRef.current?.focus();
112
126
  }
113
127
  function select(nextValue) {
114
- if (multiple) {
115
- emitValues(selectedValues.includes(nextValue) ? selectedValues.filter((selected) => selected !== nextValue) : [...selectedValues, nextValue]);
116
- setInputText("");
117
- setActiveValue(void 0);
118
- setOpen(true);
119
- return;
120
- }
121
- const option = optionMap.get(nextValue);
122
- emitValue(nextValue);
123
- setInputText(option === void 0 ? nextValue : getOptionLabel(option.props.children));
124
- setActiveValue(void 0);
125
- setOpen(false);
128
+ if (multiple) emitValues(selectedValues.includes(nextValue) ? selectedValues.filter((selected) => selected !== nextValue) : [...selectedValues, nextValue]);
129
+ else emitValue(nextValue);
130
+ closeAndFocusTrigger();
126
131
  }
127
- function handleChange(event) {
128
- setInputText(event.target.value);
129
- setActiveValue(void 0);
132
+ function openPopup() {
133
+ if (disabled || focusableValues.length === 0) return;
134
+ const selectedFocusableValue = focusableValues.find((optionValue) => multiple ? selectedValues.includes(optionValue) : selectedValue === optionValue);
135
+ setActiveValue(selectedFocusableValue ?? focusableValues[0]);
130
136
  setOpen(true);
131
- props.onChange?.(event);
132
137
  }
133
- function handleBlur(event) {
134
- props.onBlur?.(event);
135
- if (!rootRef.current?.contains(event.relatedTarget)) {
136
- commitInput();
137
- setOpen(false);
138
+ function moveActive(direction) {
139
+ if (focusableValues.length === 0) return;
140
+ const currentIndex = activeValue === void 0 ? -1 : focusableValues.indexOf(activeValue);
141
+ const nextIndex = currentIndex === -1 ? direction === 1 ? 0 : focusableValues.length - 1 : (currentIndex + direction + focusableValues.length) % focusableValues.length;
142
+ setActiveValue(focusableValues[nextIndex]);
143
+ }
144
+ function handleTriggerClick(event) {
145
+ onClick?.(event);
146
+ if (!event.defaultPrevented) {
147
+ if (open) closeAndFocusTrigger();
148
+ else openPopup();
138
149
  }
139
150
  }
140
- function handleKeyDown(event) {
141
- const currentIndex = activeValue === void 0 ? -1 : visibleValues.indexOf(activeValue);
142
- let nextIndex = currentIndex;
143
- if (event.key === "ArrowDown") nextIndex = Math.min(currentIndex + 1, visibleValues.length - 1);
144
- if (event.key === "ArrowUp") nextIndex = Math.max(currentIndex - 1, 0);
145
- if (event.key === "Home") nextIndex = 0;
146
- if (event.key === "End") nextIndex = visibleValues.length - 1;
147
- if (nextIndex !== currentIndex && visibleValues[nextIndex] !== void 0) {
151
+ function handleTriggerKeyDown(event) {
152
+ onKeyDown?.(event);
153
+ if (event.defaultPrevented) return;
154
+ if (event.key === "Enter" || event.key === " " || event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "ArrowDown" && event.altKey) {
148
155
  event.preventDefault();
149
- setActiveValue(visibleValues[nextIndex]);
150
- setOpen(true);
151
- } else if (event.key === "Enter" && activeValue !== void 0) {
156
+ openPopup();
157
+ }
158
+ }
159
+ function handleListboxKeyDown(event) {
160
+ if (event.key === "ArrowDown") {
161
+ event.preventDefault();
162
+ moveActive(1);
163
+ } else if (event.key === "ArrowUp") {
152
164
  event.preventDefault();
153
- select(activeValue);
165
+ moveActive(-1);
166
+ } else if (event.key === "Home") {
167
+ event.preventDefault();
168
+ setActiveValue(focusableValues[0]);
169
+ } else if (event.key === "End") {
170
+ event.preventDefault();
171
+ setActiveValue(focusableValues.at(-1));
154
172
  } else if (event.key === "Escape") {
155
173
  event.preventDefault();
156
- setInputText(multiple ? "" : selectedValue);
157
- setActiveValue(void 0);
174
+ closeAndFocusTrigger();
175
+ } else if (event.key === "Tab") {
158
176
  setOpen(false);
177
+ setActiveValue(void 0);
159
178
  }
160
- props.onKeyDown?.(event);
161
179
  }
162
- const resolvedClassName = ["chayns-combo-box", open ? "chayns-combo-box--open" : ""].filter(Boolean).join(" ");
163
- const describedLabel = placeholder === void 0 ? void 0 : `${inputId}-label`;
164
- const selectedOptions = selectedValues.map((selected) => optionMap.get(selected)).filter((option) => option !== void 0);
165
- const inputClassName = ["chayns-combo-box__input", className].filter(Boolean).join(" ");
166
180
  return /* @__PURE__ */ jsx(ComboBoxContext.Provider, {
167
181
  value: {
168
182
  activeValue,
169
- close: () => setOpen(false),
170
- inputText,
171
183
  isSelected: (optionValue) => multiple ? selectedValues.includes(optionValue) : selectedValue === optionValue,
172
184
  multiple,
173
185
  optionId: (optionValue) => `${listboxId}-${optionValue.replace(/[^a-zA-Z0-9_-]/g, "-")}`,
174
- select,
175
- visibleValues
186
+ select
176
187
  },
177
188
  children: /* @__PURE__ */ jsxs("div", {
178
189
  className: resolvedClassName,
179
190
  ref: rootRef,
180
191
  children: [
181
- multiple ? /* @__PURE__ */ jsx("div", {
182
- className: "chayns-combo-box__chips",
183
- "aria-hidden": "true",
184
- children: selectedOptions.map((option) => /* @__PURE__ */ jsx("span", {
185
- className: "chayns-combo-box__chip",
186
- children: option.props.children
187
- }, option.props.value))
188
- }) : null,
189
- /* @__PURE__ */ jsx("input", {
190
- ...inputProps,
191
- "aria-activedescendant": open && activeValue ? `${listboxId}-${activeValue.replace(/[^a-zA-Z0-9_-]/g, "-")}` : void 0,
192
- "aria-autocomplete": "list",
192
+ /* @__PURE__ */ jsxs("button", {
193
+ ...buttonProps,
193
194
  "aria-controls": listboxId,
194
195
  "aria-expanded": open,
196
+ "aria-haspopup": "listbox",
195
197
  "aria-label": ariaLabel,
196
- className: inputClassName,
198
+ "aria-labelledby": accessibleName,
199
+ className: triggerClassName,
197
200
  disabled,
198
- id: inputId,
199
- onBlur: handleBlur,
200
- onChange: handleChange,
201
- onFocus: () => openOnFocus && setOpen(true),
202
- onKeyDown: handleKeyDown,
203
- placeholder: placeholder === void 0 ? void 0 : " ",
204
- ref: setInputElement,
205
- role: "combobox",
206
- value: inputText
201
+ id: triggerId,
202
+ onClick: handleTriggerClick,
203
+ onKeyDown: handleTriggerKeyDown,
204
+ ref: setTriggerElement,
205
+ type: "button",
206
+ children: [/* @__PURE__ */ jsx("span", {
207
+ className: "chayns-combo-box__value",
208
+ children: displayValue || placeholder
209
+ }), /* @__PURE__ */ jsx("span", {
210
+ "aria-hidden": "true",
211
+ className: "chayns-combo-box__chevron",
212
+ children: /* @__PURE__ */ jsx(ButtonIcon, { icon: "fa-chevron-down" })
213
+ })]
207
214
  }),
208
- placeholder !== void 0 ? /* @__PURE__ */ jsx("label", {
215
+ placeholder !== void 0 ? /* @__PURE__ */ jsx("span", {
209
216
  className: "chayns-combo-box__label",
210
- htmlFor: inputId,
211
- id: describedLabel,
217
+ id: labelId,
212
218
  children: placeholder
213
219
  }) : null,
214
- /* @__PURE__ */ jsx("span", {
215
- "aria-hidden": "true",
216
- className: "chayns-combo-box__chevron",
217
- children: /* @__PURE__ */ jsx(ButtonIcon, { icon: "fa-chevron-down" })
218
- }),
219
220
  open ? /* @__PURE__ */ jsx("div", {
220
221
  "aria-multiselectable": multiple || void 0,
221
222
  className: "chayns-combo-box__popup",
222
223
  id: listboxId,
224
+ onKeyDown: handleListboxKeyDown,
223
225
  role: "listbox",
226
+ tabIndex: -1,
224
227
  children
225
228
  }) : null
226
229
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.js","names":[],"sources":["../../../src/components/combo-box/ComboBox.tsx"],"sourcesContent":["import {\n Children,\n forwardRef,\n Fragment,\n isValidElement,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { ChangeEvent, FocusEvent, KeyboardEvent, ReactElement, ReactNode } from 'react';\n\nimport ButtonIcon from '../button/button-icon/ButtonIcon.js';\nimport { ComboBoxContext, getOptionLabel, useComboBoxContext } from './ComboBoxContext.js';\nimport type { ComboBoxOptionProps, ComboBoxProps } from './ComboBox.types.js';\n\nfunction getOptionElements(children: ComboBoxProps['children']) {\n const options: ReactElement<ComboBoxOptionProps>[] = [];\n\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) {\n return;\n }\n\n const element = child as ReactElement<{ children?: ReactNode; value?: string }>;\n\n if (element.type === Fragment) {\n options.push(...getOptionElements(element.props.children));\n } else if (typeof element.props.value === 'string') {\n options.push(element as ReactElement<ComboBoxOptionProps>);\n }\n });\n\n return options;\n}\n\nconst Option = forwardRef<HTMLDivElement, ComboBoxOptionProps>(function Option(\n { children, className, value, ...optionProps },\n ref,\n) {\n const comboBox = useComboBoxContext();\n const isVisible = comboBox.visibleValues.includes(value);\n const isSelected = comboBox.isSelected(value);\n const resolvedClassName = [\n 'chayns-combo-box__option',\n isSelected ? 'chayns-combo-box__option--selected' : '',\n comboBox.activeValue === value ? 'chayns-combo-box__option--active' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n if (!isVisible) {\n return null;\n }\n\n return (\n <div\n {...optionProps}\n aria-selected={isSelected}\n className={resolvedClassName}\n id={comboBox.optionId(value)}\n onMouseDown={(event) => event.preventDefault()}\n onClick={(event) => {\n optionProps.onClick?.(event);\n if (!event.defaultPrevented) {\n comboBox.select(value);\n }\n }}\n onKeyDown={(event) => {\n optionProps.onKeyDown?.(event);\n if (!event.defaultPrevented && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n comboBox.select(value);\n }\n }}\n ref={ref}\n role=\"option\"\n tabIndex={-1}\n >\n {comboBox.multiple ? (\n <span\n aria-hidden=\"true\"\n className=\"chayns-combo-box__checkbox\"\n data-checked={isSelected || undefined}\n />\n ) : null}\n {children}\n </div>\n );\n});\n\nconst ComboBoxRoot = forwardRef<HTMLInputElement, ComboBoxProps>(function ComboBoxRoot(props, ref) {\n const {\n 'aria-label': ariaLabel,\n children,\n className,\n defaultValue,\n disabled,\n id,\n multiple = false,\n onValueChange,\n openOnFocus = true,\n placeholder,\n value,\n ...inputProps\n } = props;\n const generatedId = useId();\n const inputId = id ?? generatedId;\n const listboxId = `${inputId}-listbox`;\n const rootRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const optionElements = useMemo(() => getOptionElements(children), [children]);\n const optionMap = useMemo(\n () => new Map(optionElements.map((option) => [option.props.value, option])),\n [optionElements],\n );\n const defaultValues = multiple\n ? ((defaultValue as ReactElement<ComboBoxOptionProps>[] | undefined)?.map(\n (option) => option.props.value,\n ) ?? [])\n : [];\n const controlledValues = multiple\n ? ((value as ReactElement<ComboBoxOptionProps>[] | undefined)?.map(\n (option) => option.props.value,\n ) ?? [])\n : [];\n const [uncontrolledValue, setUncontrolledValue] = useState(\n multiple ? '' : ((defaultValue as string | undefined) ?? ''),\n );\n const [uncontrolledValues, setUncontrolledValues] = useState(defaultValues);\n const [inputText, setInputText] = useState(\n multiple ? '' : ((defaultValue as string | undefined) ?? ''),\n );\n const [open, setOpen] = useState(false);\n const [activeValue, setActiveValue] = useState<string>();\n const isControlled = value !== undefined;\n const selectedValue = multiple ? '' : isControlled ? (value as string) : uncontrolledValue;\n const selectedValues = multiple ? (isControlled ? controlledValues : uncontrolledValues) : [];\n const normalizedFilter = inputText.trim().toLocaleLowerCase();\n const visibleValues = optionElements\n .filter((option) => {\n const label = getOptionLabel(option.props.children).toLocaleLowerCase();\n return normalizedFilter === '' || label.includes(normalizedFilter);\n })\n .map((option) => option.props.value);\n\n useEffect(() => {\n if (open && activeValue === undefined) {\n setActiveValue(visibleValues[0]);\n }\n }, [activeValue, open, visibleValues]);\n\n useEffect(() => {\n if (!open) {\n return undefined;\n }\n\n function closeOnOutsidePress(event: PointerEvent) {\n if (event.target instanceof Node && !rootRef.current?.contains(event.target)) {\n commitInput();\n setOpen(false);\n }\n }\n\n document.addEventListener('pointerdown', closeOnOutsidePress);\n return () => document.removeEventListener('pointerdown', closeOnOutsidePress);\n });\n\n function setInputElement(element: HTMLInputElement | null) {\n inputRef.current = element;\n\n if (typeof ref === 'function') {\n ref(element);\n } else if (ref !== null) {\n ref.current = element;\n }\n }\n\n function emitValue(nextValue: string) {\n if (!isControlled) {\n setUncontrolledValue(nextValue);\n }\n\n (onValueChange as ((next: string) => void) | undefined)?.(nextValue);\n }\n\n function emitValues(nextValues: string[]) {\n if (!isControlled) {\n setUncontrolledValues(nextValues);\n }\n\n const nextOptions = nextValues\n .map((nextValue) => optionMap.get(nextValue))\n .filter((option): option is ReactElement<ComboBoxOptionProps> => option !== undefined);\n (onValueChange as ((next: ReactElement<ComboBoxOptionProps>[]) => void) | undefined)?.(\n nextOptions,\n );\n }\n\n function commitInput() {\n if (!multiple && inputText !== selectedValue) {\n emitValue(inputText);\n }\n }\n\n function select(nextValue: string) {\n if (multiple) {\n const nextValues = selectedValues.includes(nextValue)\n ? selectedValues.filter((selected) => selected !== nextValue)\n : [...selectedValues, nextValue];\n emitValues(nextValues);\n setInputText('');\n setActiveValue(undefined);\n setOpen(true);\n return;\n }\n\n const option = optionMap.get(nextValue);\n emitValue(nextValue);\n setInputText(option === undefined ? nextValue : getOptionLabel(option.props.children));\n setActiveValue(undefined);\n setOpen(false);\n }\n\n function handleChange(event: ChangeEvent<HTMLInputElement>) {\n setInputText(event.target.value);\n setActiveValue(undefined);\n setOpen(true);\n props.onChange?.(event);\n }\n\n function handleBlur(event: FocusEvent<HTMLInputElement>) {\n props.onBlur?.(event);\n if (!rootRef.current?.contains(event.relatedTarget)) {\n commitInput();\n setOpen(false);\n }\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLInputElement>) {\n const currentIndex = activeValue === undefined ? -1 : visibleValues.indexOf(activeValue);\n let nextIndex = currentIndex;\n\n if (event.key === 'ArrowDown') nextIndex = Math.min(currentIndex + 1, visibleValues.length - 1);\n if (event.key === 'ArrowUp') nextIndex = Math.max(currentIndex - 1, 0);\n if (event.key === 'Home') nextIndex = 0;\n if (event.key === 'End') nextIndex = visibleValues.length - 1;\n\n if (nextIndex !== currentIndex && visibleValues[nextIndex] !== undefined) {\n event.preventDefault();\n setActiveValue(visibleValues[nextIndex]);\n setOpen(true);\n } else if (event.key === 'Enter' && activeValue !== undefined) {\n event.preventDefault();\n select(activeValue);\n } else if (event.key === 'Escape') {\n event.preventDefault();\n setInputText(multiple ? '' : selectedValue);\n setActiveValue(undefined);\n setOpen(false);\n }\n\n props.onKeyDown?.(event);\n }\n\n const resolvedClassName = ['chayns-combo-box', open ? 'chayns-combo-box--open' : '']\n .filter(Boolean)\n .join(' ');\n const describedLabel = placeholder === undefined ? undefined : `${inputId}-label`;\n const selectedOptions = selectedValues\n .map((selected) => optionMap.get(selected))\n .filter((option): option is ReactElement<ComboBoxOptionProps> => option !== undefined);\n const inputClassName = ['chayns-combo-box__input', className].filter(Boolean).join(' ');\n\n return (\n <ComboBoxContext.Provider\n value={{\n activeValue,\n close: () => setOpen(false),\n inputText,\n isSelected: (optionValue) =>\n multiple ? selectedValues.includes(optionValue) : selectedValue === optionValue,\n multiple,\n optionId: (optionValue) => `${listboxId}-${optionValue.replace(/[^a-zA-Z0-9_-]/g, '-')}`,\n select,\n visibleValues,\n }}\n >\n <div className={resolvedClassName} ref={rootRef}>\n {multiple ? (\n <div className=\"chayns-combo-box__chips\" aria-hidden=\"true\">\n {selectedOptions.map((option) => (\n <span className=\"chayns-combo-box__chip\" key={option.props.value}>\n {option.props.children}\n </span>\n ))}\n </div>\n ) : null}\n <input\n {...inputProps}\n aria-activedescendant={\n open && activeValue\n ? `${listboxId}-${activeValue.replace(/[^a-zA-Z0-9_-]/g, '-')}`\n : undefined\n }\n aria-autocomplete=\"list\"\n aria-controls={listboxId}\n aria-expanded={open}\n aria-label={ariaLabel}\n className={inputClassName}\n disabled={disabled}\n id={inputId}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={() => openOnFocus && setOpen(true)}\n onKeyDown={handleKeyDown}\n placeholder={placeholder === undefined ? undefined : ' '}\n ref={setInputElement}\n role=\"combobox\"\n value={inputText}\n />\n {placeholder !== undefined ? (\n <label className=\"chayns-combo-box__label\" htmlFor={inputId} id={describedLabel}>\n {placeholder}\n </label>\n ) : null}\n <span aria-hidden=\"true\" className=\"chayns-combo-box__chevron\">\n <ButtonIcon icon=\"fa-chevron-down\" />\n </span>\n {open ? (\n <div\n aria-multiselectable={multiple || undefined}\n className=\"chayns-combo-box__popup\"\n id={listboxId}\n role=\"listbox\"\n >\n {children}\n </div>\n ) : null}\n </div>\n </ComboBoxContext.Provider>\n );\n});\n\nconst ComboBox = Object.assign(ComboBoxRoot, { Option });\n\nexport default ComboBox;\n"],"mappings":";;;;;AAiBA,SAAS,kBAAkB,UAAqC;CAC9D,MAAM,UAA+C,CAAC;CAEtD,SAAS,QAAQ,WAAW,UAAU;EACpC,IAAI,CAAC,eAAe,KAAK,GACvB;EAGF,MAAM,UAAU;EAEhB,IAAI,QAAQ,SAAS,UACnB,QAAQ,KAAK,GAAG,kBAAkB,QAAQ,MAAM,QAAQ,CAAC;OACpD,IAAI,OAAO,QAAQ,MAAM,UAAU,UACxC,QAAQ,KAAK,OAA4C;CAE7D,CAAC;CAED,OAAO;AACT;AAEA,IAAM,SAAS,WAAgD,SAAS,OACtE,EAAE,UAAU,WAAW,OAAO,GAAG,eACjC,KACA;CACA,MAAM,WAAW,mBAAmB;CACpC,MAAM,YAAY,SAAS,cAAc,SAAS,KAAK;CACvD,MAAM,aAAa,SAAS,WAAW,KAAK;CAC5C,MAAM,oBAAoB;EACxB;EACA,aAAa,uCAAuC;EACpD,SAAS,gBAAgB,QAAQ,qCAAqC;EACtE;CACF,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;CAEX,IAAI,CAAC,WACH,OAAO;CAGT,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,iBAAe;EACf,WAAW;EACX,IAAI,SAAS,SAAS,KAAK;EAC3B,cAAc,UAAU,MAAM,eAAe;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,GAAG,MAC1D,KAAA;KAEN,qBAAkB;KAClB,iBAAe;KACf,iBAAe;KACf,cAAY;KACZ,WAAW;KACD;KACV,IAAI;KACJ,QAAQ;KACR,UAAU;KACV,eAAe,eAAe,QAAQ,IAAI;KAC1C,WAAW;KACX,aAAa,gBAAgB,KAAA,IAAY,KAAA,IAAY;KACrD,KAAK;KACL,MAAK;KACL,OAAO;IACR,CAAA;IACA,gBAAgB,KAAA,IACf,oBAAC,SAAD;KAAO,WAAU;KAA0B,SAAS;KAAS,IAAI;KAC9D,UAAA;IACI,CAAA,IACL;IACJ,oBAAC,QAAD;KAAM,eAAY;KAAO,WAAU;KACjC,UAAA,oBAAC,YAAD,EAAY,MAAK,kBAAmB,CAAA;IAChC,CAAA;IACL,OACC,oBAAC,OAAD;KACE,wBAAsB,YAAY,KAAA;KAClC,WAAU;KACV,IAAI;KACJ,MAAK;KAEJ;IACE,CAAA,IACH;GACD;;CACmB,CAAA;AAE9B,CAAC;AAED,IAAM,WAAW,OAAO,OAAO,cAAc,EAAE,OAAO,CAAC"}
1
+ {"version":3,"file":"ComboBox.js","names":[],"sources":["../../../src/components/combo-box/ComboBox.tsx"],"sourcesContent":["import {\n Children,\n forwardRef,\n Fragment,\n isValidElement,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { KeyboardEvent, MouseEvent, ReactElement, ReactNode } from 'react';\n\nimport ButtonIcon from '../button/button-icon/ButtonIcon.js';\nimport { ComboBoxContext, getOptionLabel, useComboBoxContext } from './ComboBoxContext.js';\nimport type { ComboBoxOptionProps, ComboBoxProps } from './ComboBox.types.js';\n\nfunction getOptionElements(children: ComboBoxProps['children']) {\n const options: ReactElement<ComboBoxOptionProps>[] = [];\n\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) {\n return;\n }\n\n const element = child as ReactElement<{ children?: ReactNode; value?: string }>;\n\n if (element.type === Fragment) {\n options.push(...getOptionElements(element.props.children));\n } else if (typeof element.props.value === 'string') {\n options.push(element as ReactElement<ComboBoxOptionProps>);\n }\n });\n\n return options;\n}\n\nconst Option = forwardRef<HTMLDivElement, ComboBoxOptionProps>(function Option(\n { children, className, disabled = false, value, ...optionProps },\n ref,\n) {\n const comboBox = useComboBoxContext();\n const isSelected = comboBox.isSelected(value);\n const isActive = comboBox.activeValue === value;\n const resolvedClassName = [\n 'chayns-combo-box__option',\n isSelected ? 'chayns-combo-box__option--selected' : '',\n isActive ? 'chayns-combo-box__option--active' : '',\n disabled ? 'chayns-combo-box__option--disabled' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <div\n {...optionProps}\n aria-disabled={disabled || undefined}\n aria-selected={isSelected}\n className={resolvedClassName}\n id={comboBox.optionId(value)}\n onClick={(event) => {\n optionProps.onClick?.(event);\n if (!event.defaultPrevented && !disabled) {\n comboBox.select(value);\n }\n }}\n onKeyDown={(event) => {\n optionProps.onKeyDown?.(event);\n if (!event.defaultPrevented && !disabled && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n comboBox.select(value);\n }\n }}\n ref={ref}\n role=\"option\"\n tabIndex={isActive && !disabled ? 0 : -1}\n >\n {comboBox.multiple ? (\n <span\n aria-hidden=\"true\"\n className=\"chayns-combo-box__checkbox\"\n data-checked={isSelected || undefined}\n />\n ) : null}\n {children}\n {!comboBox.multiple && isSelected ? (\n <span aria-hidden=\"true\" className=\"chayns-combo-box__checkmark\">\n <i className=\"fas fa-check\" />\n </span>\n ) : null}\n </div>\n );\n});\n\nconst ComboBoxRoot = forwardRef<HTMLButtonElement, ComboBoxProps>(function ComboBoxRoot(props, ref) {\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n children,\n className,\n defaultValue,\n disabled,\n id,\n multiple = false,\n onClick,\n onKeyDown,\n onValueChange,\n placeholder,\n value,\n ...buttonProps\n } = props;\n const generatedId = useId();\n const triggerId = id ?? generatedId;\n const listboxId = `${triggerId}-listbox`;\n const labelId = `${triggerId}-label`;\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const optionElements = useMemo(() => getOptionElements(children), [children]);\n const optionMap = useMemo(\n () => new Map(optionElements.map((option) => [option.props.value, option])),\n [optionElements],\n );\n const focusableValues = optionElements\n .filter((option) => !option.props.disabled)\n .map((option) => option.props.value);\n const defaultValues = multiple\n ? ((defaultValue as ReactElement<ComboBoxOptionProps>[] | undefined)?.map(\n (option) => option.props.value,\n ) ?? [])\n : [];\n const controlledValues = multiple\n ? ((value as ReactElement<ComboBoxOptionProps>[] | undefined)?.map(\n (option) => option.props.value,\n ) ?? [])\n : [];\n const [uncontrolledValue, setUncontrolledValue] = useState(\n multiple ? '' : ((defaultValue as string | undefined) ?? ''),\n );\n const [uncontrolledValues, setUncontrolledValues] = useState(defaultValues);\n const [open, setOpen] = useState(false);\n const [activeValue, setActiveValue] = useState<string>();\n const isControlled = value !== undefined;\n const selectedValue = multiple ? '' : isControlled ? (value as string) : uncontrolledValue;\n const selectedValues = multiple ? (isControlled ? controlledValues : uncontrolledValues) : [];\n const selectedOptions = selectedValues\n .map((selected) => optionMap.get(selected))\n .filter((option): option is ReactElement<ComboBoxOptionProps> => option !== undefined);\n const selectedOption = optionMap.get(selectedValue);\n const displayValue = multiple\n ? selectedOptions.map((option) => getOptionLabel(option.props.children)).join(', ')\n : selectedOption === undefined\n ? ''\n : getOptionLabel(selectedOption.props.children);\n const resolvedClassName = ['chayns-combo-box', open ? 'chayns-combo-box--open' : '']\n .filter(Boolean)\n .join(' ');\n const triggerClassName = ['chayns-combo-box__trigger', className].filter(Boolean).join(' ');\n const accessibleName = ariaLabelledBy ?? (ariaLabel === undefined && placeholder !== undefined ? labelId : undefined);\n\n if (ariaLabel === undefined && ariaLabelledBy === undefined && placeholder === undefined) {\n throw new Error('ComboBox requires placeholder, aria-label or aria-labelledby.');\n }\n\n useEffect(() => {\n if (!open || activeValue === undefined) {\n return;\n }\n\n document\n .getElementById(`${listboxId}-${activeValue.replace(/[^a-zA-Z0-9_-]/g, '-')}`)\n ?.focus();\n }, [activeValue, listboxId, open]);\n\n useEffect(() => {\n if (!open) {\n return undefined;\n }\n\n function closeOnOutsidePress(event: PointerEvent) {\n if (event.target instanceof Node && !rootRef.current?.contains(event.target)) {\n setOpen(false);\n setActiveValue(undefined);\n }\n }\n\n document.addEventListener('pointerdown', closeOnOutsidePress);\n return () => document.removeEventListener('pointerdown', closeOnOutsidePress);\n }, [open]);\n\n function setTriggerElement(element: HTMLButtonElement | null) {\n triggerRef.current = element;\n\n if (typeof ref === 'function') {\n ref(element);\n } else if (ref !== null) {\n ref.current = element;\n }\n }\n\n function emitValue(nextValue: string) {\n if (!isControlled) {\n setUncontrolledValue(nextValue);\n }\n\n (onValueChange as ((next: string) => void) | undefined)?.(nextValue);\n }\n\n function emitValues(nextValues: string[]) {\n if (!isControlled) {\n setUncontrolledValues(nextValues);\n }\n\n const nextOptions = nextValues\n .map((nextValue) => optionMap.get(nextValue))\n .filter((option): option is ReactElement<ComboBoxOptionProps> => option !== undefined);\n (onValueChange as ((next: ReactElement<ComboBoxOptionProps>[]) => void) | undefined)?.(\n nextOptions,\n );\n }\n\n function closeAndFocusTrigger() {\n setOpen(false);\n setActiveValue(undefined);\n triggerRef.current?.focus();\n }\n\n function select(nextValue: string) {\n if (multiple) {\n const nextValues = selectedValues.includes(nextValue)\n ? selectedValues.filter((selected) => selected !== nextValue)\n : [...selectedValues, nextValue];\n emitValues(nextValues);\n } else {\n emitValue(nextValue);\n }\n\n closeAndFocusTrigger();\n }\n\n function openPopup() {\n if (disabled || focusableValues.length === 0) {\n return;\n }\n\n const selectedFocusableValue = focusableValues.find((optionValue) =>\n multiple ? selectedValues.includes(optionValue) : selectedValue === optionValue,\n );\n setActiveValue(selectedFocusableValue ?? focusableValues[0]);\n setOpen(true);\n }\n\n function moveActive(direction: 1 | -1) {\n if (focusableValues.length === 0) {\n return;\n }\n\n const currentIndex = activeValue === undefined ? -1 : focusableValues.indexOf(activeValue);\n const nextIndex =\n currentIndex === -1\n ? direction === 1\n ? 0\n : focusableValues.length - 1\n : (currentIndex + direction + focusableValues.length) % focusableValues.length;\n setActiveValue(focusableValues[nextIndex]);\n }\n\n function handleTriggerClick(event: MouseEvent<HTMLButtonElement>) {\n onClick?.(event);\n if (!event.defaultPrevented) {\n if (open) {\n closeAndFocusTrigger();\n } else {\n openPopup();\n }\n }\n }\n\n function handleTriggerKeyDown(event: KeyboardEvent<HTMLButtonElement>) {\n onKeyDown?.(event);\n if (event.defaultPrevented) {\n return;\n }\n\n if (\n event.key === 'Enter' ||\n event.key === ' ' ||\n event.key === 'ArrowDown' ||\n event.key === 'ArrowUp' ||\n (event.key === 'ArrowDown' && event.altKey)\n ) {\n event.preventDefault();\n openPopup();\n }\n }\n\n function handleListboxKeyDown(event: KeyboardEvent<HTMLDivElement>) {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n moveActive(1);\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n moveActive(-1);\n } else if (event.key === 'Home') {\n event.preventDefault();\n setActiveValue(focusableValues[0]);\n } else if (event.key === 'End') {\n event.preventDefault();\n setActiveValue(focusableValues.at(-1));\n } else if (event.key === 'Escape') {\n event.preventDefault();\n closeAndFocusTrigger();\n } else if (event.key === 'Tab') {\n setOpen(false);\n setActiveValue(undefined);\n }\n }\n\n return (\n <ComboBoxContext.Provider\n value={{\n activeValue,\n isSelected: (optionValue) =>\n multiple ? selectedValues.includes(optionValue) : selectedValue === optionValue,\n multiple,\n optionId: (optionValue) => `${listboxId}-${optionValue.replace(/[^a-zA-Z0-9_-]/g, '-')}`,\n select,\n }}\n >\n <div className={resolvedClassName} ref={rootRef}>\n <button\n {...buttonProps}\n aria-controls={listboxId}\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-label={ariaLabel}\n aria-labelledby={accessibleName}\n className={triggerClassName}\n disabled={disabled}\n id={triggerId}\n onClick={handleTriggerClick}\n onKeyDown={handleTriggerKeyDown}\n ref={setTriggerElement}\n type=\"button\"\n >\n <span className=\"chayns-combo-box__value\">{displayValue || placeholder}</span>\n <span aria-hidden=\"true\" className=\"chayns-combo-box__chevron\">\n <ButtonIcon icon=\"fa-chevron-down\" />\n </span>\n </button>\n {placeholder !== undefined ? (\n <span className=\"chayns-combo-box__label\" id={labelId}>\n {placeholder}\n </span>\n ) : null}\n {open ? (\n <div\n aria-multiselectable={multiple || undefined}\n className=\"chayns-combo-box__popup\"\n id={listboxId}\n onKeyDown={handleListboxKeyDown}\n role=\"listbox\"\n tabIndex={-1}\n >\n {children}\n </div>\n ) : null}\n </div>\n </ComboBoxContext.Provider>\n );\n});\n\nconst ComboBox = Object.assign(ComboBoxRoot, { Option });\n\nexport default ComboBox;\n"],"mappings":";;;;;AAiBA,SAAS,kBAAkB,UAAqC;CAC9D,MAAM,UAA+C,CAAC;CAEtD,SAAS,QAAQ,WAAW,UAAU;EACpC,IAAI,CAAC,eAAe,KAAK,GACvB;EAGF,MAAM,UAAU;EAEhB,IAAI,QAAQ,SAAS,UACnB,QAAQ,KAAK,GAAG,kBAAkB,QAAQ,MAAM,QAAQ,CAAC;OACpD,IAAI,OAAO,QAAQ,MAAM,UAAU,UACxC,QAAQ,KAAK,OAA4C;CAE7D,CAAC;CAED,OAAO;AACT;AAEA,IAAM,SAAS,WAAgD,SAAS,OACtE,EAAE,UAAU,WAAW,WAAW,OAAO,OAAO,GAAG,eACnD,KACA;CACA,MAAM,WAAW,mBAAmB;CACpC,MAAM,aAAa,SAAS,WAAW,KAAK;CAC5C,MAAM,WAAW,SAAS,gBAAgB;CAC1C,MAAM,oBAAoB;EACxB;EACA,aAAa,uCAAuC;EACpD,WAAW,qCAAqC;EAChD,WAAW,uCAAuC;EAClD;CACF,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;CAEX,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,iBAAe,YAAY,KAAA;EAC3B,iBAAe;EACf,WAAW;EACX,IAAI,SAAS,SAAS,KAAK;EAC3B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1B;CACF;CAEA,OACE,oBAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,aAAa,gBACX,WAAW,eAAe,SAAS,WAAW,IAAI,kBAAkB;GACtE;GACA,WAAW,gBAAgB,GAAG,UAAU,GAAG,YAAY,QAAQ,mBAAmB,GAAG;GACrF;EACF;EAEA,UAAA,qBAAC,OAAD;GAAK,WAAW;GAAmB,KAAK;GAAxC,UAAA;IACE,qBAAC,UAAD;KACE,GAAI;KACJ,iBAAe;KACf,iBAAe;KACf,iBAAc;KACd,cAAY;KACZ,mBAAiB;KACjB,WAAW;KACD;KACV,IAAI;KACJ,SAAS;KACT,WAAW;KACX,KAAK;KACL,MAAK;KAbP,UAAA,CAeE,oBAAC,QAAD;MAAM,WAAU;MAA2B,UAAA,gBAAgB;KAAkB,CAAA,GAC7E,oBAAC,QAAD;MAAM,eAAY;MAAO,WAAU;MACjC,UAAA,oBAAC,YAAD,EAAY,MAAK,kBAAmB,CAAA;KAChC,CAAA,CACA;;IACP,gBAAgB,KAAA,IACf,oBAAC,QAAD;KAAM,WAAU;KAA0B,IAAI;KAC3C,UAAA;IACG,CAAA,IACJ;IACH,OACC,oBAAC,OAAD;KACE,wBAAsB,YAAY,KAAA;KAClC,WAAU;KACV,IAAI;KACJ,WAAW;KACX,MAAK;KACL,UAAU;KAET;IACE,CAAA,IACH;GACD;;CACmB,CAAA;AAE9B,CAAC;AAED,IAAM,WAAW,OAAO,OAAO,cAAc,EAAE,OAAO,CAAC"}
@@ -1,19 +1,15 @@
1
1
  import type { ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
2
- export interface ComboBoxOptionProps extends Omit<ComponentPropsWithRef<'div'>, 'children' | 'role' | 'aria-selected'> {
2
+ export interface ComboBoxOptionProps extends Omit<ComponentPropsWithRef<'div'>, 'children' | 'role' | 'aria-selected' | 'tabIndex'> {
3
3
  value: string;
4
4
  children: Exclude<ReactNode, boolean | null | undefined>;
5
+ disabled?: boolean;
5
6
  role?: never;
6
7
  'aria-selected'?: never;
8
+ tabIndex?: never;
7
9
  }
8
- type ComboBoxBaseProps = Omit<ComponentPropsWithRef<'input'>, 'children' | 'defaultValue' | 'value' | 'multiple' | 'role' | 'aria-activedescendant' | 'aria-controls' | 'aria-expanded' | 'aria-autocomplete' | 'onBlur' | 'onChange' | 'onKeyDown'> & {
10
+ type ComboBoxBaseProps = Omit<ComponentPropsWithRef<'button'>, 'children' | 'defaultValue' | 'value' | 'multiple' | 'type' | 'aria-controls' | 'aria-expanded' | 'aria-haspopup'> & {
9
11
  children: ReactNode;
10
- /** Bodywork floating label. */
11
12
  placeholder?: string;
12
- /** Opens the popup when the input receives focus. */
13
- openOnFocus?: boolean;
14
- onBlur?: ComponentPropsWithRef<'input'>['onBlur'];
15
- onChange?: ComponentPropsWithRef<'input'>['onChange'];
16
- onKeyDown?: ComponentPropsWithRef<'input'>['onKeyDown'];
17
13
  };
18
14
  export interface ComboBoxSingleProps extends ComboBoxBaseProps {
19
15
  multiple?: false;
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.types.d.ts","sourceRoot":"","sources":["../../../src/components/combo-box/ComboBox.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5E,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAC/C,qBAAqB,CAAC,KAAK,CAAC,EAC5B,UAAU,GAAG,MAAM,GAAG,eAAe,CACtC;IACC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,eAAe,CAAC,EAAE,KAAK,CAAC;CACzB;AAED,KAAK,iBAAiB,GAAG,IAAI,CAC3B,qBAAqB,CAAC,OAAO,CAAC,EAC5B,UAAU,GACV,cAAc,GACd,OAAO,GACP,UAAU,GACV,MAAM,GACN,uBAA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xOptionProps } from './ComboBox.types.js';
2
2
  export interface ComboBoxContextValue {
3
3
  activeValue?: string | undefined;
4
- close: () => void;
5
- inputText: string;
6
4
  isSelected: (value: string) => boolean;
7
5
  multiple: boolean;
8
6
  optionId: (value: string) => string;
9
7
  select: (value: string) => void;
10
- visibleValues: string[];
11
8
  }
12
9
  export declare const ComboBoxContext: import("react").Context<ComboBoxContextValue | null>;
13
10
  export declare function useComboBoxContext(): ComboBoxContextValue;
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBoxContext.d.ts","sourceRoot":"","sources":["../../../src/components/combo-box/ComboBoxContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,eAAO,MAAM,eAAe,sDAAmD,CAAC;AAEhF,wBAAgB,kBAAkB,IAAI,oBAAoB,CAQzD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,mBAAmB,CAAC,UAAU,CAAC,GAAG,MAAM,CAM9E"}
1
+ {"version":3,"file":"ComboBoxContext.d.ts","sourceRoot":"","sources":["../../../src/components/combo-box/ComboBoxContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,eAAO,MAAM,eAAe,sDAAmD,CAAC;AAEhF,wBAAgB,kBAAkB,IAAI,oBAAoB,CAQzD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,mBAAmB,CAAC,UAAU,CAAC,GAAG,MAAM,CAM9E"}
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBoxContext.js","names":[],"sources":["../../../src/components/combo-box/ComboBoxContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { ComboBoxOptionProps } from './ComboBox.types.js';\n\nexport interface ComboBoxContextValue {\n activeValue?: string | undefined;\n close: () => void;\n inputText: string;\n isSelected: (value: string) => boolean;\n multiple: boolean;\n optionId: (value: string) => string;\n select: (value: string) => void;\n visibleValues: string[];\n}\n\nexport const ComboBoxContext = createContext<ComboBoxContextValue | null>(null);\n\nexport function useComboBoxContext(): ComboBoxContextValue {\n const context = useContext(ComboBoxContext);\n\n if (context === null) {\n throw new Error('ComboBox.Option must be rendered within ComboBox.');\n }\n\n return context;\n}\n\nexport function getOptionLabel(option: ComboBoxOptionProps['children']): string {\n if (typeof option === 'string' || typeof option === 'number') {\n return String(option);\n }\n\n return '';\n}\n"],"mappings":";;AAeA,IAAa,kBAAkB,cAA2C,IAAI;AAE9E,SAAgB,qBAA2C;CACzD,MAAM,UAAU,WAAW,eAAe;CAE1C,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,mDAAmD;CAGrE,OAAO;AACT;AAEA,SAAgB,eAAe,QAAiD;CAC9E,IAAI,OAAO,WAAW,YAAY,OAAO,WAAW,UAClD,OAAO,OAAO,MAAM;CAGtB,OAAO;AACT"}
1
+ {"version":3,"file":"ComboBoxContext.js","names":[],"sources":["../../../src/components/combo-box/ComboBoxContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { ComboBoxOptionProps } from './ComboBox.types.js';\n\nexport interface ComboBoxContextValue {\n activeValue?: string | undefined;\n isSelected: (value: string) => boolean;\n multiple: boolean;\n optionId: (value: string) => string;\n select: (value: string) => void;\n}\n\nexport const ComboBoxContext = createContext<ComboBoxContextValue | null>(null);\n\nexport function useComboBoxContext(): ComboBoxContextValue {\n const context = useContext(ComboBoxContext);\n\n if (context === null) {\n throw new Error('ComboBox.Option must be rendered within ComboBox.');\n }\n\n return context;\n}\n\nexport function getOptionLabel(option: ComboBoxOptionProps['children']): string {\n if (typeof option === 'string' || typeof option === 'number') {\n return String(option);\n }\n\n return '';\n}\n"],"mappings":";;AAYA,IAAa,kBAAkB,cAA2C,IAAI;AAE9E,SAAgB,qBAA2C;CACzD,MAAM,UAAU,WAAW,eAAe;CAE1C,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,mDAAmD;CAGrE,OAAO;AACT;AAEA,SAAgB,eAAe,QAAiD;CAC9E,IAAI,OAAO,WAAW,YAAY,OAAO,WAAW,UAClD,OAAO,OAAO,MAAM;CAGtB,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-ui/core",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Accessible React core components for chayns UI",
5
5
  "license": "MIT",
6
6
  "type": "module",