@iress-oss/ids-components 6.0.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/Autocomplete-BRGD9dSh.js +321 -0
  2. package/dist/Shadow-D2KoVwxD.js +57 -0
  3. package/dist/components/Autocomplete/Autocomplete.js +1 -1
  4. package/dist/components/Autocomplete/hooks/useAutocompleteSearch.js +1 -1
  5. package/dist/components/Autocomplete/index.js +2 -2
  6. package/dist/components/Field/Field.js +47 -47
  7. package/dist/components/Field/Field.styles.d.ts +1 -1
  8. package/dist/components/Field/Field.styles.js +6 -0
  9. package/dist/components/Field/components/FieldHint.js +27 -19
  10. package/dist/components/Field/index.d.ts +0 -2
  11. package/dist/components/Field/index.js +1 -3
  12. package/dist/components/{Field/FieldGroup → FieldGroup}/FieldGroup.js +9 -9
  13. package/dist/components/{Field/FieldGroup → FieldGroup}/FieldGroup.styles.d.ts +1 -1
  14. package/dist/components/{Field/FieldGroup → FieldGroup}/FieldGroup.styles.js +2 -2
  15. package/dist/components/FieldGroup/index.d.ts +2 -0
  16. package/dist/components/FieldGroup/index.js +3 -0
  17. package/dist/components/Input/Input.styles.d.ts +4 -4
  18. package/dist/components/Input/Input.styles.js +4 -4
  19. package/dist/components/Link/Link.styles.d.ts +1 -0
  20. package/dist/components/Link/Link.styles.js +4 -1
  21. package/dist/components/Menu/Menu.js +81 -77
  22. package/dist/components/Menu/Menu.styles.js +7 -0
  23. package/dist/components/Menu/MenuGroup/MenuGroup.d.ts +18 -3
  24. package/dist/components/Menu/MenuGroup/MenuGroup.js +38 -34
  25. package/dist/components/Menu/MenuHeading/MenuHeading.d.ts +20 -0
  26. package/dist/components/Menu/MenuHeading/MenuHeading.js +14 -0
  27. package/dist/components/Menu/MenuItem/MenuItem.styles.js +9 -0
  28. package/dist/components/Menu/MenuText/MenuText.d.ts +1 -5
  29. package/dist/components/Menu/MenuText/MenuText.js +11 -17
  30. package/dist/components/Menu/index.d.ts +1 -0
  31. package/dist/components/Menu/index.js +4 -3
  32. package/dist/components/Select/Select.js +1 -1
  33. package/dist/components/Select/SelectHeading/SelectHeading.js +5 -5
  34. package/dist/components/Select/SelectTags/SelectTags.js +15 -15
  35. package/dist/components/Select/components/SelectOptions.js +108 -95
  36. package/dist/components/Select/index.js +1 -1
  37. package/dist/components/Slideout/Slideout.styles.js +1 -0
  38. package/dist/components/TabSet/TabSet.d.ts +6 -1
  39. package/dist/components/TabSet/TabSet.js +34 -30
  40. package/dist/components/TabSet/TabSet.styles.d.ts +1 -1
  41. package/dist/components/TabSet/TabSet.styles.js +13 -1
  42. package/dist/components/Tag/Tag.styles.d.ts +14 -14
  43. package/dist/components/Tag/Tag.styles.js +16 -16
  44. package/dist/components/Tag/index.d.ts +0 -1
  45. package/dist/components/Tag/index.js +1 -2
  46. package/dist/components/{Tag/TagInput → TagInput}/TagInput.d.ts +1 -1
  47. package/dist/components/{Tag/TagInput → TagInput}/TagInput.js +7 -7
  48. package/dist/components/TagInput/TagInput.styles.d.ts +1 -0
  49. package/dist/components/{Tag/TagInput → TagInput}/TagInput.styles.js +2 -2
  50. package/dist/components/TagInput/index.d.ts +2 -0
  51. package/dist/components/TagInput/index.js +3 -0
  52. package/dist/components/Tooltip/Tooltip.d.ts +7 -2
  53. package/dist/components/Tooltip/Tooltip.js +48 -42
  54. package/dist/components/Tooltip/TooltipProvider.d.ts +27 -0
  55. package/dist/components/Tooltip/TooltipProvider.js +14 -0
  56. package/dist/components/Tooltip/hooks/useTooltipContainer.d.ts +17 -0
  57. package/dist/components/Tooltip/hooks/useTooltipContainer.js +5 -0
  58. package/dist/components/Tooltip/index.d.ts +4 -0
  59. package/dist/components/Tooltip/index.js +4 -2
  60. package/dist/components/ValidationMessage/ValidationMessage.js +2 -2
  61. package/dist/main.d.ts +2 -0
  62. package/dist/main.js +125 -121
  63. package/dist/patterns/DropdownMenu/DropdownMenu.js +113 -102
  64. package/dist/patterns/DropdownMenu/hooks/useDropdownMenuFlags.d.ts +1 -0
  65. package/dist/patterns/DropdownMenu/hooks/useDropdownMenuFlags.js +1 -0
  66. package/dist/patterns/Form/FormField/FormFieldset.d.ts +1 -1
  67. package/dist/patterns/Form/FormField/FormFieldset.js +1 -1
  68. package/dist/patterns/Form/FormValidationSummary/FormValidationSummary.js +1 -0
  69. package/dist/patterns/Form/components/LongForm.js +3 -1
  70. package/dist/patterns/Form/components/ShortForm.js +1 -0
  71. package/dist/patterns/Loading/Loading.styles.d.ts +3 -0
  72. package/dist/patterns/Loading/Loading.styles.js +4 -1
  73. package/dist/patterns/Loading/components/PageLoading.js +4 -4
  74. package/dist/patterns/Shadow/Shadow.js +1 -1
  75. package/dist/patterns/Shadow/index.js +1 -1
  76. package/dist/patterns/SideNav/SideNav.d.ts +6 -0
  77. package/dist/patterns/SideNav/SideNav.js +74 -68
  78. package/dist/patterns/SideNav/SideNav.styles.js +6 -2
  79. package/dist/style.css +1 -1
  80. package/dist/{useAutocompleteSearch-BJ_hhoKp.js → useAutocompleteSearch-DxKxs6HH.js} +29 -24
  81. package/package.json +1 -1
  82. package/dist/Autocomplete-CuUjmIAw.js +0 -308
  83. package/dist/Shadow-OHZiBoEb.js +0 -57
  84. package/dist/components/Tag/TagInput/TagInput.styles.d.ts +0 -1
  85. /package/dist/components/{Field/FieldGroup → FieldGroup}/FieldGroup.d.ts +0 -0
