@tai42/studio-sdk 21.0.0 → 22.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/components/chip-group.d.ts +42 -0
  2. package/dist/components/chip-group.d.ts.map +1 -0
  3. package/dist/components/chip-group.js +85 -0
  4. package/dist/components/chip-group.js.map +1 -0
  5. package/dist/components/components.css +9 -3
  6. package/dist/hooks/useApi.d.ts +268 -46
  7. package/dist/hooks/useApi.d.ts.map +1 -1
  8. package/dist/index.d.ts +4 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +2 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/schema-form/SchemaForm.d.ts +11 -1
  13. package/dist/schema-form/SchemaForm.d.ts.map +1 -1
  14. package/dist/schema-form/SchemaForm.js +2 -2
  15. package/dist/schema-form/SchemaForm.js.map +1 -1
  16. package/dist/schema-form/classify.d.ts.map +1 -1
  17. package/dist/schema-form/classify.js +54 -2
  18. package/dist/schema-form/classify.js.map +1 -1
  19. package/dist/schema-form/date-range-field.d.ts +44 -0
  20. package/dist/schema-form/date-range-field.d.ts.map +1 -0
  21. package/dist/schema-form/date-range-field.js +72 -0
  22. package/dist/schema-form/date-range-field.js.map +1 -0
  23. package/dist/schema-form/enum-field.d.ts +3 -1
  24. package/dist/schema-form/enum-field.d.ts.map +1 -1
  25. package/dist/schema-form/enum-field.js +8 -2
  26. package/dist/schema-form/enum-field.js.map +1 -1
  27. package/dist/schema-form/field-model.d.ts +20 -1
  28. package/dist/schema-form/field-model.d.ts.map +1 -1
  29. package/dist/schema-form/field-node.d.ts +10 -0
  30. package/dist/schema-form/field-node.d.ts.map +1 -1
  31. package/dist/schema-form/field-node.js +6 -3
  32. package/dist/schema-form/field-node.js.map +1 -1
  33. package/dist/schema-form/index.d.ts +3 -1
  34. package/dist/schema-form/index.d.ts.map +1 -1
  35. package/dist/schema-form/index.js +1 -0
  36. package/dist/schema-form/index.js.map +1 -1
  37. package/dist/schema-form/multiselect-field.d.ts.map +1 -1
  38. package/dist/schema-form/multiselect-field.js +11 -0
  39. package/dist/schema-form/multiselect-field.js.map +1 -1
  40. package/dist/schema-form/object-fields.d.ts +9 -1
  41. package/dist/schema-form/object-fields.d.ts.map +1 -1
  42. package/dist/schema-form/object-fields.js +16 -3
  43. package/dist/schema-form/object-fields.js.map +1 -1
  44. package/dist/schema-form/string-field.d.ts +6 -1
  45. package/dist/schema-form/string-field.d.ts.map +1 -1
  46. package/dist/schema-form/string-field.js +42 -8
  47. package/dist/schema-form/string-field.js.map +1 -1
  48. package/dist/schema-form/types.d.ts +36 -0
  49. package/dist/schema-form/types.d.ts.map +1 -1
  50. package/package.json +10 -10
  51. package/src/components/chip-group.tsx +157 -0
  52. package/src/components/components.css +9 -3
  53. package/src/index.ts +6 -0
  54. package/src/schema-form/SchemaForm.tsx +10 -0
  55. package/src/schema-form/classify.ts +59 -3
  56. package/src/schema-form/date-range-field.tsx +167 -0
  57. package/src/schema-form/enum-field.tsx +20 -0
  58. package/src/schema-form/field-model.ts +24 -2
  59. package/src/schema-form/field-node.tsx +19 -0
  60. package/src/schema-form/index.ts +10 -1
  61. package/src/schema-form/multiselect-field.tsx +21 -0
  62. package/src/schema-form/object-fields.tsx +36 -2
  63. package/src/schema-form/string-field.tsx +72 -1
  64. package/src/schema-form/types.ts +38 -0
