@pega/cosmos-react-core 9.0.0-build.6.15 → 9.0.0-build.6.16

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 (50) hide show
  1. package/lib/components/FieldGroup/FieldGroup.d.ts +5 -0
  2. package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
  3. package/lib/components/FieldGroup/FieldGroup.js +10 -6
  4. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  5. package/lib/components/FieldGroup/FieldGroupList.d.ts +17 -2
  6. package/lib/components/FieldGroup/FieldGroupList.d.ts.map +1 -1
  7. package/lib/components/FieldGroup/FieldGroupList.js +200 -50
  8. package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
  9. package/lib/components/FieldGroup/FieldGroupList.utils.d.ts +33 -0
  10. package/lib/components/FieldGroup/FieldGroupList.utils.d.ts.map +1 -0
  11. package/lib/components/FieldGroup/FieldGroupList.utils.js +74 -0
  12. package/lib/components/FieldGroup/FieldGroupList.utils.js.map +1 -0
  13. package/lib/components/FieldGroup/FieldGroupListContext.d.ts +8 -0
  14. package/lib/components/FieldGroup/FieldGroupListContext.d.ts.map +1 -0
  15. package/lib/components/FieldGroup/FieldGroupListContext.js +9 -0
  16. package/lib/components/FieldGroup/FieldGroupListContext.js.map +1 -0
  17. package/lib/components/FieldGroup/index.d.ts +2 -0
  18. package/lib/components/FieldGroup/index.d.ts.map +1 -1
  19. package/lib/components/FieldGroup/index.js +2 -0
  20. package/lib/components/FieldGroup/index.js.map +1 -1
  21. package/lib/components/Form/Form.d.ts +2 -0
  22. package/lib/components/Form/Form.d.ts.map +1 -1
  23. package/lib/components/Form/Form.js +2 -2
  24. package/lib/components/Form/Form.js.map +1 -1
  25. package/lib/components/MultiStepForm/MultiStepForm.d.ts.map +1 -1
  26. package/lib/components/MultiStepForm/MultiStepForm.js +29 -3
  27. package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -1
  28. package/lib/hooks/useAnimatedText.d.ts.map +1 -1
  29. package/lib/hooks/useAnimatedText.js +5 -2
  30. package/lib/hooks/useAnimatedText.js.map +1 -1
  31. package/lib/hooks/useI18n.d.ts +2 -0
  32. package/lib/hooks/useI18n.d.ts.map +1 -1
  33. package/lib/hooks/useItemIntersection.d.ts.map +1 -1
  34. package/lib/hooks/useItemIntersection.js +3 -1
  35. package/lib/hooks/useItemIntersection.js.map +1 -1
  36. package/lib/i18n/default.d.ts +2 -0
  37. package/lib/i18n/default.d.ts.map +1 -1
  38. package/lib/i18n/default.js +2 -0
  39. package/lib/i18n/default.js.map +1 -1
  40. package/lib/i18n/i18n.d.ts +2 -0
  41. package/lib/i18n/i18n.d.ts.map +1 -1
  42. package/lib/utils/focusNonInteractiveElement.d.ts +9 -0
  43. package/lib/utils/focusNonInteractiveElement.d.ts.map +1 -0
  44. package/lib/utils/focusNonInteractiveElement.js +27 -0
  45. package/lib/utils/focusNonInteractiveElement.js.map +1 -0
  46. package/lib/utils/index.d.ts +1 -0
  47. package/lib/utils/index.d.ts.map +1 -1
  48. package/lib/utils/index.js +1 -0
  49. package/lib/utils/index.js.map +1 -1
  50. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Converts a number to a Roman numeral.
