@jirawatpyk/aura-react 5.66.0 → 5.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,81 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import { Checkbox } from "./Checkbox.js";
4
+ import { describedBy } from "./Field.js";
5
+ import { Icon } from "./Icon.js";
6
+ import { cx, touchClass, uid, useMaybeControlled } from "./internal.js";
7
+ import { useStrings } from "./locale.js";
8
+ import { IconCircleAlert } from "./icons.js";
9
+ const CheckboxGroup = React.forwardRef(
10
+ function CheckboxGroup2(props, ref) {
11
+ const t = useStrings();
12
+ const auto = uid(), id = props.id || auto;
13
+ const st = useMaybeControlled(props.value, props.defaultValue || [], props.onChange);
14
+ const picked = st[0] || [];
15
+ const opts = (props.options || []).map(function(o) {
16
+ return typeof o === "object" ? o : { value: o, label: o };
17
+ });
18
+ const name = props.name || id;
19
+ const setRef = React.useCallback(
20
+ function(el) {
21
+ if (el)
22
+ el.focus = function(o) {
23
+ const b = el.querySelector('input[type="checkbox"]:checked:not(:disabled)') || el.querySelector('input[type="checkbox"]:not(:disabled)');
24
+ if (b) b.focus(o);
25
+ };
26
+ if (typeof ref === "function") ref(el);
27
+ else if (ref) ref.current = el;
28
+ },
29
+ [ref]
30
+ );
31
+ return /* @__PURE__ */ React.createElement(
32
+ "fieldset",
33
+ {
34
+ ref: setRef,
35
+ className: cx(
36
+ "aura-field aura-radio-group aura-checkbox-group",
37
+ props.error && "is-invalid",
38
+ touchClass(props.touchHeight),
39
+ props.className
40
+ ),
41
+ "aria-describedby": describedBy(id, props),
42
+ disabled: props.disabled
43
+ },
44
+ props.label ? /* @__PURE__ */ React.createElement("legend", { className: "aura-field__label" }, props.label, props.required ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", { className: "aura-field__req", "aria-hidden": true }, " *"), /* @__PURE__ */ React.createElement("span", { className: "aura-sr-only" }, " (" + t.required + ")")) : null) : null,
45
+ /* @__PURE__ */ React.createElement("div", { className: cx("aura-radio-group__list", props.orientation === "horizontal" && "is-horizontal") }, opts.map(function(v) {
46
+ return /* @__PURE__ */ React.createElement(
47
+ Checkbox,
48
+ {
49
+ key: v.value,
50
+ name,
51
+ value: v.value,
52
+ checked: picked.indexOf(v.value) >= 0,
53
+ disabled: props.disabled || v.disabled,
54
+ description: v.description,
55
+ touchHeight: props.touchHeight,
56
+ "aria-invalid": props.error ? true : void 0,
57
+ "aria-describedby": props.error ? id + "-error" : void 0,
58
+ onChange: function(on) {
59
+ const known = opts.map(function(o) {
60
+ return o.value;
61
+ });
62
+ const next = known.filter(function(val) {
63
+ return val === v.value ? on : picked.indexOf(val) >= 0;
64
+ }).concat(
65
+ picked.filter(function(val) {
66
+ return known.indexOf(val) < 0;
67
+ })
68
+ );
69
+ st[1](next);
70
+ }
71
+ },
72
+ v.label
73
+ );
74
+ })),
75
+ props.error ? /* @__PURE__ */ React.createElement("p", { className: "aura-field__error", id: id + "-error" }, /* @__PURE__ */ React.createElement(Icon, { name: /* @__PURE__ */ React.createElement(IconCircleAlert, null), size: 14 }), props.error) : props.hint ? /* @__PURE__ */ React.createElement("p", { className: "aura-field__hint", id: id + "-hint" }, props.hint) : null
76
+ );
77
+ }
78
+ );
79
+ export {
80
+ CheckboxGroup
81
+ };
package/dist/esm/index.js CHANGED
@@ -13,6 +13,7 @@ import { Select } from "./Select.js";
13
13
  import { FilterSelect } from "./FilterSelect.js";
14
14
  import { FilterDateRange } from "./FilterDateRange.js";
15
15
  import { RadioGroup } from "./RadioGroup.js";
16
+ import { CheckboxGroup } from "./CheckboxGroup.js";
16
17
  import { Switch } from "./Switch.js";
17
18
  import { Combobox, defaultFilter } from "./Combobox.js";
18
19
  import { DatePicker, DateRangePicker, Calendar, formatDate, parseDate, useFormatDate } from "./DatePicker.js";
@@ -78,6 +79,7 @@ export {
78
79
  Calendar,
79
80
  Card,
80
81
  Checkbox,
82
+ CheckboxGroup,
81
83
  ColorSchemeScript,
82
84
  ColorSchemeToggle,
83
85
  Combobox,
@@ -133,6 +133,7 @@ const STRINGS = {
133
133
  statusOk: "OK",
134
134
  statusUnknown: "No data",
135
135
  opensInNewTab: "opens in a new tab",
136
+ required: "required",
136
137
  filtersApplied: function(n2) {
137
138
  return "Filters, " + n2.toLocaleString("en") + " applied";
138
139
  },
@@ -129,6 +129,7 @@ const sv = {
129
129
  statusOk: "OK",
130
130
  statusUnknown: "Ingen data",
131
131
  opensInNewTab: "\xF6ppnas i en ny flik",
132
+ required: "obligatoriskt",
132
133
  filtersApplied: function(n) {
133
134
  return "Filter, " + n.toLocaleString("sv-SE") + " aktiva";
134
135
  },
@@ -129,6 +129,7 @@ const th = {
129
129
  statusOk: "\u0E1B\u0E01\u0E15\u0E34",
130
130
  statusUnknown: "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",
131
131
  opensInNewTab: "\u0E40\u0E1B\u0E34\u0E14\u0E43\u0E19\u0E41\u0E17\u0E47\u0E1A\u0E43\u0E2B\u0E21\u0E48",
132
+ required: "\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19",
132
133
  filtersApplied: function(n2) {
133
134
  return "\u0E15\u0E31\u0E27\u0E01\u0E23\u0E2D\u0E07, \u0E43\u0E0A\u0E49\u0E2D\u0E22\u0E39\u0E48 " + n2.toLocaleString("en") + " \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23";
134
135
  },
package/dist/index.d.cts CHANGED
@@ -687,6 +687,25 @@ export interface RadioGroupProps extends FieldProps {
687
687
  * screens already get it), `'always'` at every width, also with a mouse. Default: as tall as the control and label. */
688
688
  touchHeight?: TouchHeight | undefined;
689
689
  }
690
+ /** 5.67 (Chamber-OS 183): RadioGroup's many-choice twin — one legend, one hint, one error over a set of checkboxes. */
691
+ export interface CheckboxGroupProps extends FieldProps {
692
+ options: ChoiceOption[];
693
+ /** The ticked options' values, in option order (not the order they were ticked); values not among the options are
694
+ * kept, after them. `required` shows the `*` and adds "(required)" to the group's name; "at least one" is yours to
695
+ * check — pass `error`. */
696
+ value?: string[] | undefined;
697
+ defaultValue?: string[] | undefined;
698
+ onChange?: ((values: string[]) => void) | undefined;
699
+ /** Each box's `name` for a native form (one entry per ticked value). Default: the group's id. */
700
+ name?: string | undefined;
701
+ /** Default `vertical`. */
702
+ orientation?: "vertical" | "horizontal" | undefined;
703
+ disabled?: boolean | undefined;
704
+ id?: string | undefined;
705
+ className?: string | undefined;
706
+ /** 44px rows, as RadioGroup: `true` below 640px or on a coarse pointer, `'always'` at every width. */
707
+ touchHeight?: TouchHeight | undefined;
708
+ }
690
709
  export interface SwitchProps {
691
710
  label?: string | undefined;
692
711
  description?: string | undefined;
@@ -1933,6 +1952,7 @@ export declare const FilterSelect: React$1.ForwardRefExoticComponent<FilterSelec
1933
1952
  * complete, a preset is picked or the range is cleared; never on a lone start day. */
1934
1953
  export declare const FilterDateRange: React$1.ForwardRefExoticComponent<FilterDateRangeProps & React$1.RefAttributes<HTMLButtonElement>>;
1935
1954
  export declare const RadioGroup: React$1.ForwardRefExoticComponent<RadioGroupProps & React$1.RefAttributes<HTMLFieldSetElement>>;
1955
+ export declare const CheckboxGroup: React$1.ForwardRefExoticComponent<CheckboxGroupProps & React$1.RefAttributes<HTMLFieldSetElement>>;
1936
1956
  export declare const Switch: React$1.ForwardRefExoticComponent<SwitchProps & React$1.RefAttributes<HTMLButtonElement>>;
1937
1957
  /** One value, or with `multiple` any number (chips). Two call signatures so value/onChange are typed for each. */
1938
1958
  export interface ComboboxComponent {
@@ -2239,6 +2259,8 @@ export interface AuraStrings {
2239
2259
  statusUnknown: string;
2240
2260
  /** Read after a Menu link item with `target="_blank"` (5.41): "Visit site (opens in a new tab)". */
2241
2261
  opensInNewTab: string;
2262
+ /** 5.67: read after a CheckboxGroup's legend when `required` (its `*` is hidden from screen readers). */
2263
+ required: string;
2242
2264
  /** 5.42: FilterBar's collapsed-filters button, read with its count ("Filters, 2 applied"). */
2243
2265
  filtersApplied: (n: number) => string;
2244
2266
  /** 5.42: closes FilterBar's "Filters" sheet. */
package/dist/index.d.ts CHANGED
@@ -687,6 +687,25 @@ export interface RadioGroupProps extends FieldProps {
687
687
  * screens already get it), `'always'` at every width, also with a mouse. Default: as tall as the control and label. */
688
688
  touchHeight?: TouchHeight | undefined;
689
689
  }
690
+ /** 5.67 (Chamber-OS 183): RadioGroup's many-choice twin — one legend, one hint, one error over a set of checkboxes. */
691
+ export interface CheckboxGroupProps extends FieldProps {
692
+ options: ChoiceOption[];
693
+ /** The ticked options' values, in option order (not the order they were ticked); values not among the options are
694
+ * kept, after them. `required` shows the `*` and adds "(required)" to the group's name; "at least one" is yours to
695
+ * check — pass `error`. */
696
+ value?: string[] | undefined;
697
+ defaultValue?: string[] | undefined;
698
+ onChange?: ((values: string[]) => void) | undefined;
699
+ /** Each box's `name` for a native form (one entry per ticked value). Default: the group's id. */
700
+ name?: string | undefined;
701
+ /** Default `vertical`. */
702
+ orientation?: "vertical" | "horizontal" | undefined;
703
+ disabled?: boolean | undefined;
704
+ id?: string | undefined;
705
+ className?: string | undefined;
706
+ /** 44px rows, as RadioGroup: `true` below 640px or on a coarse pointer, `'always'` at every width. */
707
+ touchHeight?: TouchHeight | undefined;
708
+ }
690
709
  export interface SwitchProps {
691
710
  label?: string | undefined;
692
711
  description?: string | undefined;
@@ -1933,6 +1952,7 @@ export declare const FilterSelect: React$1.ForwardRefExoticComponent<FilterSelec
1933
1952
  * complete, a preset is picked or the range is cleared; never on a lone start day. */
1934
1953
  export declare const FilterDateRange: React$1.ForwardRefExoticComponent<FilterDateRangeProps & React$1.RefAttributes<HTMLButtonElement>>;
1935
1954
  export declare const RadioGroup: React$1.ForwardRefExoticComponent<RadioGroupProps & React$1.RefAttributes<HTMLFieldSetElement>>;
1955
+ export declare const CheckboxGroup: React$1.ForwardRefExoticComponent<CheckboxGroupProps & React$1.RefAttributes<HTMLFieldSetElement>>;
1936
1956
  export declare const Switch: React$1.ForwardRefExoticComponent<SwitchProps & React$1.RefAttributes<HTMLButtonElement>>;
1937
1957
  /** One value, or with `multiple` any number (chips). Two call signatures so value/onChange are typed for each. */
1938
1958
  export interface ComboboxComponent {
@@ -2239,6 +2259,8 @@ export interface AuraStrings {
2239
2259
  statusUnknown: string;
2240
2260
  /** Read after a Menu link item with `target="_blank"` (5.41): "Visit site (opens in a new tab)". */
2241
2261
  opensInNewTab: string;
2262
+ /** 5.67: read after a CheckboxGroup's legend when `required` (its `*` is hidden from screen readers). */
2263
+ required: string;
2242
2264
  /** 5.42: FilterBar's collapsed-filters button, read with its count ("Filters, 2 applied"). */
2243
2265
  filtersApplied: (n: number) => string;
2244
2266
  /** 5.42: closes FilterBar's "Filters" sheet. */
@@ -154,6 +154,7 @@ var sv = {
154
154
  statusOk: "OK",
155
155
  statusUnknown: "Ingen data",
156
156
  opensInNewTab: "\xF6ppnas i en ny flik",
157
+ required: "obligatoriskt",
157
158
  filtersApplied: function(n) {
158
159
  return "Filter, " + n.toLocaleString("sv-SE") + " aktiva";
159
160
  },
@@ -98,6 +98,8 @@ export interface AuraStrings {
98
98
  statusUnknown: string;
99
99
  /** Read after a Menu link item with `target="_blank"` (5.41): "Visit site (opens in a new tab)". */
100
100
  opensInNewTab: string;
101
+ /** 5.67: read after a CheckboxGroup's legend when `required` (its `*` is hidden from screen readers). */
102
+ required: string;
101
103
  /** 5.42: FilterBar's collapsed-filters button, read with its count ("Filters, 2 applied"). */
102
104
  filtersApplied: (n: number) => string;
103
105
  /** 5.42: closes FilterBar's "Filters" sheet. */
@@ -98,6 +98,8 @@ export interface AuraStrings {
98
98
  statusUnknown: string;
99
99
  /** Read after a Menu link item with `target="_blank"` (5.41): "Visit site (opens in a new tab)". */
100
100
  opensInNewTab: string;
101
+ /** 5.67: read after a CheckboxGroup's legend when `required` (its `*` is hidden from screen readers). */
102
+ required: string;
101
103
  /** 5.42: FilterBar's collapsed-filters button, read with its count ("Filters, 2 applied"). */
102
104
  filtersApplied: (n: number) => string;
103
105
  /** 5.42: closes FilterBar's "Filters" sheet. */
@@ -154,6 +154,7 @@ var th = {
154
154
  statusOk: "\u0E1B\u0E01\u0E15\u0E34",
155
155
  statusUnknown: "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",
156
156
  opensInNewTab: "\u0E40\u0E1B\u0E34\u0E14\u0E43\u0E19\u0E41\u0E17\u0E47\u0E1A\u0E43\u0E2B\u0E21\u0E48",
157
+ required: "\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19",
157
158
  filtersApplied: function(n2) {
158
159
  return "\u0E15\u0E31\u0E27\u0E01\u0E23\u0E2D\u0E07, \u0E43\u0E0A\u0E49\u0E2D\u0E22\u0E39\u0E48 " + n2.toLocaleString("en") + " \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23";
159
160
  },
@@ -98,6 +98,8 @@ export interface AuraStrings {
98
98
  statusUnknown: string;
99
99
  /** Read after a Menu link item with `target="_blank"` (5.41): "Visit site (opens in a new tab)". */
100
100
  opensInNewTab: string;
101
+ /** 5.67: read after a CheckboxGroup's legend when `required` (its `*` is hidden from screen readers). */
102
+ required: string;
101
103
  /** 5.42: FilterBar's collapsed-filters button, read with its count ("Filters, 2 applied"). */
102
104
  filtersApplied: (n: number) => string;
103
105
  /** 5.42: closes FilterBar's "Filters" sheet. */
@@ -98,6 +98,8 @@ export interface AuraStrings {
98
98
  statusUnknown: string;
99
99
  /** Read after a Menu link item with `target="_blank"` (5.41): "Visit site (opens in a new tab)". */
100
100
  opensInNewTab: string;
101
+ /** 5.67: read after a CheckboxGroup's legend when `required` (its `*` is hidden from screen readers). */
102
+ required: string;
101
103
  /** 5.42: FilterBar's collapsed-filters button, read with its count ("Filters, 2 applied"). */
102
104
  filtersApplied: (n: number) => string;
103
105
  /** 5.42: closes FilterBar's "Filters" sheet. */
@@ -345,6 +345,7 @@ var th = {
345
345
  statusOk: "\u0E1B\u0E01\u0E15\u0E34",
346
346
  statusUnknown: "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",
347
347
  opensInNewTab: "\u0E40\u0E1B\u0E34\u0E14\u0E43\u0E19\u0E41\u0E17\u0E47\u0E1A\u0E43\u0E2B\u0E21\u0E48",
348
+ required: "\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19",
348
349
  filtersApplied: function(n3) {
349
350
  return "\u0E15\u0E31\u0E27\u0E01\u0E23\u0E2D\u0E07, \u0E43\u0E0A\u0E49\u0E2D\u0E22\u0E39\u0E48 " + n3.toLocaleString("en") + " \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23";
350
351
  },
@@ -486,6 +487,7 @@ var sv = {
486
487
  statusOk: "OK",
487
488
  statusUnknown: "Ingen data",
488
489
  opensInNewTab: "\xF6ppnas i en ny flik",
490
+ required: "obligatoriskt",
489
491
  filtersApplied: function(n3) {
490
492
  return "Filter, " + n3.toLocaleString("sv-SE") + " aktiva";
491
493
  },
@@ -628,6 +630,7 @@ var STRINGS = {
628
630
  statusOk: "OK",
629
631
  statusUnknown: "No data",
630
632
  opensInNewTab: "opens in a new tab",
633
+ required: "required",
631
634
  filtersApplied: function(n3) {
632
635
  return "Filters, " + n3.toLocaleString("en") + " applied";
633
636
  },
@@ -432,6 +432,8 @@ export interface AuraStrings {
432
432
  statusUnknown: string;
433
433
  /** Read after a Menu link item with `target="_blank"` (5.41): "Visit site (opens in a new tab)". */
434
434
  opensInNewTab: string;
435
+ /** 5.67: read after a CheckboxGroup's legend when `required` (its `*` is hidden from screen readers). */
436
+ required: string;
435
437
  /** 5.42: FilterBar's collapsed-filters button, read with its count ("Filters, 2 applied"). */
436
438
  filtersApplied: (n: number) => string;
437
439
  /** 5.42: closes FilterBar's "Filters" sheet. */
@@ -432,6 +432,8 @@ export interface AuraStrings {
432
432
  statusUnknown: string;
433
433
  /** Read after a Menu link item with `target="_blank"` (5.41): "Visit site (opens in a new tab)". */
434
434
  opensInNewTab: string;
435
+ /** 5.67: read after a CheckboxGroup's legend when `required` (its `*` is hidden from screen readers). */
436
+ required: string;
435
437
  /** 5.42: FilterBar's collapsed-filters button, read with its count ("Filters, 2 applied"). */
436
438
  filtersApplied: (n: number) => string;
437
439
  /** 5.42: closes FilterBar's "Filters" sheet. */
@@ -279,6 +279,7 @@ var th = {
279
279
  statusOk: "\u0E1B\u0E01\u0E15\u0E34",
280
280
  statusUnknown: "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",
281
281
  opensInNewTab: "\u0E40\u0E1B\u0E34\u0E14\u0E43\u0E19\u0E41\u0E17\u0E47\u0E1A\u0E43\u0E2B\u0E21\u0E48",
282
+ required: "\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19",
282
283
  filtersApplied: function(n3) {
283
284
  return "\u0E15\u0E31\u0E27\u0E01\u0E23\u0E2D\u0E07, \u0E43\u0E0A\u0E49\u0E2D\u0E22\u0E39\u0E48 " + n3.toLocaleString("en") + " \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23";
284
285
  },
@@ -420,6 +421,7 @@ var sv = {
420
421
  statusOk: "OK",
421
422
  statusUnknown: "Ingen data",
422
423
  opensInNewTab: "\xF6ppnas i en ny flik",
424
+ required: "obligatoriskt",
423
425
  filtersApplied: function(n3) {
424
426
  return "Filter, " + n3.toLocaleString("sv-SE") + " aktiva";
425
427
  },
@@ -562,6 +564,7 @@ var STRINGS = {
562
564
  statusOk: "OK",
563
565
  statusUnknown: "No data",
564
566
  opensInNewTab: "opens in a new tab",
567
+ required: "required",
565
568
  filtersApplied: function(n3) {
566
569
  return "Filters, " + n3.toLocaleString("en") + " applied";
567
570
  },
package/dist/styles.css CHANGED
@@ -608,6 +608,8 @@ a.aura-icon-btn { text-decoration: none; }
608
608
  .aura-radio:checked { border: 5px solid var(--aura-control-checked-bg); background: var(--aura-control-checked-fg); }
609
609
  .aura-radio:focus-visible { outline: var(--aura-focus-ring-width) solid var(--aura-focus-ring); outline-offset: var(--aura-focus-ring-offset); }
610
610
  .aura-radio-group.is-invalid .aura-radio:not(:checked) { border-color: var(--aura-border-danger); }
611
+ /* 5.67 (Chamber-OS 183): CheckboxGroup shares RadioGroup's legend, list and touch rows; an error edges the empty boxes. */
612
+ .aura-checkbox-group.is-invalid .aura-check__input:not(:checked) + .aura-check__box { border-color: var(--aura-border-danger); }
611
613
 
612
614
  .aura-switch-row { display: flex; align-items: flex-start; gap: var(--aura-space-3); font-family: var(--font-sans); }
613
615
  /* 5.10.1: disabled rows, on or off, are treated alike and stay readable — the label turns secondary, the description
@@ -610,6 +610,8 @@ a.aura-icon-btn { text-decoration: none; }
610
610
  .aura-radio:checked { border: 5px solid var(--aura-control-checked-bg); background: var(--aura-control-checked-fg); }
611
611
  .aura-radio:focus-visible { outline: var(--aura-focus-ring-width) solid var(--aura-focus-ring); outline-offset: var(--aura-focus-ring-offset); }
612
612
  .aura-radio-group.is-invalid .aura-radio:not(:checked) { border-color: var(--aura-border-danger); }
613
+ /* 5.67 (Chamber-OS 183): CheckboxGroup shares RadioGroup's legend, list and touch rows; an error edges the empty boxes. */
614
+ .aura-checkbox-group.is-invalid .aura-check__input:not(:checked) + .aura-check__box { border-color: var(--aura-border-danger); }
613
615
 
614
616
  .aura-switch-row { display: flex; align-items: flex-start; gap: var(--aura-space-3); font-family: var(--font-sans); }
615
617
  /* 5.10.1: disabled rows, on or off, are treated alike and stay readable — the label turns secondary, the description
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jirawatpyk/aura-react",
3
- "version": "5.66.0",
3
+ "version": "5.67.0",
4
4
  "description": "AURA Design System — React components (Enterprise Standard, Human Creative). Thai-first: Buddhist-era dates, Thai collation.",
5
5
  "license": "MIT",
6
6
  "type": "module",