@@ -0,0 +1,42 @@
1
+ /**
2
+ * `ChipGroup` — a tap-to-select grid of pill chips (`.tai-chip`), in two modes.
3
+ *
4
+ * `single` is a `role="radiogroup"` of `role="radio"` chips carrying `aria-checked`:
5
+ * exactly one value is selected, the arrow keys move the selection, and only the
6
+ * selected chip (or the first, when none is) sits in the tab order. `multi` is a
7
+ * group of toggle buttons carrying `aria-pressed`: any number are selected, the
8
+ * arrow keys move focus, and Space/Enter (the native button activation) toggles the
9
+ * focused chip.
10
+ *
11
+ * Roving tabindex and arrow-key movement are owned here — there is no multi-select
12
+ * primitive to borrow — so both modes share one keyboard model: ←/↑ to the previous
13
+ * chip, →/↓ to the next (wrapping), Home/End to the ends, skipping disabled chips.
14
+ * The handler rides each chip (a button, an interactive element) rather than the
15
+ * container, so no static element carries an interaction. Like `RadioGroup`, the
16
+ * group takes its accessible name from an enclosing group `Field`, not a label of
17
+ * its own.
18
+ */
19
+ import type { ReactNode } from 'react';
20
+ /** One selectable chip: its answer `value` and the visible `label`. */
21
+ export interface ChipOption {
22
+ readonly value: string;
23
+ readonly label: string;
24
+ readonly disabled?: boolean;
25
+ }
26
+ export type ChipGroupProps = {
27
+ /** Exactly one value selected — a `radiogroup` of radios. */
28
+ readonly mode: 'single';
29
+ readonly options: readonly ChipOption[];
30
+ readonly value: string;
31
+ readonly onValueChange: (value: string) => void;
32
+ readonly disabled?: boolean;
33
+ } | {
34
+ /** Any number selected — a group of `aria-pressed` toggle buttons. */
35
+ readonly mode: 'multi';
36
+ readonly options: readonly ChipOption[];
37
+ readonly value: readonly string[];
38
+ readonly onValueChange: (value: readonly string[]) => void;
39
+ readonly disabled?: boolean;
40
+ };
41
+ export declare function ChipGroup(props: ChipGroupProps): ReactNode;
42
+ //# sourceMappingURL=chip-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chip-group.d.ts","sourceRoot":"","sources":["../../src/components/chip-group.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAKtD,uEAAuE;AACvE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,cAAc,GACtB;IACE,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,GACD;IACE,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;IAC3D,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEN,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CA4G1D"}
@@ -0,0 +1,85 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef, useState } from 'react';
3
+ import { useFieldControl } from './field';
4
+ export function ChipGroup(props) {
5
+ const { options, disabled = false } = props;
6
+ const field = useFieldControl();
7
+ const chipRefs = useRef([]);
8
+ const isSelected = (option) => props.mode === 'single' ? props.value === option.value : props.value.includes(option.value);
9
+ // The chip in the tab order: the (first) selected one, else the first enabled
10
+ // one — so Tab lands on the active choice and the arrows rove from there.
11
+ const [rovingIndex, setRovingIndex] = useState(() => {
12
+ const selected = options.findIndex(isSelected);
13
+ if (selected >= 0)
14
+ return selected;
15
+ const firstEnabled = options.findIndex((option) => option.disabled !== true);
16
+ return firstEnabled >= 0 ? firstEnabled : 0;
17
+ });
18
+ const enabledIndices = options
19
+ .map((option, index) => (option.disabled === true ? -1 : index))
20
+ .filter((index) => index >= 0);
21
+ const focusChip = (index) => {
22
+ setRovingIndex(index);
23
+ chipRefs.current[index]?.focus();
24
+ };
25
+ const select = (option) => {
26
+ if (props.mode === 'single') {
27
+ props.onValueChange(option.value);
28
+ return;
29
+ }
30
+ const chosen = new Set(props.value);
31
+ if (chosen.has(option.value))
32
+ chosen.delete(option.value);
33
+ else
34
+ chosen.add(option.value);
35
+ // Keep the OPTIONS' declared order, so the emitted array reads the way the form
36
+ // lists the choices rather than the order the chips were pressed.
37
+ props.onValueChange(options.map((candidate) => candidate.value).filter((v) => chosen.has(v)));
38
+ };
39
+ const onChipKeyDown = (event) => {
40
+ if (disabled || enabledIndices.length === 0)
41
+ return;
42
+ const position = enabledIndices.indexOf(rovingIndex);
43
+ let nextPosition;
44
+ switch (event.key) {
45
+ case 'ArrowRight':
46
+ case 'ArrowDown':
47
+ nextPosition = (position + 1) % enabledIndices.length;
48
+ break;
49
+ case 'ArrowLeft':
50
+ case 'ArrowUp':
51
+ nextPosition = (position - 1 + enabledIndices.length) % enabledIndices.length;
52
+ break;
53
+ case 'Home':
54
+ nextPosition = 0;
55
+ break;
56
+ case 'End':
57
+ nextPosition = enabledIndices.length - 1;
58
+ break;
59
+ default:
60
+ return;
61
+ }
62
+ event.preventDefault();
63
+ const nextIndex = enabledIndices[nextPosition];
64
+ if (nextIndex === undefined)
65
+ return;
66
+ const nextOption = options[nextIndex];
67
+ if (nextOption === undefined)
68
+ return;
69
+ focusChip(nextIndex);
70
+ // A radiogroup selects as it moves; a multi-select group only moves focus and
71
+ // leaves Space/Enter to toggle.
72
+ if (props.mode === 'single')
73
+ props.onValueChange(nextOption.value);
74
+ };
75
+ return (_jsx("div", { role: props.mode === 'single' ? 'radiogroup' : 'group', className: "tai-row", "aria-describedby": field['aria-describedby'], children: options.map((option, index) => {
76
+ const selected = isSelected(option);
77
+ return (_jsx("button", { ref: (element) => {
78
+ chipRefs.current[index] = element;
79
+ }, type: "button", className: "tai-chip", role: props.mode === 'single' ? 'radio' : undefined, "aria-checked": props.mode === 'single' ? selected : undefined, "aria-pressed": props.mode === 'multi' ? selected : undefined, "aria-invalid": field['aria-invalid'], tabIndex: index === rovingIndex ? 0 : -1, disabled: disabled || option.disabled === true, onClick: () => {
80
+ focusChip(index);
81
+ select(option);
82
+ }, onKeyDown: onChipKeyDown, children: option.label }, option.value));
83
+ }) }));
84
+ }
85
+ //# sourceMappingURL=chip-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chip-group.js","sourceRoot":"","sources":["../../src/components/chip-group.tsx"],"names":[],"mappings":";AAmBA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA2B1C,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;IAC5C,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,QAAQ,GAAG,MAAM,CAA+B,EAAE,CAAC,CAAC;IAE1D,MAAM,UAAU,GAAG,CAAC,MAAkB,EAAW,EAAE,CACjD,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE9F,8EAA8E;IAC9E,0EAA0E;IAC1E,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAS,GAAG,EAAE;QAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC/C,IAAI,QAAQ,IAAI,CAAC;YAAE,OAAO,QAAQ,CAAC;QACnC,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;QAC7E,OAAO,YAAY,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC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AAC,YAE1C,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YAC7B,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,CACL,iBAEE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE;oBACf,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;gBACpC,CAAC,EACD,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,UAAU,EACpB,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,kBACrC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,kBAC9C,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,kBAG7C,KAAK,CAAC,cAAc,CAAC,EACnC,QAAQ,EAAE,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACxC,QAAQ,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAC9C,OAAO,EAAE,GAAG,EAAE;oBACZ,SAAS,CAAC,KAAK,CAAC,CAAC;oBACjB,MAAM,CAAC,MAAM,CAAC,CAAC;gBACjB,CAAC,EACD,SAAS,EAAE,aAAa,YAEvB,MAAM,CAAC,KAAK,IApBR,MAAM,CAAC,KAAK,CAqBV,CACV,CAAC;QACJ,CAAC,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
@@ -1061,11 +1061,16 @@
1061
1061
  color var(--tai-motion-fast) ease;