3
+ * @param num - The number to convert.
4
+ * @returns The Roman numeral representation.
5
+ */
6
+ export const convertToRoman = (num) => {
7
+ const romanMap = [
8
+ ['m', 1000],
9
+ ['cm', 900],
10
+ ['d', 500],
11
+ ['cd', 400],
12
+ ['c', 100],
13
+ ['xc', 90],
14
+ ['l', 50],
15
+ ['xl', 40],
16
+ ['x', 10],
17
+ ['ix', 9],
18
+ ['v', 5],
19
+ ['iv', 4],
20
+ ['i', 1]
21
+ ];
22
+ let result = '';
23
+ for (const [roman, value] of romanMap) {
24
+ while (num >= value) {
25
+ result += roman;
26
+ num -= value;
27
+ }
28
+ }
29
+ return result;
30
+ };
31
+ /**
32
+ * Converts a number to a base-26 alphabetic string (a, b, c... aa, ab, ac...).
33
+ * @param num - The 0-based index to convert.
34
+ * @returns The alphabetic representation.
35
+ */
36
+ export const convertToAlphabetic = (num) => {
37
+ let result = '';
38
+ while (num >= 0) {
39
+ result = String.fromCharCode((num % 26) + 97) + result;
40
+ num = Math.floor(num / 26) - 1;
41
+ }
42
+ return result;
43
+ };
44
+ /**
45
+ * Generates a list number based on depth and index.
46
+ * @param levelIndex - The index of the item in the list (0-based).
47
+ * @param depth - The depth of the list (0-based).
48
+ * @returns The formatted list number.
49
+ */
50
+ export const getFormattedListNumber = (levelIndex, depth) => {
51
+ if (depth % 3 === 0) {
52
+ return (levelIndex + 1).toString();
53
+ }
54
+ if (depth % 3 === 1) {
55
+ return convertToAlphabetic(levelIndex);
56
+ }
57
+ return convertToRoman(levelIndex + 1);
58
+ };
59
+ /**
60
+ * Generates a compound index and the current list index based on the depth and index of the current item and its ancestors.
61
+ * @param indices - An array of indices representing the position at each depth (e.g., [0, 1, 2]).
62
+ * @returns An object containing:
63
+ * - `rootIndex`: The zero-based index at the root level (e.g., 0 for "1.", 1 for "2.").
64
+ * - `currentIndex`: The index at the latest depth (e.g., "a." or "i.").
65
+ * - `compoundIndex`: The full compound index (e.g., "1.a.i").
66
+ */
67
+ export const getIndexDetails = (indices) => {
68
+ const indexSegments = indices.map((levelIndex, index) => getFormattedListNumber(levelIndex, index));
69
+ const rootIndex = indices[0];
70
+ const currentIndex = `${indexSegments[indexSegments.length - 1]}.`;
71
+ const compoundIndex = indexSegments.join('.');
72
+ return { rootIndex, currentIndex, compoundIndex };
73
+ };
74
+ //# sourceMappingURL=FieldGroupList.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldGroupList.utils.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,MAAM,QAAQ,GAAuB;QACnC,CAAC,GAAG,EAAE,IAAI,C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KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACrC,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,cAAc,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,OAAiB,EACmD,EAAE;IACtE,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CACtD,sBAAsB,CAAC,UAAU,EAAE,KAAK,CAAC,CAC1C,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,YAAY,GAAG,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC;IACnE,MAAM,aAAa,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE9C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AACpD,CAAC,CAAC","sourcesContent":["/**\n * Converts a number to a Roman numeral.\n * @param num - The number to convert.\n * @returns The Roman numeral representation.\n */\nexport const convertToRoman = (num: number) => {\n const romanMap: [string, number][] = [\n ['m', 1000],\n ['cm', 900],\n ['d', 500],\n ['cd', 400],\n ['c', 100],\n ['xc', 90],\n ['l', 50],\n ['xl', 40],\n ['x', 10],\n ['ix', 9],\n ['v', 5],\n ['iv', 4],\n ['i', 1]\n ];\n\n let result = '';\n for (const [roman, value] of romanMap) {\n while (num >= value) {\n result += roman;\n num -= value;\n }\n }\n\n return result;\n};\n\n/**\n * Converts a number to a base-26 alphabetic string (a, b, c... aa, ab, ac...).\n * @param num - The 0-based index to convert.\n * @returns The alphabetic representation.\n */\nexport const convertToAlphabetic = (num: number) => {\n let result = '';\n while (num >= 0) {\n result = String.fromCharCode((num % 26) + 97) + result;\n num = Math.floor(num / 26) - 1;\n }\n\n return result;\n};\n\n/**\n * Generates a list number based on depth and index.\n * @param levelIndex - The index of the item in the list (0-based).\n * @param depth - The depth of the list (0-based).\n * @returns The formatted list number.\n */\nexport const getFormattedListNumber = (levelIndex: number, depth: number) => {\n if (depth % 3 === 0) {\n return (levelIndex + 1).toString();\n }\n\n if (depth % 3 === 1) {\n return convertToAlphabetic(levelIndex);\n }\n\n return convertToRoman(levelIndex + 1);\n};\n\n/**\n * Generates a compound index and the current list index based on the depth and index of the current item and its ancestors.\n * @param indices - An array of indices representing the position at each depth (e.g., [0, 1, 2]).\n * @returns An object containing:\n * - `rootIndex`: The zero-based index at the root level (e.g., 0 for \"1.\", 1 for \"2.\").\n * - `currentIndex`: The index at the latest depth (e.g., \"a.\" or \"i.\").\n * - `compoundIndex`: The full compound index (e.g., \"1.a.i\").\n */\nexport const getIndexDetails = (\n indices: number[]\n): { rootIndex: number; currentIndex: string; compoundIndex: string } => {\n const indexSegments = indices.map((levelIndex, index) =>\n getFormattedListNumber(levelIndex, index)\n );\n\n const rootIndex = indices[0];\n const currentIndex = `${indexSegments[indexSegments.length - 1]}.`;\n const compoundIndex = indexSegments.join('.');\n\n return { rootIndex, currentIndex, compoundIndex };\n};\n"]}
@@ -0,0 +1,8 @@
1
+ export interface FieldGroupListContextValue {
2
+ depth: number;
3
+ ancestorIndices: number[];
4
+ isAncestorHighlighted: boolean;
5
+ }
6
+ declare const FieldGroupListContext: import("react").Context<FieldGroupListContextValue>;
7
+ export default FieldGroupListContext;
8
+ //# sourceMappingURL=FieldGroupListContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldGroupListContext.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupListContext.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAQD,QAAA,MAAM,qBAAqB,qDAA4D,CAAC;AAExF,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { createContext } from 'react';
2
+ const defaultContext = {
3
+ depth: 1,
4
+ ancestorIndices: [],
5
+ isAncestorHighlighted: false
6
+ };
7
+ const FieldGroupListContext = createContext(defaultContext);
8
+ export default FieldGroupListContext;
9
+ //# sourceMappingURL=FieldGroupListContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldGroupListContext.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupListContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAQtC,MAAM,cAAc,GAAG;IACrB,KAAK,EAAE,CAAC;IACR,eAAe,EAAE,EAAE;IACnB,qBAAqB,EAAE,KAAK;CAC7B,CAAC;AAEF,MAAM,qBAAqB,GAAG,aAAa,CAA6B,cAAc,CAAC,CAAC;AAExF,eAAe,qBAAqB,CAAC","sourcesContent":["import { createContext } from 'react';\n\nexport interface FieldGroupListContextValue {\n depth: number;\n ancestorIndices: number[];\n isAncestorHighlighted: boolean;\n}\n\nconst defaultContext = {\n depth: 1,\n ancestorIndices: [],\n isAncestorHighlighted: false\n};\n\nconst FieldGroupListContext = createContext<FieldGroupListContextValue>(defaultContext);\n\nexport default FieldGroupListContext;\n"]}
@@ -2,4 +2,6 @@ export { default, StyledFieldGroup, StyledFieldGroupLegend } from './FieldGroup'
2
2
  export type { FieldGroupProps } from './FieldGroup';
3
3
  export { default as FieldGroupList } from './FieldGroupList';
4
4
  export type { FieldGroupListProps, FieldGroupListItemProps } from './FieldGroupList';
5
+ export { default as FieldGroupListContext } from './FieldGroupListContext';
6
+ export { getIndexDetails } from './FieldGroupList.utils';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACjF,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACjF,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,3 +1,5 @@
1
1
  export { default, StyledFieldGroup, StyledFieldGroupLegend } from './FieldGroup';
2
2
  export { default as FieldGroupList } from './FieldGroupList';
3
+ export { default as FieldGroupListContext } from './FieldGroupListContext';
4
+ export { getIndexDetails } from './FieldGroupList.utils';
3
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { default, StyledFieldGroup, StyledFieldGroupLegend } from './FieldGroup';\nexport type { FieldGroupProps } from './FieldGroup';\nexport { default as FieldGroupList } from './FieldGroupList';\nexport type { FieldGroupListProps, FieldGroupListItemProps } from './FieldGroupList';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { default, StyledFieldGroup, StyledFieldGroupLegend } from './FieldGroup';\nexport type { FieldGroupProps } from './FieldGroup';\nexport { default as FieldGroupList } from './FieldGroupList';\nexport type { FieldGroupListProps, FieldGroupListItemProps } from './FieldGroupList';\nexport { default as FieldGroupListContext } from './FieldGroupListContext';\nexport { getIndexDetails } from './FieldGroupList.utils';\n"]}
@@ -3,6 +3,8 @@ import type { BaseFormProps } from '../MultiStepForm/MultiStepForm.types';
3
3
  export interface FormProps extends OmitStrict<BaseFormProps, 'content'>, TestIdProp {
4
4
  /** The Form content. Recommended composing form elements within a layout template such as Grid or Flex as the only child. */
5
5
  children: BaseFormProps['content'];
6
+ /** Label for the form. */
7
+ label?: string;
6
8
  }
