@useloops/design-system 1.4.722 → 1.4.724

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 (53) hide show
  1. package/dist/Platform/TestItem.d.ts +3 -1
  2. package/dist/Platform/TestItem.js +1 -1
  3. package/dist/Platform.d.ts +4 -2
  4. package/dist/Platform.js +1 -1
  5. package/dist/WebCore/FormBuilder.d.ts +2 -2
  6. package/dist/esm/Platform/TestItem.js +1 -1
  7. package/dist/esm/Platform.js +1 -1
  8. package/dist/esm/index.js +1 -1
  9. package/dist/esm/systems/BrandCore/semanticColor.js +1 -1
  10. package/dist/esm/systems/Platform/LinkExpired/LinkExpired.js +1 -1
  11. package/dist/esm/systems/Platform/MFACodeVerify/MFACodeVerify.js +1 -1
  12. package/dist/esm/systems/Platform/TestItem/TestItem.js +1 -1
  13. package/dist/esm/systems/Platform/TestItem/_partials/AnimatedDuration.js +1 -0
  14. package/dist/esm/systems/Platform/TestItem/_partials/FooterStat.js +1 -0
  15. package/dist/esm/systems/Platform/TestItem/_partials/Root.js +1 -0
  16. package/dist/esm/systems/Platform/TestItem/_partials/StatCard.js +1 -0
  17. package/dist/esm/systems/Platform/TestItem/_partials/TagList.js +1 -0
  18. package/dist/esm/systems/Platform/TestItem/_partials/TestItemSkeleton.js +1 -0
  19. package/dist/esm/systems/Platform/TestItem/helpers.js +1 -0
  20. package/dist/esm/systems/WebCore/FormBuilder/ArrayFieldRows.js +1 -0
  21. package/dist/esm/systems/WebCore/FormBuilder/Field.js +1 -1
  22. package/dist/esm/systems/WebCore/FormBuilder/FieldCollapse.js +1 -1
  23. package/dist/esm/systems/WebCore/FormBuilder/FieldMessage.js +1 -1
  24. package/dist/esm/systems/WebCore/FormBuilder/FormBuilder.js +1 -1
  25. package/dist/esm/systems/WebCore/FormBuilder/fieldRegistry.js +1 -1
  26. package/dist/index.d.ts +4 -2
  27. package/dist/index.js +1 -1
  28. package/dist/systems/BrandCore/semanticColor.js +1 -1
  29. package/dist/systems/BrandCore/types.d.ts +2 -0
  30. package/dist/systems/Platform/LinkExpired/LinkExpired.js +1 -1
  31. package/dist/systems/Platform/MFACodeVerify/MFACodeVerify.js +1 -1
  32. package/dist/systems/Platform/TestItem/TestItem.d.ts +3 -47
  33. package/dist/systems/Platform/TestItem/TestItem.js +1 -1
  34. package/dist/systems/Platform/TestItem/_partials/AnimatedDuration.js +1 -0
  35. package/dist/systems/Platform/TestItem/_partials/FooterStat.js +1 -0
  36. package/dist/systems/Platform/TestItem/_partials/Root.js +1 -0
  37. package/dist/systems/Platform/TestItem/_partials/StatCard.js +1 -0
  38. package/dist/systems/Platform/TestItem/_partials/TagList.js +1 -0
  39. package/dist/systems/Platform/TestItem/_partials/TestItemSkeleton.d.ts +6 -0
  40. package/dist/systems/Platform/TestItem/_partials/TestItemSkeleton.js +1 -0
  41. package/dist/systems/Platform/TestItem/helpers.js +1 -0
  42. package/dist/systems/Platform/TestItem/types.d.ts +32 -0
  43. package/dist/systems/WebCore/FormBuilder/ArrayFieldRows.js +1 -0
  44. package/dist/systems/WebCore/FormBuilder/Field.js +1 -1
  45. package/dist/systems/WebCore/FormBuilder/FieldCollapse.js +1 -1
  46. package/dist/systems/WebCore/FormBuilder/FieldMessage.js +1 -1
  47. package/dist/systems/WebCore/FormBuilder/FormBuilder.js +1 -1
  48. package/dist/systems/WebCore/FormBuilder/fieldRegistry.d.ts +83 -6
  49. package/dist/systems/WebCore/FormBuilder/fieldRegistry.js +1 -1
  50. package/dist/systems/WebCore/FormBuilder/types.d.ts +4 -24
  51. package/dist/systems/WebCore/FormGenerator/types.d.ts +1 -1
  52. package/dist/theme/types.d.ts +1 -0
  53. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  import { CustomFieldProps } from '../CustomField/CustomField.js';
