@bspk/ui 1.1.12 → 1.1.14

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 (62) hide show
  1. package/dist/Checkbox.d.ts +1 -1
  2. package/dist/Checkbox.js +2 -2
  3. package/dist/Checkbox.js.map +1 -1
  4. package/dist/CheckboxOption.d.ts +2 -1
  5. package/dist/Dropdown.d.ts +3 -3
  6. package/dist/Dropdown.js +2 -1
  7. package/dist/Dropdown.js.map +1 -1
  8. package/dist/FormField.d.ts +5 -4
  9. package/dist/FormField.js +3 -3
  10. package/dist/FormField.js.map +1 -1
  11. package/dist/InlineAlert.js +1 -1
  12. package/dist/ListItem.d.ts +1 -1
  13. package/dist/ListItem.js +2 -2
  14. package/dist/ListItem.js.map +1 -1
  15. package/dist/NumberField.d.ts +2 -1
  16. package/dist/NumberInput.d.ts +22 -8
  17. package/dist/NumberInput.js +5 -2
  18. package/dist/NumberInput.js.map +1 -1
  19. package/dist/Radio.d.ts +2 -2
  20. package/dist/Radio.js.map +1 -1
  21. package/dist/RadioOption.d.ts +2 -1
  22. package/dist/RadioOption.js.map +1 -1
  23. package/dist/Skeleton.d.ts +24 -2
  24. package/dist/Skeleton.js +22 -0
  25. package/dist/Skeleton.js.map +1 -1
  26. package/dist/TextField.d.ts +2 -1
  27. package/dist/TextField.js.map +1 -1
  28. package/dist/TextInput.d.ts +3 -3
  29. package/dist/TextInput.js +2 -2
  30. package/dist/TextInput.js.map +1 -1
  31. package/dist/Textarea.d.ts +7 -7
  32. package/dist/Textarea.js +2 -2
  33. package/dist/Textarea.js.map +1 -1
  34. package/dist/form-field.css +1 -1
  35. package/dist/hooks/useFloatingMenu.d.ts +3 -2
  36. package/dist/hooks/useFloatingMenu.js +1 -0
  37. package/dist/hooks/useFloatingMenu.js.map +1 -1
  38. package/dist/index.d.ts +22 -13
  39. package/dist/index.js.map +1 -1
  40. package/dist/inline-alert.css +1 -1
  41. package/dist/number-input.css +1 -1
  42. package/meta-types.ts +5 -2
  43. package/meta.ts +8 -0
  44. package/package.json +2 -2
  45. package/src/Checkbox.tsx +3 -0
  46. package/src/CheckboxOption.tsx +4 -4
  47. package/src/Dropdown.tsx +5 -2
  48. package/src/FormField.tsx +35 -24
  49. package/src/ListItem.tsx +2 -0
  50. package/src/NumberField.tsx +5 -5
  51. package/src/NumberInput.tsx +38 -24
  52. package/src/Radio.tsx +3 -5
  53. package/src/RadioOption.tsx +4 -1
  54. package/src/Skeleton.tsx +24 -2
  55. package/src/TextField.tsx +19 -17
  56. package/src/TextInput.tsx +33 -30
  57. package/src/Textarea.tsx +51 -48
  58. package/src/form-field.scss +2 -1
  59. package/src/hooks/useFloatingMenu.ts +4 -2
  60. package/src/index.ts +24 -13
  61. package/src/inline-alert.scss +1 -1
  62. package/src/number-input.scss +6 -3
package/dist/Textarea.js CHANGED
@@ -14,7 +14,7 @@ const MAX_ROWS = 10;
14
14
  *
15
15
  * @name Textarea
16
16
  */