7
9
  declare const _default: ForwardRefForwardPropsComponent<FormProps> & {
8
10
  getTestIds: (testIdProp?: TestIdProp["testId"]) => import("../../types").TestIdsRecord<readonly []>;
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,+BAA+B,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAK1E,MAAM,WAAW,SAAU,SAAQ,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,UAAU;IACjF,6HAA6H;IAC7H,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACpC;;;;AAyCD,wBAAiD"}
1
+ {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,+BAA+B,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAK1E,MAAM,WAAW,SAAU,SAAQ,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,UAAU;IACjF,6HAA6H;IAC7H,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;;;;AA0CD,wBAAiD"}
@@ -4,13 +4,13 @@ import { useTestIds, useUID } from '../../hooks';
4
4
  import MultiStepForm from '../MultiStepForm';
5
5
  import { withTestIds } from '../../utils';
6
6
  import { getFormTestIds } from './Form.test-ids';
7
- const Form = forwardRef(function Form({ testId, children, actions, progress, heading, description, banners, ...restProps }, ref) {
7
+ const Form = forwardRef(function Form({ testId, children, actions, progress, heading, label, description, banners, ...restProps }, ref) {
8
8
  const stepId = useUID();
9
9
  const testIds = useTestIds(testId, getFormTestIds);
10
10
  return (_jsx(MultiStepForm, { "data-testid": testIds.root, autoComplete: '_off', ...restProps, heading: heading, steps: [
11
11
  {
12
12
  id: stepId,
13
- name: '',
13
+ name: label ?? '',
14
14
  actions,
15
15
  content: children,
16
16
  description,
@@ -1 +1 @@
1
- {"version":3,"file":"Form.js","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAInC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAOjD,MAAM,IAAI,GAA+C,UAAU,CAAC,SAAS,IAAI,CAC/E,EACE,MAAM,EACN,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,WAAW,EACX,OAAO,EACP,GAAG,SAAS,EACe,EAC7B,GAAqB;IAErB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEnD,OAAO,CACL,KAAC,aAAa,mBACC,OAAO,CAAC,IAAI,EACzB,YAAY,EAAC,MAAM,KACf,SAAS,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,MAAM;gBACV,IAAI,EAAE,EAAE;gBACR,OAAO;gBACP,OAAO,EAAE,QAAQ;gBACjB,WAAW;gBACX,OAAO;aACR;SACF,EACD,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,GACR,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport type { ForwardRefForwardPropsComponent, OmitStrict, TestIdProp } from '../../types';\nimport { useTestIds, useUID } from '../../hooks';\nimport MultiStepForm from '../MultiStepForm';\nimport type { BaseFormProps } from '../MultiStepForm/MultiStepForm.types';\nimport { withTestIds } from '../../utils';\n\nimport { getFormTestIds } from './Form.test-ids';\n\nexport interface FormProps extends OmitStrict<BaseFormProps, 'content'>, TestIdProp {\n /** The Form content. Recommended composing form elements within a layout template such as Grid or Flex as the only child. */\n children: BaseFormProps['content'];\n}\n\nconst Form: ForwardRefForwardPropsComponent<FormProps> = forwardRef(function Form(\n {\n testId,\n children,\n actions,\n progress,\n heading,\n description,\n banners,\n ...restProps\n }: PropsWithoutRef<FormProps>,\n ref: FormProps['ref']\n) {\n const stepId = useUID();\n const testIds = useTestIds(testId, getFormTestIds);\n\n return (\n <MultiStepForm\n data-testid={testIds.root}\n autoComplete='_off'\n {...restProps}\n heading={heading}\n steps={[\n {\n id: stepId,\n name: '',\n actions,\n content: children,\n description,\n banners\n }\n ]}\n currentStepId={stepId}\n progress={progress}\n ref={ref}\n />\n );\n});\n\nexport default withTestIds(Form, getFormTestIds);\n"]}
1
+ {"version":3,"file":"Form.js","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAInC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AASjD,MAAM,IAAI,GAA+C,UAAU,CAAC,SAAS,IAAI,CAC/E,EACE,MAAM,EACN,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,KAAK,EACL,WAAW,EACX,OAAO,EACP,GAAG,SAAS,EACe,EAC7B,GAAqB;IAErB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEnD,OAAO,CACL,KAAC,aAAa,mBACC,OAAO,CAAC,IAAI,EACzB,YAAY,EAAC,MAAM,KACf,SAAS,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,MAAM;gBACV,IAAI,EAAE,KAAK,IAAI,EAAE;gBACjB,OAAO;gBACP,OAAO,EAAE,QAAQ;gBACjB,WAAW;gBACX,OAAO;aACR;SACF,EACD,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,GACR,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport type { ForwardRefForwardPropsComponent, OmitStrict, TestIdProp } from '../../types';\nimport { useTestIds, useUID } from '../../hooks';\nimport MultiStepForm from '../MultiStepForm';\nimport type { BaseFormProps } from '../MultiStepForm/MultiStepForm.types';\nimport { withTestIds } from '../../utils';\n\nimport { getFormTestIds } from './Form.test-ids';\n\nexport interface FormProps extends OmitStrict<BaseFormProps, 'content'>, TestIdProp {\n /** The Form content. Recommended composing form elements within a layout template such as Grid or Flex as the only child. */\n children: BaseFormProps['content'];\n /** Label for the form. */\n label?: string;\n}\n\nconst Form: ForwardRefForwardPropsComponent<FormProps> = forwardRef(function Form(\n {\n testId,\n children,\n actions,\n progress,\n heading,\n label,\n description,\n banners,\n ...restProps\n }: PropsWithoutRef<FormProps>,\n ref: FormProps['ref']\n) {\n const stepId = useUID();\n const testIds = useTestIds(testId, getFormTestIds);\n\n return (\n <MultiStepForm\n data-testid={testIds.root}\n autoComplete='_off'\n {...restProps}\n heading={heading}\n steps={[\n {\n id: stepId,\n name: label ?? '',\n actions,\n content: children,\n description,\n banners\n }\n ]}\n currentStepId={stepId}\n progress={progress}\n ref={ref}\n />\n );\n});\n\nexport default withTestIds(Form, getFormTestIds);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MultiStepForm.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAWnE,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAC;AAI5D,eAAO,MAAM,UAAU;cAA2B,OAAO;cAAY,OAAO;SAkB3E,CAAC;AAIF,eAAO,MAAM,iBAAiB,yGAAe,CAAC;AAE9C,eAAO,MAAM,yBAAyB,gKAqBpC,CAAC;AAIH,QAAA,MAAM,aAAa,EAAE,+BAA+B,CAAC,kBAAkB,CAyKtE,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"MultiStepForm.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAWnE,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAC;AAI5D,eAAO,MAAM,UAAU;cAA2B,OAAO;cAAY,OAAO;SAuB3E,CAAC;AAIF,eAAO,MAAM,iBAAiB,yGAAe,CAAC;AAE9C,eAAO,MAAM,yBAAyB,gKAqBpC,CAAC;AAIH,QAAA,MAAM,aAAa,EAAE,+BAA+B,CAAC,kBAAkB,CA2LtE,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useRef, useEffect } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
4
  import { useAfterInitialEffect, useUID, useI18n, usePrevious, useBreakpoint, useTheme, useConsolidatedRef } from '../../hooks';
5
- import { focusHeadingOrContainer } from '../../utils';
5
+ import { focusNonInteractiveElement, isInstance } from '../../utils';
6
6
  import { calculateFontSize } from '../../styles';
7
7
  import Text from '../Text';
8
8
  import HTML from '../HTML';
@@ -28,6 +28,11 @@ export const StyledForm = styled.form(({ actions, heading, theme }) => {
28
28
  padding-block-start: calc(2 * ${theme.base.spacing});
29
29
  `}
30
30
  }
31
+
32
+ &:focus-visible {
33
+ outline: none;
34
+ box-shadow: ${theme.base.shadow.focus};
35
+ }
31
36
  `;
32
37
  });
33
38
  StyledForm.defaultProps = defaultThemeProp;
@@ -50,6 +55,7 @@ export const StyledRequiredFieldLegend = styled(Text)(({ theme }) => {
50
55
  StyledRequiredFieldLegend.defaultProps = defaultThemeProp;
51
56
  const MultiStepForm = forwardRef(function MultiStepForm({ currentStepId, steps, heading, stepIndicator: stepIndicatorProp, progress, ...restProps }, ref) {
52
57
  const multiStepRef = useConsolidatedRef(ref);
58
+ const headingRef = useRef(null);
53
59
  const progressIndicatorRef = useRef(null);
54
60
  const multiStepFormContentRef = useRef(null);
55
61
  const multiStepActionsRef = useRef(null);
@@ -76,8 +82,28 @@ const MultiStepForm = forwardRef(function MultiStepForm({ currentStepId, steps,
76
82
  ];
77
83
  focusables[0]?.focus();
78
84
  }
85
+ else if (headingRef.current) {
86
+ focusNonInteractiveElement(headingRef.current);
87
+ }
79
88
  else if (multiStepRef.current) {
80
- focusHeadingOrContainer(multiStepRef.current, currentStep.name);
89
+ const containerEl = multiStepRef.current.closest('[data-focusable-form-container]');
90
+ const headingEl = containerEl?.querySelector('[data-focusable-form-heading]');
91
+ if (isInstance(headingEl, HTMLElement)) {
92
+ focusNonInteractiveElement(headingEl);
93
+ }
94
+ else {
95
+ let label;
96
+ if (heading && currentStep.name) {
97
+ label = `${heading} - ${currentStep.name}`;
98
+ }
99
+ else if (currentStep.name) {
100
+ label = currentStep.name;
101
+ }
102
+ else if (heading) {
103
+ label = heading;
104
+ }
105
+ focusNonInteractiveElement(multiStepRef.current, label);
106
+ }
81
107
  }
82
108
  };
83
109
  // Set focus if the current step id updates
@@ -123,7 +149,7 @@ const MultiStepForm = forwardRef(function MultiStepForm({ currentStepId, steps,
123
149
  areaDef += '"description" ';
124
150
  areaDef += '"content"';
125
151
  }
126
- return (_jsxs(StyledForm, { ref: multiStepRef, ...restProps, "aria-labelledby": heading ? headingId : undefined, "aria-describedby": currentStep.description ? descriptionId : undefined, heading: !!heading, actions: !!currentStep.actions, children: [heading && (_jsx(Text, { id: headingId, variant: 'h3', children: heading })), _jsxs(Grid, { container: {
152
+ return (_jsxs(StyledForm, { ref: multiStepRef, ...restProps, "aria-labelledby": heading ? headingId : undefined, "aria-describedby": currentStep.description ? descriptionId : undefined, heading: !!heading, actions: !!currentStep.actions, children: [heading && (_jsx(Text, { ref: headingRef, id: headingId, variant: 'h3', children: heading })), _jsxs(Grid, { container: {
127
153
  cols: stepIndicator === 'vertical'
128
154
  ? `2fr minmax(${contentWidth.xs}, 1fr)`
129
155
  : 'minmax(0, 1fr)',
@@ -1 +1 @@
1
- {"version":3,"file":"MultiStepForm.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,WAAW,EACX,aAAa,EACb,QAAQ,EACR,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAGrD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAE9D,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAA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YACnC,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,aAAa;oCACvD,CAAC,CAAC,CAAC,CAAC,sBAAsB,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;oCAC/C,CAAC,CAAC,EAAE,GACa,IAChB,CACR,EAEA,WAAW,CAAC,OAAO,IAAI,KAAC,IAAI,IAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAG,WAAW,CAAC,OAAO,GAAQ,EAEpF,WAAW,CAAC,WAAW,IAAI,CAC1B,KAAC,IAAI,IAAC,IAAI,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,YACjC,KAAC,IAAI,IAAC,EAAE,EAAE,aAAa,EAAE,EAAE,EAAC,GAAG,EAAC,OAAO,EAAE,WAAW,CAAC,WAAW,GAAI,GAC/D,CACR,EAED,KAAC,IAAI,IAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,iBAAiB,EAAE,GAAG,EAAE,uBAAuB,YACjF,WAAW,CAAC,OAAO,GACf,EAEP,KAAC,QAAQ,IACP,OAAO,EAAE,CAAC,CAAC,QAAQ,EACnB,cAAc,QACd,SAAS,EAAC,OAAO,EACjB,OAAO,EAAE,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAC5D,IACG,EACN,WAAW,CAAC,OAAO,IAAI,CACtB,KAAC,iBAAiB,IAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,WAAW,CAAC,OAAO,GAAI,CACvF,IACU,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { forwardRef, useRef, useEffect } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n useAfterInitialEffect,\n useUID,\n useI18n,\n usePrevious,\n useBreakpoint,\n useTheme,\n useConsolidatedRef\n} from '../../hooks';\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport { focusHeadingOrContainer } from '../../utils';\nimport { calculateFontSize } from '../../styles';\nimport Text from '../Text';\nimport HTML from '../HTML';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport Grid, { StyledGrid } from '../Grid';\nimport { defaultThemeProp } from '../../theme';\nimport Progress from '../Progress';\nimport ResponsiveActions from '../ResponsiveActions';\n\nimport type MultiStepFormProps from './MultiStepForm.types';\nimport VerticalFormProgress from './VerticalFormProgress';\nimport HorizontalFormProgress from './HorizontalFormProgress';\n\nexport const StyledForm = styled.form<{ actions?: boolean; heading?: boolean }>(\n ({ actions, heading, theme }) => {\n return css`\n & > ${StyledGrid} {\n position: relative;\n\n ${actions &&\n css`\n padding-block-end: calc(2 * ${theme.base.spacing});\n `}\n\n ${heading &&\n css`\n padding-block-start: calc(2 * ${theme.base.spacing});\n `}\n }\n `;\n }\n);\n\nStyledForm.defaultProps = defaultThemeProp;\n\nexport const StyledFormContent = styled.div``;\n\nexport const StyledRequiredFieldLegend = styled(Text)(({ theme }) => {\n const {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n palette: { urgent }\n }\n } = theme;\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n font-size: ${infoFontSize};\n font-style: italic;\n\n &::before {\n display: 'inline';\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n `;\n});\n\nStyledRequiredFieldLegend.defaultProps = defaultThemeProp;\n\nconst MultiStepForm: ForwardRefForwardPropsComponent<MultiStepFormProps> = forwardRef(\n function MultiStepForm(\n {\n currentStepId,\n steps,\n heading,\n stepIndicator: stepIndicatorProp,\n progress,\n ...restProps\n }: PropsWithoutRef<MultiStepFormProps>,\n ref: MultiStepFormProps['ref']\n ) {\n const multiStepRef = useConsolidatedRef<HTMLFormElement>(ref);\n const progressIndicatorRef = useRef<HTMLDivElement>(null);\n const multiStepFormContentRef = useRef<HTMLDivElement>(null);\n const multiStepActionsRef = useRef<HTMLDivElement>(null);\n\n const previousId = usePrevious(currentStepId);\n const currentStep = steps.find(step => step.id === currentStepId)!;\n const headingId = useUID();\n const descriptionId = useUID();\n const t = useI18n();\n const {\n base: { 'content-width': contentWidth }\n } = useTheme();\n\n const isSmallOrAbove = useBreakpoint('sm');\n\n const stepIndicator = (() => {\n if (stepIndicatorProp === 'none' || steps.length < 2) return 'none';\n\n if (!isSmallOrAbove) return 'horizontal';\n\n return stepIndicatorProp ?? 'horizontal';\n })();\n\n const setFocus = () => {\n if (progress) return;\n\n if (stepIndicator !== 'none' && progressIndicatorRef.current) {\n const focusables = [\n ...progressIndicatorRef.current.querySelectorAll(`[id=\"${currentStepId}\"]`)\n ] as HTMLElement[];\n focusables[0]?.focus();\n } else if (multiStepRef.current) {\n focusHeadingOrContainer(multiStepRef.current, currentStep.name);\n }\n };\n\n // Set focus if the current step id updates\n useEffect(() => {\n if (previousId !== currentStepId) {\n setFocus();\n }\n }, [currentStepId, previousId]);\n\n // Set focus if the form content updates while focus is within the actions region of the form\n useAfterInitialEffect(() => {\n if (\n multiStepActionsRef.current &&\n multiStepActionsRef.current.contains(document.activeElement)\n ) {\n setFocus();\n }\n }, [currentStep.content]);\n\n // Set focus if a progress state resolves\n useAfterInitialEffect(() => {\n if (!progress) {\n setFocus();\n }\n }, [progress]);\n\n let areaDef = '';\n switch (stepIndicator) {\n case 'horizontal':\n areaDef += '\"stepIndicator\" ';\n if (currentStep.banners) areaDef += '\"banners\" ';\n if (currentStep.description) areaDef += '\"description\" ';\n areaDef += '\"content\"';\n break;\n case 'vertical':\n if (currentStep.banners) areaDef += '\"banners stepIndicator\" ';\n if (currentStep.description) areaDef += '\"description stepIndicator\" ';\n areaDef += '\"content stepIndicator\"';\n break;\n default:\n if (currentStep.banners) areaDef += '\"banners\" ';\n if (currentStep.description) areaDef += '\"description\" ';\n areaDef += '\"content\"';\n }\n\n return (\n <StyledForm\n ref={multiStepRef}\n {...restProps}\n aria-labelledby={heading ? headingId : undefined}\n aria-describedby={currentStep.description ? descriptionId : undefined}\n heading={!!heading}\n actions={!!currentStep.actions}\n >\n {heading && (\n <Text id={headingId} variant='h3'>\n {heading}\n </Text>\n )}\n\n <Grid\n container={{\n cols:\n stepIndicator === 'vertical'\n ? `2fr minmax(${contentWidth.xs}, 1fr)`\n : 'minmax(0, 1fr)',\n areas: areaDef,\n gap: 2\n }}\n inert={progress ? '' : undefined}\n >\n {steps.length > 1 && (\n <Grid ref={progressIndicatorRef} item={{ area: 'stepIndicator' }}>\n {stepIndicator === 'horizontal' && (\n <Grid\n item={{ area: 'stepIndicator' }}\n as={HorizontalFormProgress}\n steps={steps}\n currentStepId={currentStepId}\n />\n )}\n {stepIndicator === 'vertical' && (\n <Grid\n item={{ area: 'stepIndicator' }}\n as={VerticalFormProgress}\n steps={steps}\n currentStepId={currentStepId}\n />\n )}\n <VisuallyHiddenText aria-live='polite'>\n {previousId !== undefined && previousId !== currentStepId\n ? t('step_changed_to_name', [currentStep.name])\n : ''}\n </VisuallyHiddenText>\n </Grid>\n )}\n\n {currentStep.banners && <Grid item={{ area: 'banners' }}>{currentStep.banners}</Grid>}\n\n {currentStep.description && (\n <Grid item={{ area: 'description' }}>\n <HTML id={descriptionId} as='p' content={currentStep.description} />\n </Grid>\n )}\n\n <Grid item={{ area: 'content' }} as={StyledFormContent} ref={multiStepFormContentRef}>\n {currentStep.content}\n </Grid>\n\n <Progress\n visible={!!progress}\n focusOnVisible\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n </Grid>\n {currentStep.actions && (\n <ResponsiveActions actionsRef={multiStepActionsRef} actionsEl={currentStep.actions} />\n )}\n </StyledForm>\n );\n }\n);\n\nexport default MultiStepForm;\n"]}
1
+ {"version":3,"file":"MultiStepForm.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO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ACtB,KAAC,iBAAiB,IAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,WAAW,CAAC,OAAO,GAAI,CACvF,IACU,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { forwardRef, useRef, useEffect } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n useAfterInitialEffect,\n useUID,\n useI18n,\n usePrevious,\n useBreakpoint,\n useTheme,\n useConsolidatedRef\n} from '../../hooks';\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport { focusNonInteractiveElement, isInstance } from '../../utils';\nimport { calculateFontSize } from '../../styles';\nimport Text from '../Text';\nimport HTML from '../HTML';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport Grid, { StyledGrid } from '../Grid';\nimport { defaultThemeProp } from '../../theme';\nimport Progress from '../Progress';\nimport ResponsiveActions from '../ResponsiveActions';\n\nimport type MultiStepFormProps from './MultiStepForm.types';\nimport VerticalFormProgress from './VerticalFormProgress';\nimport HorizontalFormProgress from './HorizontalFormProgress';\n\nexport const StyledForm = styled.form<{ actions?: boolean; heading?: boolean }>(\n ({ actions, heading, theme }) => {\n return css`\n & > ${StyledGrid} {\n position: relative;\n\n ${actions &&\n css`\n padding-block-end: calc(2 * ${theme.base.spacing});\n `}\n\n ${heading &&\n css`\n padding-block-start: calc(2 * ${theme.base.spacing});\n `}\n }\n\n &:focus-visible {\n outline: none;\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n }\n);\n\nStyledForm.defaultProps = defaultThemeProp;\n\nexport const StyledFormContent = styled.div``;\n\nexport const StyledRequiredFieldLegend = styled(Text)(({ theme }) => {\n const {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n palette: { urgent }\n }\n } = theme;\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n font-size: ${infoFontSize};\n font-style: italic;\n\n &::before {\n display: 'inline';\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n `;\n});\n\nStyledRequiredFieldLegend.defaultProps = defaultThemeProp;\n\nconst MultiStepForm: ForwardRefForwardPropsComponent<MultiStepFormProps> = forwardRef(\n function MultiStepForm(\n {\n currentStepId,\n steps,\n heading,\n stepIndicator: stepIndicatorProp,\n progress,\n ...restProps\n }: PropsWithoutRef<MultiStepFormProps>,\n ref: MultiStepFormProps['ref']\n ) {\n const multiStepRef = useConsolidatedRef<HTMLFormElement>(ref);\n const headingRef = useRef<HTMLHeadingElement>(null);\n const progressIndicatorRef = useRef<HTMLDivElement>(null);\n const multiStepFormContentRef = useRef<HTMLDivElement>(null);\n const multiStepActionsRef = useRef<HTMLDivElement>(null);\n\n const previousId = usePrevious(currentStepId);\n const currentStep = steps.find(step => step.id === currentStepId)!;\n const headingId = useUID();\n const descriptionId = useUID();\n const t = useI18n();\n const {\n base: { 'content-width': contentWidth }\n } = useTheme();\n\n const isSmallOrAbove = useBreakpoint('sm');\n\n const stepIndicator = (() => {\n if (stepIndicatorProp === 'none' || steps.length < 2) return 'none';\n\n if (!isSmallOrAbove) return 'horizontal';\n\n return stepIndicatorProp ?? 'horizontal';\n })();\n\n const setFocus = () => {\n if (progress) return;\n\n if (stepIndicator !== 'none' && progressIndicatorRef.current) {\n const focusables = [\n ...progressIndicatorRef.current.querySelectorAll(`[id=\"${currentStepId}\"]`)\n ] as HTMLElement[];\n focusables[0]?.focus();\n } else if (headingRef.current) {\n focusNonInteractiveElement(headingRef.current);\n } else if (multiStepRef.current) {\n const containerEl = multiStepRef.current.closest('[data-focusable-form-container]');\n const headingEl = containerEl?.querySelector('[data-focusable-form-heading]');\n if (isInstance(headingEl, HTMLElement)) {\n focusNonInteractiveElement(headingEl);\n } else {\n let label: string | undefined;\n if (heading && currentStep.name) {\n label = `${heading} - ${currentStep.name}`;\n } else if (currentStep.name) {\n label = currentStep.name;\n } else if (heading) {\n label = heading;\n }\n\n focusNonInteractiveElement(multiStepRef.current, label);\n }\n }\n };\n\n // Set focus if the current step id updates\n useEffect(() => {\n if (previousId !== currentStepId) {\n setFocus();\n }\n }, [currentStepId, previousId]);\n\n // Set focus if the form content updates while focus is within the actions region of the form\n useAfterInitialEffect(() => {\n if (\n multiStepActionsRef.current &&\n multiStepActionsRef.current.contains(document.activeElement)\n ) {\n setFocus();\n }\n }, [currentStep.content]);\n\n // Set focus if a progress state resolves\n useAfterInitialEffect(() => {\n if (!progress) {\n setFocus();\n }\n }, [progress]);\n\n let areaDef = '';\n switch (stepIndicator) {\n case 'horizontal':\n areaDef += '\"stepIndicator\" ';\n if (currentStep.banners) areaDef += '\"banners\" ';\n if (currentStep.description) areaDef += '\"description\" ';\n areaDef += '\"content\"';\n break;\n case 'vertical':\n if (currentStep.banners) areaDef += '\"banners stepIndicator\" ';\n if (currentStep.description) areaDef += '\"description stepIndicator\" ';\n areaDef += '\"content stepIndicator\"';\n break;\n default:\n if (currentStep.banners) areaDef += '\"banners\" ';\n if (currentStep.description) areaDef += '\"description\" ';\n areaDef += '\"content\"';\n }\n\n return (\n <StyledForm\n ref={multiStepRef}\n {...restProps}\n aria-labelledby={heading ? headingId : undefined}\n aria-describedby={currentStep.description ? descriptionId : undefined}\n heading={!!heading}\n actions={!!currentStep.actions}\n >\n {heading && (\n <Text ref={headingRef} id={headingId} variant='h3'>\n {heading}\n </Text>\n )}\n\n <Grid\n container={{\n cols:\n stepIndicator === 'vertical'\n ? `2fr minmax(${contentWidth.xs}, 1fr)`\n : 'minmax(0, 1fr)',\n areas: areaDef,\n gap: 2\n }}\n inert={progress ? '' : undefined}\n >\n {steps.length > 1 && (\n <Grid ref={progressIndicatorRef} item={{ area: 'stepIndicator' }}>\n {stepIndicator === 'horizontal' && (\n <Grid\n item={{ area: 'stepIndicator' }}\n as={HorizontalFormProgress}\n steps={steps}\n currentStepId={currentStepId}\n />\n )}\n {stepIndicator === 'vertical' && (\n <Grid\n item={{ area: 'stepIndicator' }}\n as={VerticalFormProgress}\n steps={steps}\n currentStepId={currentStepId}\n />\n )}\n <VisuallyHiddenText aria-live='polite'>\n {previousId !== undefined && previousId !== currentStepId\n ? t('step_changed_to_name', [currentStep.name])\n : ''}\n </VisuallyHiddenText>\n </Grid>\n )}\n\n {currentStep.banners && <Grid item={{ area: 'banners' }}>{currentStep.banners}</Grid>}\n\n {currentStep.description && (\n <Grid item={{ area: 'description' }}>\n <HTML id={descriptionId} as='p' content={currentStep.description} />\n </Grid>\n )}\n\n <Grid item={{ area: 'content' }} as={StyledFormContent} ref={multiStepFormContentRef}>\n {currentStep.content}\n </Grid>\n\n <Progress\n visible={!!progress}\n focusOnVisible\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n </Grid>\n {currentStep.actions && (\n <ResponsiveActions actionsRef={multiStepActionsRef} actionsEl={currentStep.actions} />\n )}\n </StyledForm>\n );\n }\n);\n\nexport default MultiStepForm;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useAnimatedText.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnimatedText.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,eAAe,GAAI,yDAKtB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;;;CA8GA,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"useAnimatedText.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnimatedText.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,eAAe,GAAI,yDAKtB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;;;CAiHA,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -30,10 +30,13 @@ const useAnimatedText = ({ text, allContentReceived = false, enabled = true, tok
30
30
  const tokens = getTokens(text);
31
31
  const targetLength = tokens.length;
32
32
  const charactersToAnimate = targetLength - startingCursor;
33
- // If there are no more characters, return
33
+ // If there are no more characters to animate
34
34
  if (charactersToAnimate <= 0) {
35
35
  setCursor(targetLength);
36
- setIsAnimationDone(true);
36
+ // Only set animation done if we have all content AND no more characters to animate
37
+ if (allContentReceivedRef.current) {
38
+ setIsAnimationDone(true);
39
+ }
37
40
  return;
38
41
  }
39
42
  let intervalId;
@@ -1 +1 @@
1
- {"version":3,"file":"useAnimatedText.js","sourceRoot":"","sources":["../../src/hooks/useAnimatedText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,oBAAoB,MAAM,4BAA4B,CAAC;AAE9D,MAAM,eAAe,GAAG,CAAC,EACvB,IAAI,EACJ,kBAAkB,GAAG,KAAK,EAC1B,OAAO,GAAG,IAAI,EACd,gBAAgB,GAAG,KAAK,EAMzB,EAAE,EAAE;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc;IACvD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B;IAEpF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9D,MAAM,qBAAqB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAEzD,qBAAqB,CAAC,OAAO,GAAG,kBAAkB,CAAC;IAEnD,uCAAuC;IACvC,MAAM,SAAS,GAAG,CAAC,SAAiB,EAAY,EAAE;QAChD,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,oBAAo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AAG,UAAU,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;QAElD,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;YACjB,IAAI,UAAU,EAAE,CAAC;gBACf,YAAY,CAAC,UAAU,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE7C,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { useEffect, useState, useRef } from 'react';\n\nimport tokenizeWithMarkdown from '../utils/markdownTokenizer';\n\nconst useAnimatedText = ({\n text,\n allContentReceived = false,\n enabled = true,\n tokenizeMarkdown = false\n}: {\n text: string;\n allContentReceived: boolean;\n enabled?: boolean;\n tokenizeMarkdown?: boolean;\n}) => {\n const [cursor, setCursor] = useState(0); // End pointer\n const [startingCursor, setStartingCursor] = useState(0); // animation starting point\n\n const [prevText, setPrevText] = useState(text);\n const [isAnimationDone, setIsAnimationDone] = useState(false);\n\n const allContentReceivedRef = useRef(allContentReceived);\n\n allContentReceivedRef.current = allContentReceived;\n\n // Tokenize text based on markdown flag\n const getTokens = (inputText: string): string[] => {\n if (tokenizeMarkdown) {\n return tokenizeWithMarkdown(inputText);\n }\n return inputText.split('');\n };\n\n // A new chunk has arrived\n if (prevText !== text) {\n setPrevText(text);\n setStartingCursor(text.startsWith(prevText) ? cursor : 0);\n setIsAnimationDone(false);\n }\n\n useEffect(() => {\n // If streaming is disabled just return the whole chunk back\n if (!enabled) {\n setCursor(getTokens(text).length);\n setIsAnimationDone(true);\n return;\n }\n\n const tokens = getTokens(text);\n const targetLength = tokens.length;\n const charactersToAnimate = targetLength - startingCursor;\n\n // If there are no more characters, return\n if (charactersToAnimate <= 0) {\n setCursor(targetLength);\n setIsAnimationDone(true);\n return;\n }\n\n let intervalId: ReturnType<typeof setTimeout>;\n let startTime: number;\n let isStopped = false;\n let currentSpeed = 50; // Start with normal speed\n let lastCursor = startingCursor;\n\n const processTextAnimation = () => {\n if (isStopped) return;\n\n const currentTime = performance.now();\n\n if (!startTime) {\n startTime = currentTime;\n }\n\n // When we have all content with us, speed up streaming animation\n const targetSpeed = allContentReceivedRef.current ? 150 : 50;\n\n // Smoothly transition to target speed\n const speedDiff = targetSpeed - currentSpeed;\n currentSpeed += speedDiff * 0.1; // Smooth transition\n\n const elapsed = currentTime - startTime;\n const timeStep = elapsed / 1000;\n\n // Calculate how many characters we should have shown by now\n const expectedCursor = Math.min(startingCursor + timeStep * currentSpeed, targetLength);\n\n const newCursor = Math.min(Math.floor(expectedCursor), targetLength);\n\n // Skip update if the cursor is at the same token\n if (newCursor !== lastCursor) {\n setCursor(newCursor);\n lastCursor = newCursor;\n }\n\n // End condition - stop when we reach the target\n if (newCursor >= targetLength && allContentReceivedRef.current) {\n setIsAnimationDone(true);\n return;\n }\n\n // Continue animation if not done\n if (newCursor < targetLength || !allContentReceivedRef.current) {\n // Use adaptive timing based on content state and visibility\n const interval = allContentReceivedRef.current ? 20 : 50; // Faster when complete\n intervalId = setTimeout(processTextAnimation, interval);\n }\n };\n\n // Start the animation with initial delay\n intervalId = setTimeout(processTextAnimation, 16);\n\n return () => {\n isStopped = true;\n if (intervalId) {\n clearTimeout(intervalId);\n }\n };\n }, [startingCursor, text, tokenizeMarkdown]);\n\n return {\n text: getTokens(text).slice(0, cursor).join(''),\n isAnimationDone\n };\n};\n\nexport default useAnimatedText;\n"]}
1
+ {"version":3,"file":"useAnimatedText.js","sourceRoot":"","sources":["../../src/hooks/useAnimatedText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,oB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CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { useEffect, useState, useRef } from 'react';\n\nimport tokenizeWithMarkdown from '../utils/markdownTokenizer';\n\nconst useAnimatedText = ({\n text,\n allContentReceived = false,\n enabled = true,\n tokenizeMarkdown = false\n}: {\n text: string;\n allContentReceived: boolean;\n enabled?: boolean;\n tokenizeMarkdown?: boolean;\n}) => {\n const [cursor, setCursor] = useState(0); // End pointer\n const [startingCursor, setStartingCursor] = useState(0); // animation starting point\n\n const [prevText, setPrevText] = useState(text);\n const [isAnimationDone, setIsAnimationDone] = useState(false);\n\n const allContentReceivedRef = useRef(allContentReceived);\n\n allContentReceivedRef.current = allContentReceived;\n\n // Tokenize text based on markdown flag\n const getTokens = (inputText: string): string[] => {\n if (tokenizeMarkdown) {\n return tokenizeWithMarkdown(inputText);\n }\n return inputText.split('');\n };\n\n // A new chunk has arrived\n if (prevText !== text) {\n setPrevText(text);\n setStartingCursor(text.startsWith(prevText) ? cursor : 0);\n setIsAnimationDone(false);\n }\n\n useEffect(() => {\n // If streaming is disabled just return the whole chunk back\n if (!enabled) {\n setCursor(getTokens(text).length);\n setIsAnimationDone(true);\n return;\n }\n\n const tokens = getTokens(text);\n const targetLength = tokens.length;\n const charactersToAnimate = targetLength - startingCursor;\n\n // If there are no more characters to animate\n if (charactersToAnimate <= 0) {\n setCursor(targetLength);\n // Only set animation done if we have all content AND no more characters to animate\n if (allContentReceivedRef.current) {\n setIsAnimationDone(true);\n }\n return;\n }\n\n let intervalId: ReturnType<typeof setTimeout>;\n let startTime: number;\n let isStopped = false;\n let currentSpeed = 50; // Start with normal speed\n let lastCursor = startingCursor;\n\n const processTextAnimation = () => {\n if (isStopped) return;\n\n const currentTime = performance.now();\n\n if (!startTime) {\n startTime = currentTime;\n }\n\n // When we have all content with us, speed up streaming animation\n const targetSpeed = allContentReceivedRef.current ? 150 : 50;\n\n // Smoothly transition to target speed\n const speedDiff = targetSpeed - currentSpeed;\n currentSpeed += speedDiff * 0.1; // Smooth transition\n\n const elapsed = currentTime - startTime;\n const timeStep = elapsed / 1000;\n\n // Calculate how many characters we should have shown by now\n const expectedCursor = Math.min(startingCursor + timeStep * currentSpeed, targetLength);\n\n const newCursor = Math.min(Math.floor(expectedCursor), targetLength);\n\n // Skip update if the cursor is at the same token\n if (newCursor !== lastCursor) {\n setCursor(newCursor);\n lastCursor = newCursor;\n }\n\n // End condition - stop when we reach the target\n if (newCursor >= targetLength && allContentReceivedRef.current) {\n setIsAnimationDone(true);\n return;\n }\n\n // Continue animation if not done\n if (newCursor < targetLength || !allContentReceivedRef.current) {\n // Use adaptive timing based on content state and visibility\n const interval = allContentReceivedRef.current ? 20 : 50; // Faster when complete\n intervalId = setTimeout(processTextAnimation, interval);\n }\n };\n\n // Start the animation with initial delay\n intervalId = setTimeout(processTextAnimation, 16);\n\n return () => {\n isStopped = true;\n if (intervalId) {\n clearTimeout(intervalId);\n }\n };\n }, [startingCursor, text, tokenizeMarkdown]);\n\n return {\n text: getTokens(text).slice(0, cursor).join(''),\n isAnimationDone\n };\n};\n\nexport default useAnimatedText;\n"]}
@@ -1536,6 +1536,8 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
1536
1536
  generating_expression: string;
1537
1537
  generated_expression: string;
1538
1538
  expression_generated: string;
1539
+ expression_builder: string;
1540
+ open_expression_builder: string;
1539
1541
  library: string;
1540
1542
  }>>;
1541
1543
  export default useI18n;
@@ -1 +1 @@
1
- {"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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1
- {"version":3,"file":"useItemIntersection.d.ts","sourceRoot":"","sources":["../../src/hooks/useItemIntersection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;;GAOG;AAEH,QAAA,MAAM,mBAAmB,GACvB,cAAc,SAAS,CAAC,WAAW,CAAC,EACpC,QAAQ,MAAM,EACd,IAAI,MAAM,IAAI,EACd,cAAc,MAAM,SA8BrB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"useItemIntersection.d.ts","sourceRoot":"","sources":["../../src/hooks/useItemIntersection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;;GAOG;AAEH,QAAA,MAAM,mBAAmB,GACvB,cAAc,SAAS,CAAC,WAAW,CAAC,EACpC,QAAQ,MAAM,EACd,IAAI,MAAM,IAAI,EACd,cAAc,MAAM,SA6BrB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -9,9 +9,11 @@ import { useEffect } from 'react';
9
9
  */
10
10
  const useItemIntersection = (containerRef, offset, cb, itemSelector) => {
11
11
  useEffect(() => {
12
+ if (!containerRef.current)
13
+ return;
12
14
  let item = null;
13
15
  if (offset > 0) {
14
- const items = (containerRef.current === null ? document.body : containerRef.current).querySelectorAll(itemSelector);
16
+ const items = containerRef.current.querySelectorAll(itemSelector);
15
17
  if (items.length > offset) {
16
18
  item = items[offset];
17
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useItemIntersection.js","sourceRoot":"","sources":["../../src/hooks/useItemIntersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC;;;;;;;GAOG;AAEH,MAAM,mBAAmB,GAAG,CAC1B,YAAoC,EACpC,MAAc,EACd,EAAc,EACd,YAAoB,EACpB,EAAE;IACF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,GAAuB,IAAI,CAAC;QACpC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACf,MAAM,KAAK,GAA4B,CACrC,YAAY,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CACrE,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;YAEjC,IAAI,KAAK,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;gBAC1B,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QACD,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CACnD,CAAC,OAAoC,EAAE,EAAE;gBACvC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;oBAC9B,EAAE,EAAE,CAAC;gBACP,CAAC;YACH,CAAC,EACD;gBACE,IAAI,EAAE,YAAY,CAAC,OAAO;aAC3B,CACF,CAAC;YACF,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACnC,OAAO,GAAG,EAAE;gBACV,oBAAoB,CAAC,UAAU,EAAE,CAAC;YACpC,CAAC,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,EAAE,EAAE,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport type { RefObject } from 'react';\n\n/**\n * @example useItemIntersection(listRef,offset,() => { do_some_thing; });\n * @param containerRef The ref of the List.\n * @param offset Index of the list item which needs to be observed.\n * @param cb Callback that needs to be fired on intersect\n * @param itemSelector Selector used to get the node list of items\n * @returns void.\n */\n\nconst useItemIntersection = (\n containerRef: RefObject<HTMLElement>,\n offset: number,\n cb: () => void,\n itemSelector: string\n) => {\n useEffect(() => {\n let item: HTMLElement | null = null;\n if (offset > 0) {\n const items: NodeListOf<HTMLElement> = (\n containerRef.current === null ? document.body : containerRef.current\n ).querySelectorAll(itemSelector);\n\n if (items.length > offset) {\n item = items[offset];\n }\n }\n if (item) {\n const intersectionObserver = new IntersectionObserver(\n (entries: IntersectionObserverEntry[]) => {\n if (entries[0].isIntersecting) {\n cb();\n }\n },\n {\n root: containerRef.current\n }\n );\n intersectionObserver.observe(item);\n return () => {\n intersectionObserver.disconnect();\n };\n }\n }, [cb, containerRef.current, offset]);\n};\n\nexport default useItemIntersection;\n"]}
1
+ {"version":3,"file":"useItemIntersection.js","sourceRoot":"","sources":["../../src/hooks/useItemIntersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC;;;;;;;GAOG;AAEH,MAAM,mBAAmB,GAAG,CAC1B,YAAoC,EACpC,MAAc,EACd,EAAc,EACd,YAAoB,EACpB,EAAE;IACF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAAY,CAAC,OAAO;YAAE,OAAO;QAClC,IAAI,IAAI,GAAuB,IAAI,CAAC;QACpC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACf,MAAM,KAAK,GAA4B,YAAY,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;YAE3F,IAAI,KAAK,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;gBAC1B,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QACD,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CACnD,CAAC,OAAoC,EAAE,EAAE;gBACvC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;oBAC9B,EAAE,EAAE,CAAC;gBACP,CAAC;YACH,CAAC,EACD;gBACE,IAAI,EAAE,YAAY,CAAC,OAAO;aAC3B,CACF,CAAC;YACF,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACnC,OAAO,GAAG,EAAE;gBACV,oBAAoB,CAAC,UAAU,EAAE,CAAC;YACpC,CAAC,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,EAAE,EAAE,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport type { RefObject } from 'react';\n\n/**\n * @example useItemIntersection(listRef,offset,() => { do_some_thing; });\n * @param containerRef The ref of the List.\n * @param offset Index of the list item which needs to be observed.\n * @param cb Callback that needs to be fired on intersect\n * @param itemSelector Selector used to get the node list of items\n * @returns void.\n */\n\nconst useItemIntersection = (\n containerRef: RefObject<HTMLElement>,\n offset: number,\n cb: () => void,\n itemSelector: string\n) => {\n useEffect(() => {\n if (!containerRef.current) return;\n let item: HTMLElement | null = null;\n if (offset > 0) {\n const items: NodeListOf<HTMLElement> = containerRef.current.querySelectorAll(itemSelector);\n\n if (items.length > offset) {\n item = items[offset];\n }\n }\n if (item) {\n const intersectionObserver = new IntersectionObserver(\n (entries: IntersectionObserverEntry[]) => {\n if (entries[0].isIntersecting) {\n cb();\n }\n },\n {\n root: containerRef.current\n }\n );\n intersectionObserver.observe(item);\n return () => {\n intersectionObserver.disconnect();\n };\n }\n }, [cb, containerRef.current, offset]);\n};\n\nexport default useItemIntersection;\n"]}
@@ -1536,6 +1536,8 @@ declare const _default: {
1536
1536
  generating_expression: string;
1537
1537
  generated_expression: string;
1538
1538
  expression_generated: string;
1539
+ expression_builder: string;
1540
+ open_expression_builder: string;
1539
1541
  library: string;
1540
1542
  };
1541
1543
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/i18n/default.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiE5C,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAhuDzC,wBAkxDE"}
@@ -1658,6 +1658,8 @@ export default {
1658
1658
  generating_expression: 'Generating expression',
1659
1659
  generated_expression: 'Generated Expression',
1660
1660
  expression_generated: 'Expression generated',
1661
+ expression_builder: 'Expression Builder',
1662
+ open_expression_builder: 'Open Expression Builder',
1661
1663
  library: 'Library'
1662
1664
  };
1663
1665
  //# sourceMappingURL=default.js.map