@stack-spot/portal-components 2.5.2 → 2.6.1

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 (52) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/components/form/Select/CustomSelect.d.ts +81 -0
  3. package/dist/components/form/Select/CustomSelect.d.ts.map +1 -0
  4. package/dist/components/form/Select/CustomSelect.js +178 -0
  5. package/dist/components/form/Select/CustomSelect.js.map +1 -0
  6. package/dist/components/form/Select/DetailedSelect.d.ts +65 -0
  7. package/dist/components/form/Select/DetailedSelect.d.ts.map +1 -0
  8. package/dist/components/form/Select/DetailedSelect.js +80 -0
  9. package/dist/components/form/Select/DetailedSelect.js.map +1 -0
  10. package/dist/components/form/Select/Select.d.ts +47 -0
  11. package/dist/components/form/Select/Select.d.ts.map +1 -0
  12. package/dist/components/form/Select/Select.js +62 -0
  13. package/dist/components/form/Select/Select.js.map +1 -0
  14. package/dist/components/form/Select/index.d.ts +5 -0
  15. package/dist/components/form/Select/index.d.ts.map +1 -0
  16. package/dist/components/form/Select/index.js +5 -0
  17. package/dist/components/form/Select/index.js.map +1 -0
  18. package/dist/components/form/Select/styled.d.ts +6 -0
  19. package/dist/components/form/Select/styled.d.ts.map +1 -0
  20. package/dist/components/form/Select/styled.js +165 -0
  21. package/dist/components/form/Select/styled.js.map +1 -0
  22. package/dist/components/form/Select/types.d.ts +103 -0
  23. package/dist/components/form/Select/types.d.ts.map +1 -0
  24. package/dist/components/form/Select/types.js +2 -0
  25. package/dist/components/form/Select/types.js.map +1 -0
  26. package/dist/components/form/Select/utils.d.ts +3 -0
  27. package/dist/components/form/Select/utils.d.ts.map +1 -0
  28. package/dist/components/form/Select/utils.js +20 -0
  29. package/dist/components/form/Select/utils.js.map +1 -0
  30. package/dist/components/notification/NotificationItem.d.ts.map +1 -1
  31. package/dist/components/notification/NotificationItem.js +2 -2
  32. package/dist/components/notification/NotificationItem.js.map +1 -1
  33. package/dist/containers/NotificationsPage.js +1 -1
  34. package/dist/hooks/keyboard.d.ts +4 -4
  35. package/dist/hooks/keyboard.d.ts.map +1 -1
  36. package/dist/hooks/keyboard.js +2 -2
  37. package/dist/hooks/keyboard.js.map +1 -1
  38. package/package.json +2 -2
  39. package/src/components/form/Select/CustomSelect.tsx +232 -0
  40. package/src/components/form/Select/DetailedSelect.tsx +85 -0
  41. package/src/components/form/Select/Select.tsx +67 -0
  42. package/src/components/form/Select/index.ts +4 -0
  43. package/src/components/form/Select/styled.ts +165 -0
  44. package/src/components/form/Select/types.ts +112 -0
  45. package/src/components/form/Select/utils.tsx +28 -0
  46. package/src/components/notification/NotificationItem.tsx +6 -2
  47. package/src/hooks/keyboard.tsx +6 -4
  48. package/dist/components/form/Select.d.ts +0 -69
  49. package/dist/components/form/Select.d.ts.map +0 -1
  50. package/dist/components/form/Select.js +0 -162
  51. package/dist/components/form/Select.js.map +0 -1
  52. package/src/components/form/Select.tsx +0 -265
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.6.1](https://github.com/stack-spot/portal-commons/compare/portal-components@v2.6.0...portal-components@v2.6.1) (2024-09-26)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Accessibility 517 visualize notification button ([e919b44](https://github.com/stack-spot/portal-commons/commit/e919b446130c15d11c73b2d3336f92fee3f4c8b7))
9
+ * docs ([f488e48](https://github.com/stack-spot/portal-commons/commit/f488e48bdf0156265ddb6fcd279938c8a46c0bf1))
10
+
11
+ ## [2.6.0](https://github.com/stack-spot/portal-commons/compare/portal-components@v2.5.2...portal-components@v2.6.0) (2024-09-20)
12
+
13
+
14
+ ### Features
15
+
16
+ * enhance select ([#377](https://github.com/stack-spot/portal-commons/issues/377)) ([af5d011](https://github.com/stack-spot/portal-commons/commit/af5d011ed0c69f973160d9d7d2e3bb2992653dd0))
17
+
3
18
  ## [2.5.2](https://github.com/stack-spot/portal-commons/compare/portal-components@v2.5.1...portal-components@v2.5.2) (2024-09-16)
4
19
 
5
20
 
@@ -0,0 +1,81 @@
1
+ import { CustomSelectProps } from './types.js';
2
+ /**
3
+ * Renders a Select component using the Citric Design System.
4
+ *
5
+ * The styled version of the select component is rendered on top of the default select from the browser. Visual users will use the Citric
6
+ * version of a Select, but blind users, who interacts with the keyboard, will use the default browser select instead, which is already
7
+ * highly optimized for accessibility.
8
+ *
9
+ * The CustomSelect lets you customize how each option and the selected value are rendered. To do so, use the prop `renderLabel` and
10
+ * `emptyOption`.
11
+ *
12
+ * If you don't need fully customized labels, check the more simple components: `DetailedSelect` and `Select`.
13
+ *
14
+ * The CustomSelect expects a {@link GenericAccessibleLabel} to create labels.
15
+ *
16
+ * Tips:
17
+ * - This is a controlled field. You can't use it any other way. If you're using it with react-hook-form, you need to wrap it under the
18
+ * component `<Controller>` from the same library.
19
+ * - `value` is required and must be of the same type of an item of the array of options. `value` is only optional if `emptyOption` is
20
+ * provided, in this case, an empty option is rendered and the value is undefined when it's selected.
21
+ * - A consequence of the previous rule is that you can't have an empty selection if you don't set a value for `emptyOption`. This
22
+ * component must work exactly like the browser's `select`, so this behavior is intended.
23
+ * - If `renderLabel` or `renderValue` are not provided, this will use the `toString` method of the object.
24
+ *
25
+ * @example
26
+ * options as an object array
27
+ * ```
28
+ * const options = ['option 1', 'option 2', 'option 3']
29
+ *
30
+ * function renderCustomLabel(option: string) {
31
+ * return {
32
+ * // this is how the option will be rendered in the list
33
+ * option: (
34
+ * <div style={{ display: flex, flexDirection: 'row', gap: '5px' }}>
35
+ * <img src="/my-image.png" width="40px" height="40px" />
36
+ * <p>An option called {option}</p>
37
+ * </div>
38
+ * ),
39
+ * // this is how the option will be rendered inside the input, when it's the value currently selected.
40
+ * selected: <p>{option}</p>,
41
+ * // this a string representation of the option: used for accessibility. This should contain the same information as `option`.
42
+ * text: `An option called ${option}`,
43
+ * )
44
+ * }
45
+ *
46
+ * const MyComponent = {
47
+ * const [value, setValue] = useState(options[0])
48
+ * return <CustomSelect options={options} value={value} onChange={setValue} renderLabel={renderCustomLabel} />
49
+ * }
50
+ * ```
51
+ * @example
52
+ * options as an object array
53
+ * ```
54
+ * const options = [{ id: 1, name: 'John', age: 34 }, { id: 2, name: 'Marcia', age: 28 }, { id: 3, name: 'Angeline', age: 58 }]
55
+ *
56
+ * function renderCustomLabel(option: (typeof options)[number]) {
57
+ * return {
58
+ * // this is how the option will be rendered in the list
59
+ * option: (
60
+ * <div style={{ display: flex, flexDirection: 'row', gap: '5px' }}>
61
+ * <img src="/my-image.png" width="40px" height="40px" />
62
+ * <p>{option.name}, aged {option.age}</p>
63
+ * </div>
64
+ * ),
65
+ * // this is how the option will be rendered inside the input, when it's the value currently selected.
66
+ * selected: <p>{option}</p>,
67
+ * // this a string representation of the option: used for accessibility. This should contain the same information as `option`.
68
+ * text: `${option.name}, aged ${option.age}`,
69
+ * )
70
+ * }
71
+ *
72
+ * const MyComponent = {
73
+ * const [value, setValue] = useState(options[0])
74
+ * // below, renderValue could be `o => o.id`
75
+ * return <CustomSelect options={options} value={value} onChange={setValue} renderValue="id" renderLabel={renderCustomLabel} />
76
+ * }
77
+ * ```
78
+ * @param props the component props: {@link CustomSelectProps}.
79
+ */
80
+ export declare function CustomSelect<T>({ onChange, options, value, emptyOption, renderLabel, renderValue, maxItems, onFocus, onBlur, style, className, isLoading, disabled, height, ...props }: CustomSelectProps<T>): import("react/jsx-runtime").JSX.Element;
81
+ //# sourceMappingURL=CustomSelect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Select/CustomSelect.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAqC,MAAM,SAAS,CAAA;AAkC9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC9B,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,QAAY,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EACrI,MAAe,EAAE,GAAG,KAAK,EAC1B,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CA6GtB"}
@@ -0,0 +1,178 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { IconBox } from '@citric/core';
3
+ import { ChevronDown } from '@citric/icons';
4
+ import { LoadingCircular } from '@citric/ui';
5
+ import { listToClass } from '@stack-spot/portal-theme';
6
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
+ import { delay } from '../../../utils/promise.js';
8
+ import { SelectBox } from './styled.js';
9
+ import { parseLabel } from './utils.js';
10
+ function getOptionAsValue(option, renderer) {
11
+ let result;
12
+ if (typeof renderer === 'function')
13
+ result = option ? renderer(option) : undefined;
14
+ else if (typeof renderer === 'string')
15
+ result = option[renderer];
16
+ return result ? result : `${option ?? ''}`;
17
+ }
18
+ function getOptionAsLabel(option, renderer) {
19
+ let result;
20
+ if (typeof renderer === 'function')
21
+ result = option ? renderer(option) : undefined;
22
+ else if (typeof renderer === 'string')
23
+ result = option[renderer];
24
+ return result ? result : parseLabel(`${option ?? ''}`);
25
+ }
26
+ const FakeOption = ({ value, label, onChange }) => (_jsx("li", { className: "option", onClick: () => onChange({ target: { value } }), children: label }));
27
+ /**
28
+ * Renders a Select component using the Citric Design System.
29
+ *
30
+ * The styled version of the select component is rendered on top of the default select from the browser. Visual users will use the Citric
31
+ * version of a Select, but blind users, who interacts with the keyboard, will use the default browser select instead, which is already
32
+ * highly optimized for accessibility.
33
+ *
34
+ * The CustomSelect lets you customize how each option and the selected value are rendered. To do so, use the prop `renderLabel` and
35
+ * `emptyOption`.
36
+ *
37
+ * If you don't need fully customized labels, check the more simple components: `DetailedSelect` and `Select`.
38
+ *
39
+ * The CustomSelect expects a {@link GenericAccessibleLabel} to create labels.
40
+ *
41
+ * Tips:
42
+ * - This is a controlled field. You can't use it any other way. If you're using it with react-hook-form, you need to wrap it under the
43
+ * component `<Controller>` from the same library.
44
+ * - `value` is required and must be of the same type of an item of the array of options. `value` is only optional if `emptyOption` is
45
+ * provided, in this case, an empty option is rendered and the value is undefined when it's selected.
46
+ * - A consequence of the previous rule is that you can't have an empty selection if you don't set a value for `emptyOption`. This
47
+ * component must work exactly like the browser's `select`, so this behavior is intended.
48
+ * - If `renderLabel` or `renderValue` are not provided, this will use the `toString` method of the object.
49
+ *
50
+ * @example
51
+ * options as an object array
52
+ * ```
53
+ * const options = ['option 1', 'option 2', 'option 3']
54
+ *
55
+ * function renderCustomLabel(option: string) {
56
+ * return {
57
+ * // this is how the option will be rendered in the list
58
+ * option: (
59
+ * <div style={{ display: flex, flexDirection: 'row', gap: '5px' }}>
60
+ * <img src="/my-image.png" width="40px" height="40px" />
61
+ * <p>An option called {option}</p>
62
+ * </div>
63
+ * ),
64
+ * // this is how the option will be rendered inside the input, when it's the value currently selected.
65
+ * selected: <p>{option}</p>,
66
+ * // this a string representation of the option: used for accessibility. This should contain the same information as `option`.
67
+ * text: `An option called ${option}`,
68
+ * )
69
+ * }
70
+ *
71
+ * const MyComponent = {
72
+ * const [value, setValue] = useState(options[0])
73
+ * return <CustomSelect options={options} value={value} onChange={setValue} renderLabel={renderCustomLabel} />
74
+ * }
75
+ * ```
76
+ * @example
77
+ * options as an object array
78
+ * ```
79
+ * const options = [{ id: 1, name: 'John', age: 34 }, { id: 2, name: 'Marcia', age: 28 }, { id: 3, name: 'Angeline', age: 58 }]
80
+ *
81
+ * function renderCustomLabel(option: (typeof options)[number]) {
82
+ * return {
83
+ * // this is how the option will be rendered in the list
84
+ * option: (
85
+ * <div style={{ display: flex, flexDirection: 'row', gap: '5px' }}>
86
+ * <img src="/my-image.png" width="40px" height="40px" />
87
+ * <p>{option.name}, aged {option.age}</p>
88
+ * </div>
89
+ * ),
90
+ * // this is how the option will be rendered inside the input, when it's the value currently selected.
91
+ * selected: <p>{option}</p>,
92
+ * // this a string representation of the option: used for accessibility. This should contain the same information as `option`.
93
+ * text: `${option.name}, aged ${option.age}`,
94
+ * )
95
+ * }
96
+ *
97
+ * const MyComponent = {
98
+ * const [value, setValue] = useState(options[0])
99
+ * // below, renderValue could be `o => o.id`
100
+ * return <CustomSelect options={options} value={value} onChange={setValue} renderValue="id" renderLabel={renderCustomLabel} />
101
+ * }
102
+ * ```
103
+ * @param props the component props: {@link CustomSelectProps}.
104
+ */
105
+ export function CustomSelect({ onChange, options, value, emptyOption, renderLabel, renderValue, maxItems = 6, onFocus, onBlur, style, className, isLoading, disabled, height = '42px', ...props }) {
106
+ const [open, setOpen] = useState(false);
107
+ const [focused, setFocused] = useState(false);
108
+ const fakeSelectRef = useRef(null);
109
+ const listHeight = useRef(0);
110
+ const isDisabled = disabled || isLoading;
111
+ const isMeasuring = useRef(false);
112
+ const onChangeOption = useCallback((event) => {
113
+ const value = options?.find(o => getOptionAsValue(o, renderValue) === event.target.value);
114
+ onChange(value);
115
+ setOpen(false);
116
+ }, [options]);
117
+ const onClickOutside = useCallback((event) => {
118
+ if (fakeSelectRef.current && !fakeSelectRef.current.contains(event.target))
119
+ setOpen(false);
120
+ }, []);
121
+ const [htmlOptions, fakeOptions] = useMemo(() => (options ?? []).reduce(([opts, fake], o) => {
122
+ const id = getOptionAsValue(o, renderValue);
123
+ const label = getOptionAsLabel(o, renderLabel);
124
+ return [
125
+ [...opts, _jsx("option", { value: id, selected: value === id, children: label.text }, id)],
126
+ [...fake, _jsx(FakeOption, { value: id, label: label.option, onChange: onChangeOption }, id)],
127
+ ];
128
+ }, [[], []]), [options, value]);
129
+ function getCurrentValue() {
130
+ return value === undefined ? '' : getOptionAsValue(value, renderValue);
131
+ }
132
+ function getCurrentLabel() {
133
+ return value === undefined ? emptyOption : getOptionAsLabel(value, renderLabel);
134
+ }
135
+ useEffect(() => {
136
+ const detach = () => document.removeEventListener('mousedown', onClickOutside);
137
+ if (open)
138
+ document.addEventListener('mousedown', onClickOutside);
139
+ else
140
+ detach();
141
+ return detach;
142
+ }, [open]);
143
+ useEffect(() => {
144
+ async function measure() {
145
+ // semaphore for controlling concurrence
146
+ if (isMeasuring.current)
147
+ return;
148
+ isMeasuring.current = true;
149
+ const list = fakeSelectRef.current?.querySelector('.options');
150
+ if (!list)
151
+ return;
152
+ list.setAttribute('inert', '');
153
+ list.setAttribute('style', 'height: auto');
154
+ await delay(0);
155
+ listHeight.current = list.clientHeight;
156
+ await delay(0);
157
+ list.setAttribute('style', `height: ${open ? listHeight.current : 0}`);
158
+ list.removeAttribute('inert');
159
+ isMeasuring.current = false;
160
+ }
161
+ measure();
162
+ }, [options, fakeSelectRef.current]);
163
+ // replicates the original select effect of the browser to select the first option. This is necessary because we use the default
164
+ // select element for accessibility, the behavior must not differ.
165
+ useEffect(() => {
166
+ if (!value && !emptyOption && options?.length) {
167
+ onChange(options[0]);
168
+ }
169
+ }, [options]);
170
+ return (_jsxs(SelectBox, { style: style, className: className, "$maxItems": maxItems, "$inputHeight": height, children: [_jsxs("select", { ...props, value: getCurrentValue(), onChange: onChangeOption, onFocus: (ev) => {
171
+ setFocused(true);
172
+ onFocus?.(ev);
173
+ }, onBlur: (ev) => {
174
+ setFocused(false);
175
+ onBlur?.(ev);
176
+ }, disabled: isDisabled, "aria-busy": isLoading, children: [emptyOption === undefined ? null : _jsx("option", { value: "", selected: !value, children: emptyOption.text }), htmlOptions] }), _jsxs("div", { ref: fakeSelectRef, className: listToClass(['fake-select', open && 'open', focused && 'focused', isDisabled && 'disabled']), "aria-hidden": true, children: [_jsxs("div", { className: "current-value", onClick: isDisabled ? undefined : () => setOpen(!open), children: [getCurrentLabel()?.selected || getCurrentLabel()?.option || _jsx("div", {}), isLoading ? _jsx(LoadingCircular, { size: "sm" }) : _jsx(IconBox, { className: "arrow", children: _jsx(ChevronDown, {}) })] }), _jsxs("ul", { className: "options", style: { height: open ? listHeight.current : 0 }, children: [emptyOption === undefined ? null : _jsx(FakeOption, { value: "", label: emptyOption.option, onChange: onChangeOption }), fakeOptions] })] })] }));
177
+ }
178
+ //# sourceMappingURL=CustomSelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomSelect.js","sourceRoot":"","sources":["../../../../src/components/form/Select/CustomSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC,SAAS,gBAAgB,CACvB,MAAc,EACd,QAAuB;IAEvB,IAAI,MAA0B,CAAA;IAC9B,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;SAC7E,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,MAAM,GAAG,MAAM,CAAC,QAAwB,CAAW,CAAA;IAC1F,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,EAAE,CAAA;AAC5C,CAAC;AAED,SAAS,gBAAgB,CAIvB,MAAc,EACd,QAAuB;IAEvB,IAAI,MAA0C,CAAA;IAC9C,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,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ACjG,WAAW,IACL,EACT,eACE,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,WAAW,CAAC,CAAC,aAAa,EAAE,IAAI,IAAI,MAAM,EAAE,OAAO,IAAI,SAAS,EAAE,UAAU,IAAI,UAAU,CAAC,CAAC,kCAGvG,eAAK,SAAS,EAAC,eAAe,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,aAClF,eAAe,EAAE,EAAE,QAAQ,IAAI,eAAe,EAAE,EAAE,MAAM,IAAI,eAAW,EACvE,SAAS,CAAC,CAAC,CAAC,KAAC,eAAe,IAAC,IAAI,EAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAC,OAAO,IAAC,SAAS,EAAC,OAAO,YAAC,KAAC,WAAW,KAAG,GAAU,IAC7F,EACN,cAAI,SAAS,EAAC,SAAS,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,aACrE,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAC,UAAU,IAAC,KAAK,EAAC,EAAE,EAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAI,EAC/G,WAAW,IACT,IACD,IACI,CACb,CAAA;AACH,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { DetailedSelectProps } from './types.js';
2
+ /**
3
+ * Renders a Select component using the Citric Design System.
4
+ *
5
+ * The styled version of the select component is rendered on top of the default select from the browser. Visual users will use the Citric
6
+ * version of a Select, but blind users, who interacts with the keyboard, will use the default browser select instead, which is already
7
+ * highly optimized for accessibility.
8
+ *
9
+ * The DetailedSelect lets you set an image, a title and a description for each option. To do so, use the prop `renderLabel` and
10
+ * `emptyOption`. The accessible string for each option will always be `option.title: option.description`.
11
+ *
12
+ * To use more customizable labels, check the `CustomSelect`. To use more simple labels (just strings) use `Select`.
13
+ *
14
+ * The DetailedSelect expects a {@link DetailedLabel} to create labels.
15
+ *
16
+ * Tips:
17
+ * - This is a controlled field. You can't use it any other way. If you're using it with react-hook-form, you need to wrap it under the
18
+ * component `<Controller>` from the same library.
19
+ * - `value` is required and must be of the same type of an item of the array of options. `value` is only optional if `emptyOption` is
20
+ * provided, in this case, an empty option is rendered and the value is undefined when it's selected.
21
+ * - A consequence of the previous rule is that you can't have an empty selection if you don't set a value for `emptyOption`. This
22
+ * component must work exactly like the browser's `select`, so this behavior is intended.
23
+ * - If `renderLabel` or `renderValue` are not provided, this will use the `toString` method of the object to set the option's title.
24
+ *
25
+ * @example
26
+ * options as a string array
27
+ * ```
28
+ * const options = ['option 1', 'option 2', 'option 3']
29
+ *
30
+ * function renderDetailedLabel(option: string) {
31
+ * return {
32
+ * title: option,
33
+ * description: 'my description',
34
+ * image: <img src="/my-image.png" />,
35
+ * }
36
+ * }
37
+ *
38
+ * const MyComponent = {
39
+ * const [value, setValue] = useState(options[0])
40
+ * return <DetailedSelect options={options} value={value} onChange={setValue} renderLabel={renderDetailedLabel} />
41
+ * }
42
+ * ```
43
+ * @example
44
+ * options as an object array
45
+ * ```
46
+ * const options = [{ id: 1, name: 'John', age: 34 }, { id: 2, name: 'Marcia', age: 28 }, { id: 3, name: 'Angeline', age: 58 }]
47
+ *
48
+ * function renderDetailedLabel(option: (typeof options)[number]) {
49
+ * return {
50
+ * title: option.name,
51
+ * description: `${option.age} years old`,
52
+ * image: <img src="/my-image.png" />,
53
+ * }
54
+ * }
55
+ *
56
+ * const MyComponent = {
57
+ * const [value, setValue] = useState(options[0])
58
+ * // below, renderValue could be `o => o.id`
59
+ * return <DetailedSelect options={options} value={value} onChange={setValue} renderValue="id" renderLabel={renderDetailedLabel} />
60
+ * }
61
+ * ```
62
+ * @param props the component props: {@link DetailedSelectProps}.
63
+ */
64
+ export declare function DetailedSelect<T>({ renderLabel, emptyOption, ...props }: DetailedSelectProps<T>): import("react/jsx-runtime").JSX.Element;
65
+ //# sourceMappingURL=DetailedSelect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DetailedSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Select/DetailedSelect.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,mBAAmB,EAAqC,MAAM,SAAS,CAAA;AAgB/F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC,2CAI/F"}
@@ -0,0 +1,80 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ import { CustomSelect } from './CustomSelect.js';
4
+ import { parseLabel } from './utils.js';
5
+ function getOptionAsLabel(option, renderer) {
6
+ let result;
7
+ if (typeof renderer === 'function')
8
+ result = option ? renderer(option) : undefined;
9
+ else if (typeof renderer === 'string')
10
+ result = option[renderer];
11
+ return parseLabel(result ?? `${option ?? ''}`);
12
+ }
13
+ /**
14
+ * Renders a Select component using the Citric Design System.
15
+ *
16
+ * The styled version of the select component is rendered on top of the default select from the browser. Visual users will use the Citric
17
+ * version of a Select, but blind users, who interacts with the keyboard, will use the default browser select instead, which is already
18
+ * highly optimized for accessibility.
19
+ *
20
+ * The DetailedSelect lets you set an image, a title and a description for each option. To do so, use the prop `renderLabel` and
21
+ * `emptyOption`. The accessible string for each option will always be `option.title: option.description`.
22
+ *
23
+ * To use more customizable labels, check the `CustomSelect`. To use more simple labels (just strings) use `Select`.
24
+ *
25
+ * The DetailedSelect expects a {@link DetailedLabel} to create labels.
26
+ *
27
+ * Tips:
28
+ * - This is a controlled field. You can't use it any other way. If you're using it with react-hook-form, you need to wrap it under the
29
+ * component `<Controller>` from the same library.
30
+ * - `value` is required and must be of the same type of an item of the array of options. `value` is only optional if `emptyOption` is
31
+ * provided, in this case, an empty option is rendered and the value is undefined when it's selected.
32
+ * - A consequence of the previous rule is that you can't have an empty selection if you don't set a value for `emptyOption`. This
33
+ * component must work exactly like the browser's `select`, so this behavior is intended.
34
+ * - If `renderLabel` or `renderValue` are not provided, this will use the `toString` method of the object to set the option's title.
35
+ *
36
+ * @example
37
+ * options as a string array
38
+ * ```
39
+ * const options = ['option 1', 'option 2', 'option 3']
40
+ *
41
+ * function renderDetailedLabel(option: string) {
42
+ * return {
43
+ * title: option,
44
+ * description: 'my description',
45
+ * image: <img src="/my-image.png" />,
46
+ * }
47
+ * }
48
+ *
49
+ * const MyComponent = {
50
+ * const [value, setValue] = useState(options[0])
51
+ * return <DetailedSelect options={options} value={value} onChange={setValue} renderLabel={renderDetailedLabel} />
52
+ * }
53
+ * ```
54
+ * @example
55
+ * options as an object array
56
+ * ```
57
+ * const options = [{ id: 1, name: 'John', age: 34 }, { id: 2, name: 'Marcia', age: 28 }, { id: 3, name: 'Angeline', age: 58 }]
58
+ *
59
+ * function renderDetailedLabel(option: (typeof options)[number]) {
60
+ * return {
61
+ * title: option.name,
62
+ * description: `${option.age} years old`,
63
+ * image: <img src="/my-image.png" />,
64
+ * }
65
+ * }
66
+ *
67
+ * const MyComponent = {
68
+ * const [value, setValue] = useState(options[0])
69
+ * // below, renderValue could be `o => o.id`
70
+ * return <DetailedSelect options={options} value={value} onChange={setValue} renderValue="id" renderLabel={renderDetailedLabel} />
71
+ * }
72
+ * ```
73
+ * @param props the component props: {@link DetailedSelectProps}.
74
+ */
75
+ export function DetailedSelect({ renderLabel, emptyOption, ...props }) {
76
+ const renderLabelRef = useCallback((option) => getOptionAsLabel(option, renderLabel), []);
77
+ // @ts-ignore the following usage is correct, Typescript is getting confused because it doesn't know if `emptyOption` is undefined or not.
78
+ return _jsx(CustomSelect, { renderLabel: renderLabelRef, emptyOption: emptyOption ? parseLabel(emptyOption) : undefined, ...props });
79
+ }
80
+ //# sourceMappingURL=DetailedSelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DetailedSelect.js","sourceRoot":"","sources":["../../../../src/components/form/Select/DetailedSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC,SAAS,gBAAgB,CAIvB,MAAc,EACd,QAAuB;IAEvB,IAAI,MAAiC,CAAA;IACrC,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;SAC7E,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,MAAM,GAAG,MAAM,CAAC,QAAwB,CAAkB,CAAA;IACjG,OAAO,UAAU,CAAC,MAAM,IAAI,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC,CAAA;AAChD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,UAAU,cAAc,CAAI,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,KAAK,EAA0B;IAC9F,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,MAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,CAAA;IAC5F,0IAA0I;IAC1I,OAAO,KAAC,YAAY,IAAC,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,KAAM,KAAK,GAAI,CAAA;AACjI,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { SelectProps } from './types.js';
2
+ /**
3
+ * Renders a Select component using the Citric Design System.
4
+ *
5
+ * The styled version of the select component is rendered on top of the default select from the browser. Visual users will use the Citric
6
+ * version of a Select, but blind users, who interacts with the keyboard, will use the default browser select instead, which is already
7
+ * highly optimized for accessibility.
8
+ *
9
+ * The Select component renders each option as a string. To use more customizable labels, check the `DetailedSelect` and `CustomSelect`
10
+ * components.
11
+ *
12
+ * The Select component expects plain strings to create labels.
13
+ *
14
+ * Tips:
15
+ * - This is a controlled field. You can't use it any other way. If you're using it with react-hook-form, you need to wrap it under the
16
+ * component `<Controller>` from the same library.
17
+ * - `value` is required and must be of the same type of an item of the array of options. `value` is only optional if `emptyOption` is
18
+ * provided, in this case, an empty option is rendered and the value is undefined when it's selected.
19
+ * - A consequence of the previous rule is that you can't have an empty selection if you don't set a value for `emptyOption`. This
20
+ * component must work exactly like the browser's `select`, so this behavior is intended.
21
+ * - If `renderLabel` or `renderValue` are not provided, this will use the `toString` method of the object.
22
+ *
23
+ * @example
24
+ * options as a string array
25
+ * ```
26
+ * const options = ['option 1', 'option 2', 'option 3']
27
+ *
28
+ * const MyComponent = {
29
+ * const [value, setValue] = useState(options[0])
30
+ * return <Select options={options} value={value} onChange={setValue} />
31
+ * }
32
+ * ```
33
+ * @example
34
+ * options as an object array
35
+ * ```
36
+ * const options = [{ id: 1, name: 'John', age: 34 }, { id: 2, name: 'Marcia', age: 28 }, { id: 3, name: 'Angeline', age: 58 }]
37
+ *
38
+ * const MyComponent = {
39
+ * const [value, setValue] = useState(options[0])
40
+ * // below, renderValue could be `o => o.id` and renderLabel `o => o.name`.
41
+ * return <Select options={options} value={value} onChange={setValue} renderValue="id" renderLabel="name" />
42
+ * }
43
+ * ```
44
+ * @param props the component props: {@link CustomSelectProps}.
45
+ */
46
+ export declare function Select<T>({ renderLabel, emptyOption, ...props }: SelectProps<T>): import("react/jsx-runtime").JSX.Element;
47
+ //# sourceMappingURL=Select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Select/Select.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAqC,WAAW,EAAE,MAAM,SAAS,CAAA;AAgBxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,2CAI/E"}
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ import { CustomSelect } from './CustomSelect.js';
4
+ import { parseLabel } from './utils.js';
5
+ function getOptionAsLabel(option, renderer) {
6
+ let result;
7
+ if (typeof renderer === 'function')
8
+ result = option ? renderer(option) : undefined;
9
+ else if (typeof renderer === 'string')
10
+ result = option[renderer];
11
+ return parseLabel(result ?? `${option ?? ''}`);
12
+ }
13
+ /**
14
+ * Renders a Select component using the Citric Design System.
15
+ *
16
+ * The styled version of the select component is rendered on top of the default select from the browser. Visual users will use the Citric
17
+ * version of a Select, but blind users, who interacts with the keyboard, will use the default browser select instead, which is already
18
+ * highly optimized for accessibility.
19
+ *
20
+ * The Select component renders each option as a string. To use more customizable labels, check the `DetailedSelect` and `CustomSelect`
21
+ * components.
22
+ *
23
+ * The Select component expects plain strings to create labels.
24
+ *
25
+ * Tips:
26
+ * - This is a controlled field. You can't use it any other way. If you're using it with react-hook-form, you need to wrap it under the
27
+ * component `<Controller>` from the same library.
28
+ * - `value` is required and must be of the same type of an item of the array of options. `value` is only optional if `emptyOption` is
29
+ * provided, in this case, an empty option is rendered and the value is undefined when it's selected.
30
+ * - A consequence of the previous rule is that you can't have an empty selection if you don't set a value for `emptyOption`. This
31
+ * component must work exactly like the browser's `select`, so this behavior is intended.
32
+ * - If `renderLabel` or `renderValue` are not provided, this will use the `toString` method of the object.
33
+ *
34
+ * @example
35
+ * options as a string array
36
+ * ```
37
+ * const options = ['option 1', 'option 2', 'option 3']
38
+ *
39
+ * const MyComponent = {
40
+ * const [value, setValue] = useState(options[0])
41
+ * return <Select options={options} value={value} onChange={setValue} />
42
+ * }
43
+ * ```
44
+ * @example
45
+ * options as an object array
46
+ * ```
47
+ * const options = [{ id: 1, name: 'John', age: 34 }, { id: 2, name: 'Marcia', age: 28 }, { id: 3, name: 'Angeline', age: 58 }]
48
+ *
49
+ * const MyComponent = {
50
+ * const [value, setValue] = useState(options[0])
51
+ * // below, renderValue could be `o => o.id` and renderLabel `o => o.name`.
52
+ * return <Select options={options} value={value} onChange={setValue} renderValue="id" renderLabel="name" />
53
+ * }
54
+ * ```
55
+ * @param props the component props: {@link CustomSelectProps}.
56
+ */
57
+ export function Select({ renderLabel, emptyOption, ...props }) {
58
+ const renderLabelRef = useCallback((option) => getOptionAsLabel(option, renderLabel), []);
59
+ // @ts-ignore the following usage is correct, Typescript is getting confused because it doesn't know if `emptyOption` is undefined or not.
60
+ return _jsx(CustomSelect, { renderLabel: renderLabelRef, emptyOption: emptyOption ? parseLabel(emptyOption) : undefined, ...props });
61
+ }
62
+ //# sourceMappingURL=Select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../../src/components/form/Select/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC,SAAS,gBAAgB,CAIvB,MAAc,EACd,QAAuB;IAEvB,IAAI,MAA0B,CAAA;IAC9B,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;SAC7E,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,MAAM,GAAG,MAAM,CAAC,QAAwB,CAAW,CAAA;IAC1F,OAAO,UAAU,CAAC,MAAM,IAAI,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC,CAAA;AAChD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,UAAU,MAAM,CAAI,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,KAAK,EAAkB;IAC9E,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,MAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,CAAA;IAC5F,0IAA0I;IAC1I,OAAO,KAAC,YAAY,IAAC,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,KAAM,KAAK,GAAI,CAAA;AACjI,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { CustomSelect } from './CustomSelect.js';
2
+ export { DetailedSelect } from './DetailedSelect.js';
3
+ export { Select } from './Select.js';
4
+ export * from './types.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Select/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,cAAc,SAAS,CAAA"}
@@ -0,0 +1,5 @@
1
+ export { CustomSelect } from './CustomSelect.js';
2
+ export { DetailedSelect } from './DetailedSelect.js';
3
+ export { Select } from './Select.js';
4
+ export * from './types.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/form/Select/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,cAAc,SAAS,CAAA"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const SelectBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
3
+ $maxItems: number;
4
+ $inputHeight: string;
5
+ }>> & string;
6
+ //# sourceMappingURL=styled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../../../src/components/form/Select/styled.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,SAAS;eAA2B,MAAM;kBAAgB,MAAM;YAiK5E,CAAA"}