2
2
  import { RichTextFieldProps } from '../RichTextField/RichTextField.js';
3
3
  import * as react from 'react';
4
- import { ComponentProps, ReactElement } from 'react';
4
+ import { Ref, ReactElement, ReactNode, ComponentProps } from 'react';
5
5
  import { RankProps } from '../Rank/types.js';
6
6
  import { RadioGroupProps } from '../RadioGroup/RadioGroup.js';
7
7
  import { LikertProps } from '../Likert/Likert.js';
@@ -11,15 +11,49 @@ import { SliderProps } from '../Slider/Slider.js';
11
11
  import { SwitchProps } from '../Switch/Switch.js';
12
12
  import { CheckboxGroupProps } from '../CheckboxGroup/CheckboxGroup.js';
13
13
  import { CheckboxProps } from '../Checkbox/Checkbox.js';
14
+ import { SxProps, Theme } from '@mui/material';
14
15
  import { AutocompleteFieldProps } from '../AutocompleteSingle/types.js';
15
16
  import { SelectProps } from '../Select/types.js';
16
17
  import { CreatableAutocompleteProps } from '../CreatableAutocomplete/CreatableAutocomplete.js';
17
18
  import { TextareaProps } from '../Textarea/Textarea.js';
18
19
  import { NumberFieldProps } from '../NumberField/types.js';
19
20
  import { TextFieldProps } from '../TextField/TextField.js';
20
- import { FieldValues } from 'react-hook-form';
21
- import { BaseField } from './types.js';
21
+ import { FieldValues, FieldPath } from 'react-hook-form';
22
+ import { InputLabelProps } from '../InputLabel/InputLabel.js';
23
+ import { InputLabelHelpProps } from '../InputLabelHelp/InputLabelHelp.js';
22
24
 
25
+ interface BaseField<TValues extends FieldValues = FieldValues> {
26
+ name: FieldPath<TValues>;
27
+ id?: string;
28
+ ref?: Ref<HTMLElement>;
29
+ /** A function label re-renders from the live form values — e.g. a toggle label that greys when off. */
30
+ label?: string | ReactElement | ((values: TValues) => string | ReactElement);
31
+ labelProps?: InputLabelProps;
32
+ helperText?: string | ReactNode;
33
+ helpTextProps?: InputLabelHelpProps;
34
+ hidden?: boolean;
35
+ /**
36
+ * Declarative visibility: the field shows only while this returns true for the live form values,
37
+ * animating in and out. The field stays registered while hidden unless the form unregisters hidden
38
+ * values (see `preserveHiddenValues`). Combines with `hidden` (either hides).
39
+ */
40
+ visibleWhen?: (values: TValues) => boolean;
41
+ /**
42
+ * Reactive props: recomputed from the live form values and merged over the field's static props —
43
+ * e.g. a select whose `selections` depend on how many rows another field holds.
44
+ */
45
+ deriveProps?: (values: TValues) => Record<string, unknown>;
46
+ /** Suppress the inline error message — for dense layouts that surface the error elsewhere. */
47
+ hideError?: boolean;
48
+ /** Narrowed per control type in `DynamicField`; declared here so the union is uniformly readable. */
49
+ defaultValue?: unknown;
50
+ disabled?: boolean;
51
+ styleOverrides?: {
52
+ sxInputWrapper?: SxProps<Theme>;
53
+ sxInputBase?: SxProps<Theme>;
54
+ sxInputStack?: SxProps<Theme>;
55
+ };
56
+ }
23
57
  /** Props handed to a field's component on every render — supplied by the form, never the config. */