1062
1062
  }
1063
1063
 
1064
- .tai-chip:not(.tai-chip-static):not([aria-pressed='true']):hover:not(:disabled) {
1064
+ .tai-chip:not(.tai-chip-static):not([aria-pressed='true']):not([aria-checked='true']):hover:not(
1065
+ :disabled
1066
+ ) {
1065
1067
  background: var(--tai-color-surface);
1066
1068
  }
1067
1069
 
1068
- .tai-chip[aria-pressed='true'] {
1070
+ /* A selected chip, pressed (a multi-select toggle) OR checked (a single-select
1071
+ radio chip): both wear the accent tint. */
1072
+ .tai-chip[aria-pressed='true'],
1073
+ .tai-chip[aria-checked='true'] {
1069
1074
  background: var(--tai-color-accent-tint);
1070
1075
  border-color: var(--tai-color-accent);
1071
1076
  color: var(--tai-color-accent-on-tint);
@@ -1073,7 +1078,8 @@
1073
1078
 
1074
1079
  /* A selected chip KEEPS its tint on hover and strengthens its border instead —
1075
1080
  the one part that moves in both themes (see the segment rule above). */
1076
- .tai-chip[aria-pressed='true']:hover:not(:disabled) {
1081
+ .tai-chip[aria-pressed='true']:hover:not(:disabled),
1082
+ .tai-chip[aria-checked='true']:hover:not(:disabled) {
1077
1083
  border-color: var(--tai-color-accent-hover);
1078
1084
  }
1079
1085