@@ -0,0 +1,321 @@
1
+ import { t as e } from "./cx-CZ8IJJTy.js";
2
+ import { GlobalCSSClass as t } from "./enums.js";
3
+ import { idsLogger as n } from "./helpers/utility/idsLogger.js";
4
+ import { IressIcon as r } from "./components/Icon/Icon.js";
5
+ import { IressText as i } from "./components/Text/Text.js";
6
+ import { propagateTestid as a } from "./helpers/utility/propagateTestid.js";
7
+ import { IressSpinner as o } from "./components/Spinner/Spinner.js";
8
+ import { toArray as s } from "./helpers/formatting/toArray.js";
9
+ import { useControlledState as ee } from "./hooks/useControlledState.js";
10
+ import { useResponsiveProps as te } from "./hooks/useResponsiveProps.js";
11
+ import { IressPopover as ne } from "./components/Popover/Popover.js";
12
+ import { IressInputPopover as re } from "./components/Popover/InputPopover/InputPopover.js";
13
+ import { IressAlert as c } from "./components/Alert/Alert.js";
14
+ import { autoComplete as ie } from "./components/Autocomplete/Autocomplete.styles.js";
15
+ import { getFormControlValueAsStringIfDefined as l } from "./helpers/form/getFormControlValueAsStringIfDefined.js";
16
+ import { useNoDefaultValueInForms as ae } from "./patterns/Form/hooks/useNoDefaultValueInForms.js";
17
+ import { IressReadonly as oe } from "./components/Readonly/Readonly.js";
18
+ import { IressInput as se } from "./components/Input/Input.js";
19
+ import { getValueAsEvent as u } from "./helpers/form/getValueAsEvent.js";
20
+ import { t as ce } from "./useAutocompleteSearch-DxKxs6HH.js";
21
+ import { AutocompleteInstructions as d } from "./components/Autocomplete/components/AutocompleteInstructions.js";
22
+ import { select as le } from "./components/Select/Select.styles.js";
23
+ import { IressInline as f } from "./components/Inline/Inline.js";
24
+ import { SelectActivator as ue } from "./components/Select/components/SelectActivator.js";
25
+ import { IressSelectMenu as p } from "./components/Select/SelectMenu/SelectMenu.js";
26
+ import { SelectOptions as m } from "./components/Select/components/SelectOptions.js";
27
+ import { SelectHiddenInput as de } from "./components/Select/components/SelectHiddenInput.js";
28
+ import { NativeSelect as fe } from "./components/Select/components/NativeSelect.js";
29
+ import { useSelectState as pe } from "./components/Select/hooks/useSelectState.js";
30
+ import { forwardRef as h, useCallback as me, useEffect as g, useImperativeHandle as he, useMemo as _, useRef as v, useState as y } from "react";
31
+ import { Fragment as ge, jsx as b, jsxs as x } from "react/jsx-runtime";
32
+ //#region src/components/Select/Select.tsx
33
+ var S = (e) => typeof e == "object" && !!e && "label" in e, C = (e, t) => {
34
+ for (let n of t) if (n.children) {
35
+ let t = C(e, n.children);
36
+ if (t) return t;
37
+ } else if (n.value !== void 0 && n.value === e) return n;
38
+ }, w = (e, t) => {
39
+ if (S(e)) return e;
40
+ if (typeof t != "function") return C(e, t) ?? (typeof e == "number" ? C(String(e), t) : void 0);
41
+ }, T = (e, t) => {
42
+ if (e !== void 0) {
43
+ if (Array.isArray(e)) {
44
+ let r = e, i = r.map((e) => w(e, t)).filter((e) => e !== void 0);
45
+ return i.length < r.length && typeof t != "function" && n(`IressSelect: ${r.length - i.length} value(s) could not be resolved to matching options and were dropped.`, "warn"), i;
46
+ }
47
+ return w(e, t);
48
+ }
49
+ }, E = h(({ align: r = "bottom-start", autoHighlight: i = !0, className: a, defaultValue: o, disabled: s, footer: ee, header: re, id: c, matchActivatorWidth: ie = !0, multiSelect: l, multiSelectLimit: se, name: u, onChange: d, onBlur: f, options: p, native: h, placeholder: C, readOnly: w, renderHiddenInput: E, renderLabel: D, renderOptions: _e, required: O, type: k, value: A, virtualFocus: j, width: M, ...N }, P) => {
50
+ ae({
51
+ component: "IressSelect",
52
+ defaultValue: o
53
+ });
54
+ let [F, I] = y(!1), L = F && !s, [R, ve] = y(""), z = _(() => T(A, p), [A, p]), B = _(() => T(o, p), [o, p]);
55
+ g(() => {
56
+ A !== void 0 && !S(A) && z === void 0 && typeof p == "function" && n("IressSelect: A primitive value was passed but cannot be resolved because options are asynchronous. Pass a LabelValueMeta object instead when using async options, otherwise the component will behave as uncontrolled.", "warn");
57
+ }, [
58
+ A,
59
+ z,
60
+ p
61
+ ]);
62
+ let { value: V, setValue: H, getValuesString: U, getLabelsString: ye } = pe({
63
+ component: "IressSelect",
64
+ defaultValue: B,
65
+ multiple: l,
66
+ value: z
67
+ }), W = v(null), G = v(null), K = v(null), { value: q } = te(typeof h == "string" ? {
68
+ xs: !0,
69
+ [h]: !1
70
+ } : { xs: h }, { disabled: !h }), { append: be, debounceThreshold: xe, initialOptions: J, minSearchLength: Y, onActivated: X, onDeactivated: Se, prepend: Ce, selectedOptionsText: we, ...Z } = N, { debouncedQuery: Te, error: Ee, results: De, stopSearch: Oe, loading: ke, shouldShowInstructions: Ae, shouldShowNoResults: je } = ce({
71
+ debounceThreshold: xe,
72
+ disabled: !F || !!q,
73
+ initialOptions: J,
74
+ minSearchLength: Y,
75
+ options: p,
76
+ query: R
77
+ });
78
+ he(P, () => q ? {
79
+ focus: () => G.current?.focus(),
80
+ blur: () => G.current?.blur(),
81
+ input: G.current ?? null
82
+ } : W.current ? {
83
+ ...W.current,
84
+ focus: () => W.current?.getActivator()?.focus(),
85
+ blur: () => W.current?.getActivator()?.blur(),
86
+ hiddenInput: K.current ?? void 0,
87
+ input: K.current ?? null
88
+ } : {
89
+ hiddenInput: K.current ?? void 0,
90
+ input: K.current ?? null,
91
+ focus: () => K.current?.focus(),
92
+ blur: () => K.current?.blur()
93
+ }, [q]), g(() => {
94
+ F ? X?.() : Se?.();
95
+ }, [
96
+ X,
97
+ Se,
98
+ F
99
+ ]);
100
+ let Me = me((e) => {
101
+ if (!f) return;
102
+ let t = e.currentTarget, n = e.relatedTarget;
103
+ !F && (!n || !t.contains(n)) && f(e), e.stopPropagation();
104
+ }, [f, F]);
105
+ if (w) return /* @__PURE__ */ b(oe, {
106
+ value: U(),
107
+ ref: K,
108
+ variant: w,
109
+ name: u,
110
+ disabled: s,
111
+ required: O,
112
+ children: ye(", ")
113
+ });
114
+ if (q) {
115
+ if (p instanceof Function) throw Error("[IressSelect] The native select does not support asynchronous options. Please provide options as an array.");
116
+ if (l) throw Error("[IressSelect] The native select does not support multiple selection. Please remove the multiSelect prop or use the non-native select.");
117
+ return /* @__PURE__ */ b(fe, {
118
+ className: e(a, t.Select),
119
+ "data-testid": Z["data-testid"],
120
+ disabled: s,
121
+ id: c,
122
+ name: u,
123
+ onChange: (e, t) => {
124
+ d?.(e, t?.value ?? null, t), H(t);
125
+ },
126
+ options: p,
127
+ placeholder: typeof h == "string" ? C ?? "" : C,
128
+ style: Z.style,
129
+ value: V,
130
+ width: M,
131
+ ref: G
132
+ });
133
+ }
134
+ let Q = typeof p == "function", Ne = j ?? !Q, Pe = k ?? (Q ? void 0 : "listbox"), $ = le({ width: M }), Fe = () => {
135
+ I(!0);
136
+ }, Ie = () => {
137
+ I(!1), Oe();
138
+ };
139
+ return /* @__PURE__ */ x(ge, { children: [/* @__PURE__ */ b(de, {
140
+ "data-testid": Z["data-testid"],
141
+ getValuesString: U,
142
+ name: u,
143
+ renderHiddenInput: E,
144
+ required: O,
145
+ value: V,
146
+ disabled: s,
147
+ ref: K
148
+ }), /* @__PURE__ */ b(ne, {
149
+ ...Z,
150
+ activator: /* @__PURE__ */ b(ue, {
151
+ append: be,
152
+ async: Q,
153
+ disabled: s,
154
+ error: Ee,
155
+ id: c,
156
+ loading: ke,
157
+ multiSelect: l,
158
+ multiSelectLimit: se,
159
+ onChange: d,
160
+ placeholder: C,
161
+ prepend: Ce,
162
+ renderLabel: D,
163
+ selectedOptionsText: we,
164
+ setValue: H,
165
+ setShow: I,
166
+ show: F,
167
+ value: V
168
+ }),
169
+ align: r,
170
+ className: e(a, $.root, t.Select),
171
+ contentClassName: e($.popoverContent),
172
+ contentStyle: {
173
+ ...Z.contentStyle,
174
+ p: "none"
175
+ },
176
+ matchActivatorWidth: ie,
177
+ onActivated: Fe,
178
+ onDeactivated: Ie,
179
+ ref: W,
180
+ show: L,
181
+ type: Pe,
182
+ virtualFocus: Ne,
183
+ onBlur: Me,
184
+ children: /* @__PURE__ */ x("div", {
185
+ className: $.wrapper,
186
+ children: [
187
+ re,
188
+ /* @__PURE__ */ b(m, {
189
+ autoHighlight: i,
190
+ debouncedQuery: Te,
191
+ error: Ee,
192
+ initialOptions: J,
193
+ loading: ke,
194
+ minSearchLength: Y,
195
+ multiSelect: l,
196
+ onChange: d,
197
+ options: p,
198
+ query: R,
199
+ renderOptions: _e,
200
+ results: De,
201
+ setQuery: ve,
202
+ setShow: I,
203
+ setValue: H,
204
+ shouldShowInstructions: Ae,
205
+ shouldShowNoResults: je,
206
+ show: L,
207
+ value: V
208
+ }),
209
+ ee
210
+ ]
211
+ })
212
+ })] });
213
+ });
214
+ E.displayName = "IressSelect";
215
+ //#endregion
216
+ //#region src/components/Autocomplete/Autocomplete.tsx
217
+ var D = h(({ alwaysShowOnFocus: n, append: te = /* @__PURE__ */ b(r, { name: "search" }), autoComplete: ne = "off", autoSelect: ae = !0, className: le, clearable: ue = !0, "data-testid": m, debounceThreshold: de, defaultValue: fe, errorText: pe = /* @__PURE__ */ b(c, {
218
+ status: "danger",
219
+ mb: "none",
220
+ borderRadius: "radius.system.form",
221
+ children: "An unknown error occurred. Please contact support if the error persists."
222
+ }), initialOptions: h, limitDesktop: me = 12, limitMobile: he = 6, minSearchLength: _, noResultsText: v, onChange: S, onClear: C, onFocus: w, options: T, popoverProps: { autoHighlight: E = !1, append: D, prepend: _e, ...O } = {}, readOnly: k, value: A, ...j }, M) => {
223
+ let [N, P] = y(!1), { value: F, setValue: I } = ee({
224
+ component: "IressAutocomplete",
225
+ defaultValue: fe,
226
+ value: A
227
+ }), [L, R] = y(!1), { clearError: ve, debouncedQuery: z, error: B, loading: V, results: H, startSearch: U, stopSearch: ye, shouldShowInstructions: W, shouldShowNoResults: G } = ce({
228
+ debounceThreshold: de,
229
+ initialOptions: h,
230
+ minSearchLength: _,
231
+ options: T,
232
+ query: l(F)
233
+ });
234
+ if (g(() => {
235
+ L && !N && H.length > 0 && F && P(!0);
236
+ }, [
237
+ H.length,
238
+ N,
239
+ L,
240
+ F
241
+ ]), g(() => {
242
+ V && L && P(!0);
243
+ }, [V, L]), g(() => {
244
+ B && P(!0);
245
+ }, [B]), k) return /* @__PURE__ */ b(oe, {
246
+ value: F,
247
+ variant: k
248
+ });
249
+ let K = (e, t) => {
250
+ S?.(e, t), I(t), R(!!t);
251
+ }, q = (e) => {
252
+ C?.(e), I("");
253
+ }, be = (e) => {
254
+ w?.(e), h?.length && P(!0);
255
+ }, xe = (e) => {
256
+ let t = s(e)?.[0];
257
+ S?.(u(t?.label), t?.label, t), I(t?.label), P(!1), R(!1);
258
+ }, J = () => {
259
+ (!n || !F) && ye(), ve(), P(!1), F && R(!1);
260
+ }, Y = (e) => {
261
+ j.onKeyDown?.(e), e.key === "ArrowDown" && (!N || !L) && (H.length || U(!0), R(!0), P(!0));
262
+ }, X = ie({ isEmpty: H.length === 0 && !V && !B && !W && !G });
263
+ return /* @__PURE__ */ x(re, {
264
+ ...O,
265
+ activator: /* @__PURE__ */ b(se, {
266
+ ...j,
267
+ append: te,
268
+ autoComplete: ne,
269
+ clearable: ue,
270
+ "data-testid": a(m, "input"),
271
+ onChange: K,
272
+ onClear: q,
273
+ onFocus: be,
274
+ onKeyDown: Y,
275
+ value: F,
276
+ ref: M
277
+ }),
278
+ autoHighlight: E,
279
+ className: e(le, O.className, X.root, t.Autocomplete),
280
+ contentClassName: e(O.contentClassName, X.popoverContent),
281
+ contentStyle: O.contentStyle,
282
+ "data-testid": m,
283
+ minLength: 0,
284
+ onActivated: () => (L || n) && P(!0),
285
+ onDeactivated: J,
286
+ show: N,
287
+ type: "listbox",
288
+ focusStartIndex: 0,
289
+ children: [
290
+ V && !H.length && /* @__PURE__ */ x(f, {
291
+ gap: "sm",
292
+ verticalAlign: "middle",
293
+ p: "spacing.3",
294
+ children: [/* @__PURE__ */ b(o, { color: "colour.neutral.70" }), /* @__PURE__ */ b(i, {
295
+ color: "colour.neutral.70",
296
+ children: "Loading results..."
297
+ })]
298
+ }),
299
+ H.length > 0 && /* @__PURE__ */ x(ge, { children: [
300
+ _e,
301
+ /* @__PURE__ */ b(p, {
302
+ changeOnBlur: ae,
303
+ className: e(X.optionList),
304
+ "data-testid": a(m, "menu"),
305
+ items: H,
306
+ limitDesktop: me,
307
+ limitMobile: he,
308
+ onChange: xe,
309
+ selected: { label: z }
310
+ }),
311
+ D
312
+ ] }),
313
+ B && pe,
314
+ W && !B && /* @__PURE__ */ b(d, { minSearchLength: _ ?? 1 }),
315
+ G && !B && v
316
+ ]
317
+ });
318
+ });
319
+ D.displayName = "IressAutocomplete";
320
+ //#endregion
321
+ export { E as n, D as t };