24
58
  interface RhfFieldProps {
25
59
  value: unknown;
@@ -124,7 +158,7 @@ type ControlField<K extends DynamicFieldType, TValues extends FieldValues = Fiel
124
158
  defaultValue?: ControlProps<K> extends {
125
159
  value?: infer V;
126
160
  } ? V : unknown;
127
- } & ExtrasFor<K> & Partial<Omit<ControlProps<K>, 'value' | 'onChange' | 'name' | 'inputRef' | 'internalChange' | 'defaultValue'>>;
161
+ } & ExtrasFor<K> & Partial<Omit<ControlProps<K>, 'value' | 'onChange' | 'name' | 'inputRef' | 'internalChange' | 'defaultValue' | 'label'>>;
128
162
  type DynamicField<TValues extends FieldValues = FieldValues> = {
129
163
  [K in DynamicFieldType]: ControlField<K, TValues>;
130
164
  }[DynamicFieldType];
@@ -133,8 +167,51 @@ type HtmlField<TValues extends FieldValues = FieldValues> = Omit<BaseField<TValu
133
167
  fieldType: 'html';
134
168
  content: ReactElement;
135
169
  };
136
- type FieldTypes<TValues extends FieldValues = FieldValues> = DynamicField<TValues> | HtmlField<TValues>;
170
+ /** Per-row control config for an `ArrayField` any registry control, minus the row-managed keys. */
171
+ type ArrayItemField = {
172
+ fieldType: DynamicFieldType;
173
+ } & Record<string, unknown>;
174
+ /** Handed to an `itemField` function so custom rows can own their remove action. */
175
+ interface ArrayRowApi {
176
+ index: number;
177
+ /** Collapse this row away, then remove it from the array. */
178
+ remove: () => void;
179
+ atMinimum: boolean;
180
+ atMaximum: boolean;
181
+ }
182
+ /** Handed to the `actions` slot so custom footers can append rows (e.g. an import button). */
183
+ interface ArrayActionsApi {
184
+ /** Append a row holding `value` (falls back to `defaultItem`, then `''`). */
185
+ append: (value?: unknown) => void;
186
+ count: number;
187
+ atMaximum: boolean;
188
+ }
189
+ /**
190
+ * A react-hook-form field array: `name` holds an array of `{ value }` rows (react-hook-form field arrays
191
+ * require object items), each rendered as an `itemField` control with a remove action, plus an append
192
+ * button. `itemField` may be a function of the row index (e.g. numbered placeholders) and receives the
193
+ * row's api for rows that render their own actions.
194
+ */
195
+ type ArrayField<TValues extends FieldValues = FieldValues> = Omit<BaseField<TValues>, 'defaultValue'> & {
196
+ fieldType: 'array';
197
+ defaultValue?: {
198
+ value: unknown;
199
+ }[];
200
+ itemField: ArrayItemField | ((index: number, row: ArrayRowApi) => ArrayItemField);
201
+ /** Row removal disables at this count. */
202
+ minItems?: number;
203
+ /** The append button disables at this count. */
204
+ maxItems?: number;
205
+ addLabel?: string;
206
+ /** Value a newly appended row starts with. Defaults to `''`. */
207
+ defaultItem?: unknown;
208
+ /** `'none'` skips injecting the delete `endAdornment` — for rows that render their own actions. */
209
+ removeAction?: 'endAdornment' | 'none';
210
+ /** Replaces the default append button — e.g. Add + Import side by side. */
211
+ actions?: (api: ArrayActionsApi) => ReactNode;
212
+ };
213
+ type FieldTypes<TValues extends FieldValues = FieldValues> = DynamicField<TValues> | HtmlField<TValues> | ArrayField<TValues>;
137
214
  type FieldType = FieldTypes['fieldType'];