17
- function Textarea({ invalid: invalidProp, onChange, size = 'medium', value = '', name, 'aria-label': ariaLabel, innerRef, placeholder, id: idProp, minRows: minRowsProp = MIN_ROWS, maxRows: maxRowsProp = MAX_ROWS, ...otherProps }) {
17
+ function Textarea({ invalid: invalidProp, onChange, size = 'medium', value = '', name, 'aria-label': ariaLabel, innerRef, placeholder, id: idProp, minRows: minRowsProp = MIN_ROWS, maxRows: maxRowsProp = MAX_ROWS, errorMessage, ...otherProps }) {
18
18
  const id = useId(idProp);
19
19
  const invalid = !otherProps.readOnly && !otherProps.disabled && invalidProp;
20
20
  // ensure minRows and maxRows are within bounds
@@ -23,7 +23,7 @@ function Textarea({ invalid: invalidProp, onChange, size = 'medium', value = '',
23
23
  return (_jsxs("div", { "data-bspk": "textarea", "data-size": size, style: {
24
24
  '--min-rows': minRows,
25
25
  '--max-rows': maxRows,
26
- }, children: [_jsx("textarea", { ...otherProps, "aria-invalid": invalid || undefined, "aria-label": ariaLabel, id: id, name: name, onBlur: (event) => {
26
+ }, children: [_jsx("textarea", { ...otherProps, "aria-errormessage": errorMessage || undefined, "aria-invalid": invalid || undefined, "aria-label": ariaLabel, id: id, name: name, onBlur: (event) => {
27
27
  const target = event.target;
28
28
  target.scrollTop = 0;
29
29
  }, onChange: (event) => onChange(event.target.value, event), onInput: (event) => {
@@ -1 +1 @@
1
- {"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../src/Textarea.tsx"],"names":[],"mappings":";AAAA,OAAO,iBAAiB,CAAC;AAGzB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAoDtC,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,QAAQ,GAAG,EAAE,CAAC;AAEpB;;;;;;GAMG;AACH,SAAS,QAAQ,CAAC,EACd,OAAO,EAAE,WAAW,EACpB,QAAQ,EACR,IAAI,GAAG,QAAQ,EACf,KAAK,GAAG,EAAE,EACV,IAAI,EACJ,YAAY,EAAE,SAAS,EACvB,QAAQ,EACR,WAAW,EACX,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,WAAW,GAAG,QAAQ,EAC/B,OAAO,EAAE,WAAW,GAAG,QAAQ,EAC/B,GAAG,UAAU,EACD;IACZ,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,QAAQ,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,WAAW,CAAC;IAC5E,+CAA+C;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEpE,OAAO,CACH,4BACc,UAAU,eACT,IAAI,EACf,KAAK,EACD;YACI,YAAY,EAAE,OAAO;YACrB,Y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B,MAAM,CAAC,WAA2B,CAAC,SAAS,GAAG,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;gBACxE,CAAC,EACD,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK,GACd,EACF,mEAAyC,IACvC,CACT,CAAC;AACN,CAAC;AAED,QAAQ,CAAC,QAAQ,GAAG,UAAU,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1 +1 @@
1
- [data-bspk=form-field]{box-sizing:border-box;width:100%;display:flex;flex-direction:column;gap:var(--spacing-sizing-01)}[data-bspk=form-field] header label{flex-grow:1}
1
+ [data-bspk=form-field]{box-sizing:border-box;max-width:100%;width:fit-content;display:flex;flex-direction:column;gap:var(--spacing-sizing-01)}[data-bspk=form-field] header label{flex-grow:1}
@@ -1,9 +1,9 @@
1
1
  import { AriaAttributes } from 'react';
2
- import { CommonProps } from '..';
2
+ import { CommonProps, InvalidPropsLibrary } from '..';
3
3
  import { Placement } from './useFloating';
4
4
  export type UseFloatingMenuProps = {
5
5
  placement: Placement;
6
- triggerProps?: CommonProps<'disabled' | 'invalid' | 'readOnly'>;
6
+ triggerProps?: CommonProps<'disabled' | 'readOnly'> & InvalidPropsLibrary;
7
7
  };
8
8
  export type UseFloatingMenuReturn = {
9
9
  menuProps: {
@@ -23,6 +23,7 @@ export type UseFloatingMenuReturn = {
23
23
  'aria-invalid': boolean | undefined;
24
24
  'aria-owns': string;
25
25
  'aria-readonly': boolean | undefined;
26
+ 'aria-errormessage': string | undefined;
26
27
  role: 'combobox';
27
28
  tabIndex: number;
28
29
  ref: (node: HTMLElement | null) => void;
@@ -35,6 +35,7 @@ export function useFloatingMenu({ placement, triggerProps }) {
35
35
  tabIndex: -1,
36
36
  },
37
37
  triggerProps: {
38
+ 'aria-errormessage': triggerProps?.errorMessage || undefined,
38
39
  'aria-activedescendant': selectedId || undefined,
39
40
  'aria-controls': menuId,
40
41
  'aria-expanded': show,
@@ -1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sD"}
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export type CallToActionButton = {
24
24
  /** The size of the call to action button. */
25
25
  size?: ButtonSize;
26
26
  };
27
- export type ToggleControlProps<T extends HTMLElement> = CommonProps<'aria-label' | 'disabled' | 'invalid' | 'name', T> & Required<CommonProps<'value'>> & {
27
+ export type ToggleControlProps<T extends HTMLElement> = CommonProps<'aria-label' | 'disabled' | 'name', T> & InvalidPropsLibrary & Required<CommonProps<'value'>> & {
28
28
  /**
29
29
  * Marks the control as checked.
30
30
  *
@@ -40,6 +40,27 @@ export type ToggleControlProps<T extends HTMLElement> = CommonProps<'aria-label'
40
40
  onChange: (checked: boolean, event: ChangeEvent<T>) => void;
41
41
  };
42
42
  export type CommonProps<K extends keyof CommonPropsLibrary, T extends HTMLElement = HTMLElement> = Pick<CommonPropsLibrary<T>, K>;
43
+ /**
44
+ * The props that are common to input elements.
45
+ *
46
+ * If an element is invalid it must have an errorMessage.
47
+ */
48
+ export type InvalidPropsLibrary = {
49
+ /**
50
+ * Marks the element as invalid and displays error state theme.
51
+ *
52
+ * If the errorMessage is empty the error state theme will not appear.
53
+ *
54
+ * @default false
55
+ */
56
+ invalid?: boolean;
57
+ /**
58
+ * Marks the element as invalid and displays error message.
59
+ *
60
+ * When an element is invalid it must display an error message explaining why it is invalid.
61
+ */
62
+ errorMessage?: string;
63
+ };
43
64
  export type CommonPropsLibrary<T extends HTMLElement = HTMLElement> = {
44
65
  /** The id of the element. If not provided one will be generated. */
45
66
  id?: string;
@@ -73,12 +94,6 @@ export type CommonPropsLibrary<T extends HTMLElement = HTMLElement> = {
73
94
  * @default false
74
95
  */
75
96
  disabled?: boolean;
76
- /**
77
- * Marks the element as invalid and displays error state theme.
78
- *
79
- * @default false
80
- */
81
- invalid?: boolean;
82
97
  /**
83
98
  * Determines if the element is [readonly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly).
84
99
  *
@@ -91,12 +106,6 @@ export type CommonPropsLibrary<T extends HTMLElement = HTMLElement> = {
91
106
  * @required
92
107
  */
93
108
  name: string;
94
- /**
95
- * Marks the element as invalid and displays error message.
96
- *
97
- * When an element is invalid it must display an error message explaining why it is invalid.
98
- */
99
- errorMessage?: string;
100
109
  /**
101
110
  * The value of the control.
102
111
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+IH,MAAM,CAAC,MAAM,MAAM,GAAqC;IACpD,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;IACvC,EAAE,KAAK,EAAE,wBAAwB,EAAE,IAAI,EAAE,sBAAsB,EAAE;IACjE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACnC,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE;IAC3C,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACrD,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;IACvC,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE;IAC7C,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IAC7B,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE;CAClC,CAAC;AAEX,sDAAsD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0JH,MAAM,CAAC,MAAM,MAAM,GAAqC;IACpD,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;IACvC,EAAE,KAAK,EAAE,wBAAwB,EAAE,IAAI,EAAE,sBAAsB,EAAE;IACjE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACnC,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE;IAC3C,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACrD,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;IACvC,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE;IAC7C,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IAC7B,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE;CAClC,CAAC;AAEX,sDAAsD"}
@@ -1 +1 @@
1
- [data-bspk=inline-alert]{display:flex;align-items:start;justify-content:center;flex-direction:row;gap:var(--spacing-sizing-02)}[data-bspk=inline-alert] [data-txt]{flex:1}[data-bspk=inline-alert][data-variant=error]{color:var(--status-error);--first-tone: var(--status-error);--second-tone: var(--status-on-information)}[data-bspk=inline-alert][data-variant=success]{color:var(--status-success);--first-tone: var(--status-success);--second-tone: var(--status-on-success)}[data-bspk=inline-alert][data-variant=warning]{color:var(--foreground-neutral-on-surface);--first-tone: var(--status-warning);--second-tone: var(--status-on-warning)}[data-bspk=inline-alert][data-variant=informational]{color:var(--status-information);--first-tone: var(--status-information);--second-tone: var(--status-on-information)}[data-bspk=inline-alert] svg{color:var(--first-tone);width:var(--spacing-sizing-05);height:var(--spacing-sizing-05)}[data-bspk=inline-alert] svg [data-second-tone]{fill:var(--second-tone)}
1
+ [data-bspk=inline-alert]{display:flex;align-items:start;justify-content:start;flex-direction:row;gap:var(--spacing-sizing-02)}[data-bspk=inline-alert] [data-txt]{flex:1}[data-bspk=inline-alert][data-variant=error]{color:var(--status-error);--first-tone: var(--status-error);--second-tone: var(--status-on-information)}[data-bspk=inline-alert][data-variant=success]{color:var(--status-success);--first-tone: var(--status-success);--second-tone: var(--status-on-success)}[data-bspk=inline-alert][data-variant=warning]{color:var(--foreground-neutral-on-surface);--first-tone: var(--status-warning);--second-tone: var(--status-on-warning)}[data-bspk=inline-alert][data-variant=informational]{color:var(--status-information);--first-tone: var(--status-information);--second-tone: var(--status-on-information)}[data-bspk=inline-alert] svg{color:var(--first-tone);width:var(--spacing-sizing-05);height:var(--spacing-sizing-05)}[data-bspk=inline-alert] svg [data-second-tone]{fill:var(--second-tone)}
@@ -1 +1 @@
1
- [data-bspk=number-input]{--font: var(--body-base);--height: var(--spacing-sizing-10);--svg-width: var(--spacing-sizing-05);--color: var(--foreground-neutral-on-surface);width:100%;display:flex;flex-flow:row nowrap;font:var(--font);height:var(--height);border:1px solid var(--stroke-neutral-base);border-radius:var(--radius-small);background:var(--surface-neutral-t1-base)}[data-bspk=number-input]:focus-within{border-color:var(--stroke-brand-primary);outline:1px solid var(--stroke-brand-primary)}[data-bspk=number-input] [data-divider]{width:4px;border-right:1px solid var(--stroke-neutral-base);height:calc(var(--height) - 8px);margin:3px 0}[data-bspk=number-input] button{min-width:var(--height);background:none;border:none;cursor:pointer;font:var(--font);display:flex;justify-content:center;align-items:center;color:var(--color)}[data-bspk=number-input] button svg{width:var(--svg-width)}[data-bspk=number-input] button:disabled{cursor:not-allowed;color:var(--foreground-neutral-disabled-on-surface)}[data-bspk=number-input] input{color:var(--color);min-width:0;display:block;font:var(--font);text-align:center;padding:0 var(--spacing-sizing-03);background:rgba(0,0,0,0);border:none}[data-bspk=number-input] input:focus{outline:none}[data-bspk=number-input] input::-webkit-outer-spin-button,[data-bspk=number-input] input::-webkit-inner-spin-button{appearance:none;margin:0}[data-bspk=number-input] input[type=number]{appearance:textfield}[data-bspk=number-input]:not([data-disabled],[data-readonly]) input:hover,[data-bspk=number-input]:not([data-disabled],[data-readonly]) button:not(:disabled):hover{background-color:var(--interactions-hover-opacity)}[data-bspk=number-input]:not([data-disabled],[data-readonly]) input:active,[data-bspk=number-input]:not([data-disabled],[data-readonly]) button:not(:disabled):active{background-color:var(--interactions-press-opacity)}[data-bspk=number-input]:not([data-disabled],[data-readonly])[data-invalid]{border-color:var(--status-error);outline-color:var(--status-error)}[data-bspk=number-input][data-disabled],[data-bspk=number-input][data-readonly]{--color: var(--foreground-neutral-disabled-on-surface);border-color:var(--stroke-neutral-disabled-light);background:linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=number-input][data-disabled] [data-divider],[data-bspk=number-input][data-readonly] [data-divider]{border-color:var(--stroke-neutral-disabled-light)}[data-bspk=number-input][data-readonly] input{color:var(--foreground-neutral-on-surface) !important}[data-bspk=number-input][data-size=small]{--font: var(--body-small);--height: var(--spacing-sizing-08)}[data-bspk=number-input][data-size=large]{--font: var(--body-large);--height: var(--spacing-sizing-12);--svg-width: var(--spacing-sizing-06)}
1
+ [data-bspk=number-input]{--font: var(--body-base);--height: var(--spacing-sizing-10);--svg-width: var(--spacing-sizing-05);--color: var(--foreground-neutral-on-surface);width:100%;display:flex;flex-flow:row nowrap;font:var(--font);height:var(--height);border:1px solid var(--stroke-neutral-base);border-radius:var(--radius-small);background:var(--surface-neutral-t1-base);max-width:280px}[data-bspk=number-input]:focus-within{border-color:var(--stroke-brand-primary)}[data-bspk=number-input] [data-divider]{width:4px;border-right:1px solid var(--stroke-neutral-base);height:calc(var(--height) - 8px);margin:3px 0}[data-bspk=number-input] button{width:var(--height);height:var(--height);background:none;border:none;cursor:pointer;font:var(--font);flex-shrink:0;display:flex;justify-content:center;align-items:center;color:var(--color)}[data-bspk=number-input] button svg{width:var(--svg-width)}[data-bspk=number-input] button:disabled{cursor:not-allowed;color:var(--foreground-neutral-disabled-on-surface)}[data-bspk=number-input] input{color:var(--color);min-width:0;display:block;font:var(--font);text-align:center;padding:0 var(--spacing-sizing-03);background:rgba(0,0,0,0);border:none;flex-grow:1}[data-bspk=number-input] input:focus{outline:none}[data-bspk=number-input] input::-webkit-outer-spin-button,[data-bspk=number-input] input::-webkit-inner-spin-button{appearance:none;margin:0}[data-bspk=number-input] input[type=number]{appearance:textfield}[data-bspk=number-input]:not([data-disabled],[data-readonly]) input:hover,[data-bspk=number-input]:not([data-disabled],[data-readonly]) button:not(:disabled):hover{background-color:var(--interactions-hover-opacity)}[data-bspk=number-input]:not([data-disabled],[data-readonly]) input:active,[data-bspk=number-input]:not([data-disabled],[data-readonly]) button:not(:disabled):active{background-color:var(--interactions-press-opacity)}[data-bspk=number-input]:not([data-disabled],[data-readonly])[data-invalid]{border-color:var(--status-error);outline-color:var(--status-error)}[data-bspk=number-input][data-disabled],[data-bspk=number-input][data-readonly]{--color: var(--foreground-neutral-disabled-on-surface);border-color:var(--stroke-neutral-disabled-light);background:linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=number-input][data-disabled] [data-divider],[data-bspk=number-input][data-readonly] [data-divider]{border-color:var(--stroke-neutral-disabled-light)}[data-bspk=number-input][data-readonly] input{color:var(--foreground-neutral-on-surface) !important}[data-bspk=number-input][data-size=small]{--font: var(--body-small);--height: var(--spacing-sizing-08)}[data-bspk=number-input][data-size=large]{--font: var(--body-large);--height: var(--spacing-sizing-12);--svg-width: var(--spacing-sizing-06)}
package/meta-types.ts CHANGED
@@ -6,11 +6,11 @@ export type BaseMeta = {
6
6
  name: string;
7
7
  description?: string;
8
8
  file?: string;
9
+ example?: string;
9
10
  };
10
11
 
11
12
  export type TypeMeta = BaseMeta & {
12
13
  id: string;
13
- example?: string;
14
14
  references?: string[];
15
15
  properties?: TypeProperty[];
16
16
  };
@@ -35,12 +35,15 @@ export type ComponentMeta = BaseMeta & {
35
35
  modified: string;
36
36
  css: string;
37
37
  hasTouchTarget: boolean;
38
+ usage?: {
39
+ code: string;
40
+ description?: string;
41
+ };
38
42
  };
39
43
 
40
44
  export type UtilityMeta = BaseMeta & {
41
45
  param?: string;
42
46
  returns?: string;
43
- example?: string;
44
47
  };
45
48
 
46
49
  /** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
package/meta.ts CHANGED
@@ -169,6 +169,13 @@ function generateComponentMeta({
169
169
 
170
170
  const css = fs.existsSync(cssPath) ? fs.readFileSync(cssPath, { encoding: 'utf-8' }) : '';
171
171
 
172
+ const usage = componentDoc.example
173
+ ? {
174
+ code: componentDoc.example,
175
+ description: componentDoc.exampleDescription,
176
+ }
177
+ : undefined;
178
+
172
179
  return {
173
180
  description: componentDoc.description,
174
181
  file: componentFile.split(componentsDir)[1],
@@ -176,6 +183,7 @@ function generateComponentMeta({
176
183
  slug,
177
184
  dependencies,
178
185
  modified: stats.mtime.toISOString(),
186
+ usage,
179
187
  css,
180
188
  hasTouchTarget: css.includes('data-touch-target'),
181
189
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bspk/ui",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "license": "CC-BY-4.0",
5
5
  "type": "module",
6
6
  "files": [
@@ -19,7 +19,7 @@
19
19
  "sass": "sass --style=compressed --no-source-map src:dist",
20
20
  "build": "tsx build.ts",
21
21
  "lint:css": "npx stylelint '**/*.scss'",
22
- "lint": "eslint",
22
+ "lint": "eslint && tsc --noEmit && stylelint '**/*.scss'",
23
23
  "lint:fix": "eslint --fix",
24
24
  "semantic-release": "semantic-release",
25
25
  "test": "jest",
package/src/Checkbox.tsx CHANGED
@@ -27,6 +27,8 @@ function Checkbox({
27
27
  indeterminate: indeterminateProp,
28
28
  invalid,
29
29
  disabled,
30
+ errorMessage,
31
+
30
32
  ...props
31
33
  }: ElementProps<CheckboxProps, 'input'>) {
32
34
  const indeterminate = !!indeterminateProp;
@@ -46,6 +48,7 @@ function Checkbox({
46
48
  >
47
49
  <input
48
50
  {...props}
51
+ aria-errormessage={errorMessage || undefined}
49
52
  aria-invalid={invalid || undefined}
50
53
  checked={checked}
51
54
  disabled={disabled || undefined}
@@ -1,10 +1,10 @@
1
1
  import { CheckboxProps, Checkbox } from './Checkbox';
2
2
  import { ToggleOptionProps, ToggleOption } from './ToggleOption';
3
3
 
4
- export type CheckboxOptionProps = Pick<
5
- CheckboxProps,
6
- 'checked' | 'disabled' | 'indeterminate' | 'invalid' | 'name' | 'onChange' | 'value'
7
- > &
4
+ import { InvalidPropsLibrary } from '.';
5
+
6
+ export type CheckboxOptionProps = InvalidPropsLibrary &
7
+ Pick<CheckboxProps, 'checked' | 'disabled' | 'indeterminate' | 'name' | 'onChange' | 'value'> &
8
8
  Pick<ToggleOptionProps, 'description' | 'label'>;
9
9
 
10
10
  /**
package/src/Dropdown.tsx CHANGED
@@ -8,7 +8,7 @@ import { Placement } from './hooks/useFloating';
8
8
  import { useFloatingMenu } from './hooks/useFloatingMenu';
9
9
  import { useId } from './hooks/useId';
10
10
 
11
- import { CommonProps } from './';
11
+ import { CommonProps, InvalidPropsLibrary } from './';
12
12
 
13
13
  export type DropdownOption = {
14
14
  /** The value of the option. */
@@ -18,8 +18,9 @@ export type DropdownOption = {
18
18
  };
19
19
 
20
20
  export type DropdownProps<O extends DropdownOption = DropdownOption> = CommonProps<
21
- 'aria-label' | 'disabled' | 'id' | 'invalid' | 'name' | 'readOnly' | 'size'
21
+ 'aria-label' | 'disabled' | 'id' | 'name' | 'readOnly' | 'size'
22
22
  > &
23
+ InvalidPropsLibrary &
23
24
  Pick<MenuProps<O>, 'isMulti' | 'itemCount' | 'onChange' | 'renderListItem'> & {
24
25
  /**
25
26
  * Array of options to display in the dropdown
@@ -66,6 +67,7 @@ function Dropdown<O extends DropdownOption = DropdownOption>({
66
67
  disabled,
67
68
  id: propId,
68
69
  invalid,
70
+ errorMessage,
69
71
  readOnly,
70
72
  placement = 'bottom',
71
73
  name,
@@ -81,6 +83,7 @@ function Dropdown<O extends DropdownOption = DropdownOption>({
81
83
  disabled,
82
84
  invalid,
83
85
  readOnly,
86
+ errorMessage,
84
87
  },
85
88
  });
86
89
 
package/src/FormField.tsx CHANGED
@@ -3,7 +3,7 @@ import { InlineAlert } from './InlineAlert';
3
3
  import { Layout } from './Layout';
4
4
  import { Txt } from './Txt';
5
5
 
6
- import { CommonProps } from './';
6
+ import { CommonProps, InvalidPropsLibrary } from './';
7
7
 
8
8
  export type FieldControlProps = {
9
9
  /**
@@ -18,27 +18,29 @@ export type FieldControlProps = {
18
18
  'aria-errormessage'?: string;
19
19
  };
20
20
 
21
- export type FormFieldProps = CommonProps<'errorMessage' | 'required'> & {
22
- /**
23
- * The label of the field.
24
- *
25
- * @required
26
- */
27
- label: string;
28
- /** The id of the control. */
29
- controlId: string;
30
- /**
31
- * The children of the form field. This should be a control such as TextInput, Dropdown, DatePicker, or TimePicker.
32
- *
33
- * @type (childProps: FieldControlProps) => JSX.Element
34
- * @required
35
- */
36
- children: (childProps: FieldControlProps) => JSX.Element;
37
- /** The helperText of the field. */
38
- helperText?: string;
39
- /** The trailing element of the label. */
40
- labelTrailing?: React.ReactNode;
41
- };
21
+ export type FormFieldProps = CommonProps<'required'> &
22
+ InvalidPropsLibrary & {
23
+ /**
24
+ * The label of the field.
25
+ *
26
+ * @required
27
+ */
28
+ label: string;
29
+ /** The id of the control. */
30
+ controlId: string;
31
+ /**
32
+ * The children of the form field. This should be a control such as TextInput, Dropdown, DatePicker, or
33
+ * TimePicker.
34
+ *
35
+ * @type (childProps: FieldControlProps) => JSX.Element
36
+ * @required
37
+ */
38
+ children: (childProps: FieldControlProps) => JSX.Element;
39
+ /** The helperText of the field. */
40
+ helperText?: string;
41
+ /** The trailing element of the label. */
42
+ labelTrailing?: React.ReactNode;
43
+ };
42
44
 
43
45
  /**
44
46
  * Wrapper component for form controls.
@@ -47,14 +49,23 @@ export type FormFieldProps = CommonProps<'errorMessage' | 'required'> & {
47
49
  *
48
50
  * @name FormField
49
51
  */
50
- function FormField({ label, errorMessage, helperText, children, labelTrailing, controlId, required }: FormFieldProps) {
52
+ function FormField({
53
+ label,
54
+ invalid,
55
+ errorMessage,
56
+ helperText,
57
+ children,
58
+ labelTrailing,
59
+ controlId,
60
+ required,
61
+ }: FormFieldProps) {
51
62
  const errorMessageId = errorMessage && `${controlId}-error-message`;
52
63
  const helperTextId = helperText && `${controlId}-helper-text`;
53
64
 
54
65
  if (typeof children !== 'function') return null;
55
66
 
56
67
  return (
57
- <div data-bspk="form-field">
68
+ <div data-bspk="form-field" data-invalid={invalid || undefined}>
58
69
  <Layout as="header">
59
70
  <label htmlFor={controlId}>
60
71
  <Txt as="span" variant="labels-small">
package/src/ListItem.tsx CHANGED
@@ -81,6 +81,7 @@ function ListItem<As extends ElementType = 'div'>({
81
81
  subText,
82
82
  active,
83
83
  readOnly,
84
+ errorMessage,
84
85
  ...props
85
86
  }: ElementProps<ListItemProps<As>, As>) {
86
87
  let As: ElementType = as || 'div';
@@ -120,6 +121,7 @@ function ListItem<As extends ElementType = 'div'>({
120
121
  <As
121
122
  {...props}
122
123
  aria-disabled={disabled || undefined}
124
+ aria-errormessage={errorMessage || undefined}
123
125
  aria-invalid={invalid || undefined}
124
126
  data-action={actionable || undefined}
125
127
  data-active={active || undefined}
@@ -1,11 +1,11 @@
1
1
  import { FormFieldProps, FormField } from './FormField';
2
2
  import { NumberInputProps, NumberInput } from './NumberInput';
3
3
 
4
- export type NumberFieldProps = Pick<
5
- NumberInputProps,
6
- 'centered' | 'disabled' | 'id' | 'invalid' | 'name' | 'onChange' | 'readOnly' | 'size' | 'value'
7
- > &
8
- Pick<FormFieldProps, 'controlId' | 'errorMessage' | 'helperText' | 'label' | 'labelTrailing' | 'required'>;
4
+ import { InvalidPropsLibrary } from '.';
5
+
6
+ export type NumberFieldProps = InvalidPropsLibrary &
7
+ Pick<FormFieldProps, 'controlId' | 'errorMessage' | 'helperText' | 'label' | 'labelTrailing' | 'required'> &
8
+ Pick<NumberInputProps, 'align' | 'disabled' | 'id' | 'name' | 'onChange' | 'readOnly' | 'size' | 'value'>;
9
9
 
10
10
  /**
11
11
  * A input element that allows users to either input a numerical value or singularly increase or decrease the values by
@@ -5,7 +5,7 @@ import './number-input.scss';
5
5
  import { useId } from './hooks/useId';
6
6
  import { useLongPress } from './hooks/useLongPress';
7
7
 
8
- import { CommonProps } from '.';
8
+ import { CommonProps, InvalidPropsLibrary } from '.';
9
9
 
10
10
  function isNumber(value: unknown): number | undefined {
11
11
  if (typeof value === 'number') return value;
@@ -14,40 +14,53 @@ function isNumber(value: unknown): number | undefined {
14
14
  return isNaN(num) ? undefined : num;
15
15
  }
16
16
 
17
- export type NumberInputProps = CommonProps<
18
- 'aria-label' | 'disabled' | 'id' | 'invalid' | 'name' | 'readOnly' | 'size'
19
- > & {
20
- /**
21
- * The value of the control.
22
- *
23
- * @required
24
- */
25
- value?: number;
26
- /** Callback when the value changes. */
27
- onChange: (value: number) => void;
28
- /**
29
- * If the value should be centered between the up & down buttons.
30
- *
31
- * @default false
32
- */
33
- centered?: boolean;
34
- /** Defines the [maximum](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max) value that is accepted. */
35
- max?: number;
36
- /** Defines the [minimum](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/min) value that is accepted. */
37
- min?: number;
38
- };
17
+ export type NumberInputProps = CommonProps<'aria-label' | 'disabled' | 'id' | 'name' | 'readOnly' | 'size'> &
18
+ InvalidPropsLibrary & {
19
+ /**
20
+ * The value of the control.
21
+ *
22
+ * @required
23
+ */
24
+ value?: number;
25
+ /** Callback when the value changes. */
26
+ onChange: (value: number) => void;
27
+ /**
28
+ * The alignment of the input box. Centered between the plus and minus buttons or to the left of the buttons.
29
+ *
30
+ * @default center
31
+ */
32
+ align?: 'center' | 'left';
33
+ /**
34
+ * Defines the [maximum](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max) value that is
35
+ * accepted.
36
+ *
37
+ * @default 99
38
+ * @maximum 99
39
+ * @minimum 1
40
+ */
41
+ max?: number;
42
+ /**
43
+ * Defines the [minimum](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/min) value that is
44
+ * accepted.
45
+ *
46
+ * @minimum 0
47
+ */
48
+ min?: number;
49
+ };
39
50
 
40
51
  /**
41
52
  * A input element that allows users to either input a numerical value or singularly increase or decrease the values by
42
53
  * pressing the (+) or (-).
43
54
  *
55
+ * The value of the input is a number. The value is clamped to the min and max values if they are provided.
56
+ *
44
57
  * @name NumberInput
45
58
  */
46
59
  function NumberInput({
47
60
  //
48
61
  value = 1,
49
62
  onChange,
50
- centered = false,
63
+ align = 'center',
51
64
  size = 'medium',
52
65
  disabled = false,
53
66
  readOnly = false,
@@ -58,6 +71,7 @@ function NumberInput({
58
71
  max: maxProp,
59
72
  min: minProp,
60
73
  }: NumberInputProps) {
74
+ const centered = align !== 'left';
61
75
  const inputId = useId(inputIdProp);
62
76
  const max = isNumber(maxProp);
63
77
  const min = isNumber(minProp);
package/src/Radio.tsx CHANGED
@@ -1,10 +1,8 @@
1
1
  import './radio.scss';
2
- import { ToggleControlProps, ElementProps } from './';
2
+ import { ToggleControlProps, ElementProps, InvalidPropsLibrary } from './';
3
3
 
4
- export type RadioProps = Pick<
5
- ToggleControlProps<HTMLInputElement>,
6
- 'aria-label' | 'checked' | 'disabled' | 'invalid' | 'name' | 'onChange' | 'value'
7
- >;
4
+ export type RadioProps = InvalidPropsLibrary &
5
+ Pick<ToggleControlProps<HTMLInputElement>, 'aria-label' | 'checked' | 'disabled' | 'name' | 'onChange' | 'value'>;
8
6
 
9
7
  /**
10
8
  * A round control that allows user to choose one option from a set. This is the base element and if used directly you
@@ -1,7 +1,10 @@
1
1
  import { RadioProps, Radio } from './Radio';
2
2
  import { ToggleOptionProps, ToggleOption } from './ToggleOption';
3
3
 
4
- export type RadioOptionProps = Pick<RadioProps, 'checked' | 'disabled' | 'invalid' | 'name' | 'onChange' | 'value'> &
4
+ import { InvalidPropsLibrary } from '.';
5
+
6
+ export type RadioOptionProps = InvalidPropsLibrary &
7
+ Pick<RadioProps, 'checked' | 'disabled' | 'name' | 'onChange' | 'value'> &
5
8
  Pick<ToggleOptionProps, 'description' | 'label'>;
6
9
 
7
10
  /**
package/src/Skeleton.tsx CHANGED
@@ -5,13 +5,13 @@ import { TxtVariant } from './utils/txtVariants';
5
5
 
6
6
  export type SkeletonProps = {
7
7
  /**
8
- * The text variant of the skeleton.
8
+ * The variant of the skeleton that best hints the content being loaded.
9
9
  *
10
10
  * @default text
11
11
  */
12
12
  variant?: 'circular' | 'photo' | 'profile' | 'rectangular' | 'text' | 'thumbnail';
13
13
  /**
14
- * The size of the text. This is only used when variant is 'text'.
14
+ * The variant of the text being loaded. This is only used when variant is 'text'.
15
15
  *
16
16
  * @default body-base
17
17
  */
@@ -39,6 +39,28 @@ export type SkeletonProps = {
39
39
  /**
40
40
  * A visual placeholder for an element while it is in a loading state.
41
41
  *
42
+ * The data for your components might not be immediately available. You can improve the perceived responsiveness of the
43
+ * page by using skeletons. It feels like things are happening immediately, then the information is incrementally
44
+ * displayed on the screen.
45
+ *
46
+ * @example
47
+ * function Example() {
48
+ * return item ? (
49
+ * <img
50
+ * style={{
51
+ * width: 210,
52
+ * height: 118,
53
+ * }}
54
+ * alt={item.title}
55
+ * src={item.src}
56
+ * />
57
+ * ) : (
58
+ * <Skeleton variant="photo" width={210} height={118} />
59
+ * );
60
+ * }
61
+ *
62
+ * @exampleDescription This example shows a skeleton loading state for an image but can be used for any element.
63
+ *
42
64
  * @name Skeleton
43
65
  */
44
66
  function Skeleton({
package/src/TextField.tsx CHANGED
@@ -1,23 +1,25 @@
1
1
  import { FormFieldProps, FormField } from './FormField';
2
2
  import { TextInputProps, TextInput } from './TextInput';
3
3
 
4
- export type TextFieldProps = Pick<
5
- TextInputProps,
6
- | 'autoComplete'
7
- | 'disabled'
8
- | 'inputRef'
9
- | 'invalid'
10
- | 'leading'
11
- | 'name'
12
- | 'onChange'
13
- | 'placeholder'
14
- | 'readOnly'
15
- | 'required'
16
- | 'size'
17
- | 'trailing'
18
- | 'type'
19
- | 'value'
20
- > &
4
+ import { InvalidPropsLibrary } from '.';
5
+
6
+ export type TextFieldProps = InvalidPropsLibrary &
7
+ Pick<
8
+ TextInputProps,
9
+ | 'autoComplete'
10
+ | 'disabled'
11
+ | 'inputRef'
12
+ | 'leading'
13
+ | 'name'
14
+ | 'onChange'
15
+ | 'placeholder'
16
+ | 'readOnly'
17
+ | 'required'
18
+ | 'size'
19
+ | 'trailing'
20
+ | 'type'
21
+ | 'value'
22
+ > &
21
23
  Pick<FormFieldProps, 'controlId' | 'errorMessage' | 'helperText' | 'label' | 'labelTrailing'>;
22
24
 
23
25
  /**