138
215
 
139
216
  export { FIELD_REGISTRY };
140
- export type { DynamicField, DynamicFieldType, FieldType, FieldTypes, HtmlField };
217
+ export type { ArrayActionsApi, ArrayField, ArrayItemField, ArrayRowApi, BaseField, DynamicField, DynamicFieldType, FieldType, FieldTypes, HtmlField };
@@ -1 +1 @@
1
- "use strict";var e=require("../AutocompleteField/AutocompleteField.js"),t=require("../Checkbox/Checkbox.js");require("../Checkbox/StyledCheckbox.js");var l=require("../CheckboxGroup/CheckboxGroup.js"),a=require("../CreatableAutocomplete/CreatableAutocomplete.js"),u=require("../CustomField/CustomField.js"),r=require("../Differential/Differential.js"),o=require("../Likert/Likert.js"),n=require("../NumberField/NumberField.js"),i=require("../RadioGroup/RadioGroup.js"),f=require("../Rank/Rank.js"),d=require("../RichTextField/RichTextField.js");require("../SelectItem/SelectItem.js");var s=require("../Select/Select.js"),c=require("../Slider/Slider.js"),p=require("../StarRating/StarRating.js"),m=require("../Switch/Switch.js"),g=require("../Textarea/Textarea.js");const h={textfield:{component:require("../TextField/TextField.js"),getDefault:e=>e.defaultValue??""},numberfield:{component:n.default,getDefault:e=>e.defaultValue??0},textarea:{component:g,getDefault:e=>e.defaultValue??""},creatableautocomplete:{component:a,getDefault:e=>e.defaultValue??""},select:{component:s,getDefault:e=>e.defaultValue??""},autocomplete:{component:e,getDefault:e=>e.defaultValue,adapt:(e,t)=>({onChange:(e,l)=>t.onChange(l)})},checkbox:{component:t,getDefault:e=>e.defaultValue??!1},checkboxGroup:{component:l,getDefault:e=>e.defaultValue??[]},switch:{component:m,getDefault:e=>e.defaultValue??!1,adapt:e=>({label:e.label})},slider:{component:c,getDefault:e=>Array.isArray(e.defaultValue)?e.defaultValue:e.defaultValue??e.min??0,adapt:(e,t)=>({onChange:(e,l)=>t.onChange(l)})},starRating:{component:p,getDefault:e=>e.defaultValue??0,adapt:(e,t)=>({onChange:(e,l)=>t.onChange(l)})},differential:{component:r,getDefault:e=>e.defaultValue??""},likert:{component:o,getDefault:e=>e.defaultValue??""},radioGroup:{component:i,getDefault:e=>e.defaultValue??""},ranking:{component:f,getDefault:e=>e.defaultValue?e.defaultValue.map(t=>e.options.find(e=>e.id===t)):e.options},richTextfield:{component:d,getDefault:e=>e.defaultValue??""},customfield:{component:u,getDefault:e=>e.defaultValue??""}},x=["fieldType","name","ref","label","labelProps","helperText","helpTextProps","content","styleOverrides","strengthIndicator","defaultValue","hidden"],D=e=>{if(e.noneOfThese)return!0;return(e.name||e.value||"").replace(/-/g,"_").includes("none_of_these")};exports.FIELD_REGISTRY=h,exports.extractNoneOfThese=e=>{if(!e.other?.enabled||!Array.isArray(e.options))return e;const t=e.options,l=t.findIndex(D);return-1===l?e:{...e,options:t.filter((e,t)=>t!==l),noneOfTheseOption:t[l]}},exports.getDefaultValues=e=>e.reduce((e,t)=>("html"!==t.fieldType&&(e[t.name]=h[t.fieldType].getDefault(t)),e),{}),exports.getFieldDefault=e=>"html"===e.fieldType?void 0:h[e.fieldType].getDefault(e),exports.getFieldDefinition=e=>h[e],exports.splitFieldProps=e=>{const t={};for(const l of Object.keys(e))x.includes(l)||(t[l]=e[l]);return t};
1
+ "use strict";var e=require("../AutocompleteField/AutocompleteField.js"),t=require("../Checkbox/Checkbox.js");require("../Checkbox/StyledCheckbox.js");var a=require("../CheckboxGroup/CheckboxGroup.js"),l=require("../CreatableAutocomplete/CreatableAutocomplete.js"),r=require("../CustomField/CustomField.js"),u=require("../Differential/Differential.js"),o=require("../Likert/Likert.js"),i=require("../NumberField/NumberField.js"),n=require("../RadioGroup/RadioGroup.js"),d=require("../Rank/Rank.js"),f=require("../RichTextField/RichTextField.js");require("../SelectItem/SelectItem.js");var s=require("../Select/Select.js"),c=require("../Slider/Slider.js"),p=require("../StarRating/StarRating.js"),m=require("../Switch/Switch.js"),g=require("../Textarea/Textarea.js");const h={textfield:{component:require("../TextField/TextField.js"),getDefault:e=>e.defaultValue??""},numberfield:{component:i.default,getDefault:e=>e.defaultValue??0},textarea:{component:g,getDefault:e=>e.defaultValue??""},creatableautocomplete:{component:l,getDefault:e=>e.defaultValue??""},select:{component:s,getDefault:e=>e.defaultValue??""},autocomplete:{component:e,getDefault:e=>e.defaultValue,adapt:(e,t)=>({onChange:(e,a)=>t.onChange(a)})},checkbox:{component:t,getDefault:e=>e.defaultValue??!1},checkboxGroup:{component:a,getDefault:e=>e.defaultValue??[]},switch:{component:m,getDefault:e=>e.defaultValue??!1,adapt:e=>({label:e.label})},slider:{component:c,getDefault:e=>Array.isArray(e.defaultValue)?e.defaultValue:e.defaultValue??e.min??0,adapt:(e,t)=>({onChange:(e,a)=>t.onChange(a)})},starRating:{component:p,getDefault:e=>e.defaultValue??0,adapt:(e,t)=>({onChange:(e,a)=>t.onChange(a)})},differential:{component:u,getDefault:e=>e.defaultValue??""},likert:{component:o,getDefault:e=>e.defaultValue??""},radioGroup:{component:n,getDefault:e=>e.defaultValue??""},ranking:{component:d,getDefault:e=>e.defaultValue?e.defaultValue.map(t=>e.options.find(e=>e.id===t)):e.options},richTextfield:{component:f,getDefault:e=>e.defaultValue??""},customfield:{component:r,getDefault:e=>e.defaultValue??""}},x=e=>{if("html"!==e.fieldType)return"array"===e.fieldType?e.defaultValue??[]:h[e.fieldType].getDefault(e)},D=["fieldType","name","ref","label","labelProps","helperText","helpTextProps","content","styleOverrides","strengthIndicator","defaultValue","hidden","visibleWhen","hideError","itemField","minItems","maxItems","addLabel","defaultItem","removeAction","actions","deriveProps"],V=e=>{if(e.noneOfThese)return!0;return(e.name||e.value||"").replace(/-/g,"_").includes("none_of_these")};exports.FIELD_REGISTRY=h,exports.extractNoneOfThese=e=>{if(!e.other?.enabled||!Array.isArray(e.options))return e;const t=e.options,a=t.findIndex(V);return-1===a?e:{...e,options:t.filter((e,t)=>t!==a),noneOfTheseOption:t[a]}},exports.getDefaultValues=e=>e.reduce((e,t)=>("html"!==t.fieldType&&(e[t.name]=x(t)),e),{}),exports.getFieldDefault=x,exports.getFieldDefinition=e=>h[e],exports.splitFieldProps=e=>{const t={};for(const a of Object.keys(e))D.includes(a)||(t[a]=e[a]);return t};
@@ -1,30 +1,10 @@
1
1
  import { SxProps, Theme } from '@mui/material';
2
- import { Ref, ReactElement, ReactNode } from 'react';
3
- import { FieldValues, FieldPath, Resolver, SubmitHandler, FieldErrors, UseFormSetValue, UseFormGetFieldState, UseFormTrigger, UseFormWatch } from 'react-hook-form';
4
- import '../../../index.js';
5
- import '../Text/types.js';
2
+ import { ReactElement } from 'react';
3
+ import { FieldValues, Resolver, SubmitHandler, FieldErrors, FieldPath, UseFormSetValue, UseFormGetFieldState, UseFormTrigger, UseFormWatch } from 'react-hook-form';
6
4
  import { ZodType } from 'zod';
7
5
  import { FieldTypes } from './fieldRegistry.js';
8
- export { DynamicFieldType, FieldType, HtmlField } from './fieldRegistry.js';
9
- import { InputLabelProps } from '../InputLabel/InputLabel.js';
10
- import { InputLabelHelpProps } from '../InputLabelHelp/InputLabelHelp.js';
6
+ export { ArrayActionsApi, ArrayField, ArrayItemField, ArrayRowApi, BaseField, DynamicFieldType, FieldType, HtmlField } from './fieldRegistry.js';
11
7
 
12
- interface BaseField<TValues extends FieldValues = FieldValues> {
13
- name: FieldPath<TValues>;
14
- id?: string;
15
- ref?: Ref<HTMLElement>;
16
- label?: string | ReactElement;
17
- labelProps?: InputLabelProps;
18
- helperText?: string | ReactNode;
19
- helpTextProps?: InputLabelHelpProps;
20
- hidden?: boolean;
21
- disabled?: boolean;
22
- styleOverrides?: {
23
- sxInputWrapper?: SxProps<Theme>;
24
- sxInputBase?: SxProps<Theme>;
25
- sxInputStack?: SxProps<Theme>;
26
- };
27
- }
28
8
  interface FormBuilderConfig<TValues extends FieldValues = FieldValues> {
29
9
  fields: FieldTypes<TValues>[];
30
10
  schema?: ZodType<TValues>;
@@ -67,4 +47,4 @@ interface FormBuilderProps<TValues extends FieldValues = FieldValues> {
67
47
  }
68
48
 
69
49
  export { FieldTypes };
70
- export type { BaseField, FormBuilderConfig, FormBuilderHandle, FormBuilderProps };
50
+ export type { FormBuilderConfig, FormBuilderHandle, FormBuilderProps };
@@ -19,9 +19,9 @@ import { SwitchProps } from '../Switch/Switch.js';
19
19
  import { TextareaProps } from '../Textarea/Textarea.js';
20
20
  import { NumberFieldProps } from '../NumberField/types.js';
21
21
  import { TextFieldProps } from '../TextField/TextField.js';
22
- import { HtmlProps } from '../Html/Html.js';
23
22
  import { InputLabelProps } from '../InputLabel/InputLabel.js';
24
23
  import { InputLabelHelpProps } from '../InputLabelHelp/InputLabelHelp.js';
24
+ import { HtmlProps } from '../Html/Html.js';
25
25
 
26
26
  /**
27
27
  * Form Generator Core Types
@@ -38,6 +38,7 @@ interface CustomTheme {
38
38
  strong: string;
39
39
  light: string;
40
40
  subtle: string;
41
+ transparent: string;
41
42
  focus: string;
42
43
  disabled: string;
43
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useloops/design-system",
3
- "version": "1.4.722",
3
+ "version": "1.4.724",
4
4
  "description": "The official React based Loops design system",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -245,7 +245,7 @@
245
245
  "merge-sx": "^3.5.0",
246
246
  "motion": "^12.40.0",
247
247
  "mui-tiptap": "^1.31.0",
248
- "react-hook-form": "^7.78.0",
248
+ "react-hook-form": "^7.81.0",
249
249
  "react-intersection-observer": "^9.16.0",
250
250
  "react-number-format": "^5.4.5",
251
251
  "react-phone-number-input": "^3.4.17",