@stacksjs/components 0.2.961 → 0.2.962

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 (60) hide show
  1. package/README.md +4 -0
  2. package/dist/{AppearancePicker-30fetv0a.stx → AppearancePicker-34758z53.stx} +2 -70
  3. package/dist/{Button-ghdfqwg0.stx → Button-rns3jhjh.stx} +33 -70
  4. package/dist/{Checkbox-355qsbwd.stx → Checkbox-4g3hemtw.stx} +1 -69
  5. package/dist/{ColorSwatches-ecfxphjy.stx → ColorSwatches-mz9kt78g.stx} +1 -69
  6. package/dist/{DateTimePicker-pz9p8jw4.stx → DateTimePicker-d5984mm1.stx} +5 -3
  7. package/dist/{NumberInput-e2afxyh3.stx → NumberInput-nqqen5a6.stx} +2 -70
  8. package/dist/{PasswordInput-d78bk8r0.stx → PasswordInput-j38f2n01.stx} +2 -70
  9. package/dist/{RadioGroup-ps9kn22f.stx → RadioGroup-mz3pv7he.stx} +1 -69
  10. package/dist/{RadioGroupOption-6hyy1bvb.stx → RadioGroupOption-mk98taz5.stx} +1 -69
  11. package/dist/{SegmentedControl-b93n9n2v.stx → SegmentedControl-jm6tb9f8.stx} +1 -69
  12. package/dist/{Select-p8mgxthn.stx → Select-36s22z6d.stx} +2 -70
  13. package/dist/{SettingsGroup-g1hnxp1p.stx → SettingsGroup-t3emsgk2.stx} +2 -70
  14. package/dist/{SettingsPane-9svk1w3e.stx → SettingsPane-tqe8q5cw.stx} +11 -3
  15. package/dist/{SettingsPaneHeader-am42srhp.stx → SettingsPaneHeader-wznh6dss.stx} +2 -70
  16. package/dist/{SettingsRow-kgda3nv1.stx → SettingsRow-5jgay5ae.stx} +2 -70
  17. package/dist/SettingsSidebarGroup-p5h359bn.stx +57 -0
  18. package/dist/{SettingsSidebarItem-ga2jxq53.stx → SettingsSidebarItem-69zs4b55.stx} +2 -70
  19. package/dist/{SettingsUpdateRow-ajpnqx8a.stx → SettingsUpdateRow-92mmxvpd.stx} +1 -69
  20. package/dist/{SettingsWindow-v7jepxem.stx → SettingsWindow-q0x86xqb.stx} +8 -70
  21. package/dist/{Slider-j59dgw1c.stx → Slider-cebse060.stx} +1 -69
  22. package/dist/{Switch-vd8k23sr.stx → Switch-7s3bhjg4.stx} +2 -70
  23. package/dist/{TextInput-fge1b7tk.stx → TextInput-4v09vw1r.stx} +2 -70
  24. package/dist/index.js +17 -17
  25. package/dist/settings/settings.js +80 -19
  26. package/dist/ui/button/Button.d.ts +4 -1
  27. package/dist/ui/button/index.d.ts +4 -0
  28. package/dist/ui/date-time-picker/DateTimePicker.d.ts +2 -0
  29. package/dist/ui/settings/SettingsPane.d.ts +6 -3
  30. package/dist/ui/settings/SettingsWindow.d.ts +4 -1
  31. package/dist/ui/settings/index.d.ts +4 -0
  32. package/dist/ui/settings/view.d.ts +3 -0
  33. package/package.json +3 -3
  34. package/{dist/SettingsSidebarGroup-4ag5qjpw.stx → src/theme/macos.css} +0 -57
  35. package/src/ui/appearance-picker/AppearancePicker.stx +2 -70
  36. package/src/ui/button/Button.stx +33 -70
  37. package/src/ui/button/index.ts +9 -0
  38. package/src/ui/checkbox/Checkbox.stx +1 -69
  39. package/src/ui/color-swatches/ColorSwatches.stx +1 -69
  40. package/src/ui/date-time-picker/DateTimePicker.stx +5 -3
  41. package/src/ui/input/NumberInput.stx +2 -70
  42. package/src/ui/input/PasswordInput.stx +2 -70
  43. package/src/ui/input/TextInput.stx +2 -70
  44. package/src/ui/radio-group/RadioGroup.stx +1 -69
  45. package/src/ui/radio-group/RadioGroupOption.stx +1 -69
  46. package/src/ui/segmented-control/SegmentedControl.stx +1 -69
  47. package/src/ui/select/Select.stx +2 -70
  48. package/src/ui/settings/README.md +21 -0
  49. package/src/ui/settings/SettingsGroup.stx +2 -70
  50. package/src/ui/settings/SettingsPane.stx +11 -3
  51. package/src/ui/settings/SettingsPaneHeader.stx +2 -70
  52. package/src/ui/settings/SettingsRow.stx +2 -70
  53. package/src/ui/settings/SettingsSidebarGroup.stx +2 -70
  54. package/src/ui/settings/SettingsSidebarItem.stx +2 -70
  55. package/src/ui/settings/SettingsUpdateRow.stx +1 -69
  56. package/src/ui/settings/SettingsWindow.stx +8 -70
  57. package/src/ui/settings/index.ts +6 -0
  58. package/src/ui/settings/view.ts +93 -21
  59. package/src/ui/slider/Slider.stx +1 -69
  60. package/src/ui/switch/Switch.stx +2 -70
@@ -529,6 +529,7 @@ function settingsUpdateView(status, appName = "") {
529
529
  }
530
530
  }
531
531
  // src/ui/settings/view.ts
532
+ import { loadStaticFragment } from "@stacksjs/stx/static-fragment-client";
532
533
  var ROOT2 = "[data-stx-settings]";
533
534
  var ITEM2 = "[data-settings-item]";
534
535
  var PANE2 = "[data-settings-pane]";
@@ -541,6 +542,7 @@ function domId(text) {
541
542
 
542
543
  class SettingsWindowView {
543
544
  root;
545
+ options;
544
546
  callbacks;
545
547
  history = emptySettingsHistory();
546
548
  current = "";
@@ -549,6 +551,8 @@ class SettingsWindowView {
549
551
  storage;
550
552
  typed = null;
551
553
  hits = [];
554
+ queuedReveal = null;
555
+ fragmentDownloads = new AbortController;
552
556
  highlighted = null;
553
557
  highlightTimer = null;
554
558
  disposers = [];
@@ -565,6 +569,7 @@ class SettingsWindowView {
565
569
  body;
566
570
  constructor(root, options = {}, callbacks = {}) {
567
571
  this.root = root;
572
+ this.options = options;
568
573
  this.callbacks = callbacks;
569
574
  this.storageKey = options.storageKey || "";
570
575
  this.storage = options.storage ?? null;
@@ -611,12 +616,11 @@ class SettingsWindowView {
611
616
  revealSetting(id) {
612
617
  if (!id)
613
618
  return false;
614
- const row = this.rowElements().find((element) => element.getAttribute("data-setting") === id);
615
- const pane = row ? this.paneOf(row) : "";
616
- if (!row || !pane)
619
+ const row = this.searchableRows().find((entry) => entry.id === id);
620
+ if (!row)
617
621
  return false;
618
- this.open(pane);
619
- this.reveal(row);
622
+ this.open(row.pane);
623
+ this.revealRow(row);
620
624
  return true;
621
625
  }
622
626
  back() {
@@ -638,6 +642,7 @@ class SettingsWindowView {
638
642
  this.applySearch(true);
639
643
  }
640
644
  destroy() {
645
+ this.fragmentDownloads.abort();
641
646
  for (const dispose of this.disposers)
642
647
  dispose();
643
648
  this.disposers.length = 0;
@@ -684,11 +689,26 @@ class SettingsWindowView {
684
689
  keywords: item.getAttribute("data-keywords") || ""
685
690
  }));
686
691
  }
687
- rowElements() {
688
- return this.all(ROW2).filter((row) => this.paneOf(row) !== "");
692
+ rowElements(pane) {
693
+ return this.all(ROW2, pane).filter((element) => element.closest(PANE2) === pane);
689
694
  }
690
- paneOf(element) {
691
- return element.closest(PANE2)?.getAttribute("data-settings-pane") || "";
695
+ searchableRows() {
696
+ return this.paneElements().flatMap((pane) => {
697
+ const id = pane.getAttribute("data-settings-pane") || "";
698
+ if (!id)
699
+ return [];
700
+ if (pane.hasAttribute("data-stx-fragment")) {
701
+ const entries = JSON.parse(pane.getAttribute("data-stx-fragment-metadata") || "[]");
702
+ return entries.map(([setting, label, keywords], position) => ({ id: setting, label: label.trim(), keywords, pane: id, position }));
703
+ }
704
+ return this.rowElements(pane).map((row, position) => ({
705
+ id: row.getAttribute("data-setting") || "",
706
+ label: (row.getAttribute("data-label") || "").trim(),
707
+ keywords: row.getAttribute("data-keywords") || "",
708
+ pane: id,
709
+ position
710
+ }));
711
+ });
692
712
  }
693
713
  stored() {
694
714
  if (!this.storageKey)
@@ -783,6 +803,7 @@ class SettingsWindowView {
783
803
  const changed = id !== this.current;
784
804
  this.current = id;
785
805
  if (changed) {
806
+ this.queuedReveal = null;
786
807
  this.clearHighlight();
787
808
  if (this.body)
788
809
  this.body.scrollTop = 0;
@@ -795,6 +816,39 @@ class SettingsWindowView {
795
816
  this.store();
796
817
  this.callbacks.onPane?.({ id, title: info.title, parent: settingsParentPane(panes, id) });
797
818
  }
819
+ if (target.hasAttribute("data-stx-fragment") && !target.hasChildNodes())
820
+ this.loadPane(target);
821
+ }
822
+ async loadPane(pane) {
823
+ const status = document.createElement("p");
824
+ status.setAttribute("role", "status");
825
+ status.textContent = this.options.loadingPane ?? "Loading settings…";
826
+ if (pane.contains(document.activeElement)) {
827
+ pane.setAttribute("tabindex", "-1");
828
+ pane.focus({ preventScroll: true });
829
+ }
830
+ pane.replaceChildren(status);
831
+ pane.setAttribute("aria-busy", "true");
832
+ const signal = this.fragmentDownloads.signal;
833
+ try {
834
+ await loadStaticFragment(pane, signal);
835
+ const reveal = this.queuedReveal;
836
+ if (reveal && this.current === reveal.pane && this.paneElement(reveal.pane) === pane) {
837
+ this.queuedReveal = null;
838
+ this.revealRow(reveal);
839
+ }
840
+ } catch {
841
+ if (signal.aborted || !pane.isConnected)
842
+ return;
843
+ status.textContent = this.options.failedPane ?? "Could not load this pane.";
844
+ const retry = document.createElement("button");
845
+ retry.type = "button";
846
+ retry.textContent = this.options.retryPane ?? "Try again";
847
+ retry.addEventListener("click", () => void this.loadPane(pane), { once: true });
848
+ pane.replaceChildren(status, retry);
849
+ } finally {
850
+ pane.removeAttribute("aria-busy");
851
+ }
798
852
  }
799
853
  syncTabStops() {
800
854
  const visible = this.visibleItems();
@@ -825,14 +879,8 @@ class SettingsWindowView {
825
879
  this.root.toggleAttribute("data-scrolled", Boolean(this.body && this.body.scrollTop > 0));
826
880
  }
827
881
  applySearch(report) {
828
- const rows = this.rowElements();
829
- const index = rows.map((row) => ({
830
- id: row.getAttribute("data-setting") || "",
831
- label: (row.getAttribute("data-label") || "").trim(),
832
- keywords: row.getAttribute("data-keywords") || "",
833
- pane: this.paneOf(row)
834
- }));
835
- const found = searchSettings(this.query, { panes: this.panes(), items: this.items(), rows: index });
882
+ const rows = this.searchableRows();
883
+ const found = searchSettings(this.query, { panes: this.panes(), items: this.items(), rows });
836
884
  const searching = found.query !== "";
837
885
  this.root.toggleAttribute("data-searching", searching);
838
886
  this.field?.toggleAttribute("data-filled", this.query !== "");
@@ -885,16 +933,29 @@ class SettingsWindowView {
885
933
  }
886
934
  chooseResult(position) {
887
935
  const found = this.hits[position];
888
- if (!found || !found.row.isConnected)
936
+ if (!found)
889
937
  return;
890
938
  this.open(found.hit.pane);
891
- this.reveal(found.row);
939
+ this.revealRow(found.row);
892
940
  }
893
941
  clearSearch() {
894
942
  if (this.query === "" && (!this.input || this.input.value === ""))
895
943
  return;
896
944
  this.search("");
897
945
  }
946
+ revealRow(hit) {
947
+ const pane = this.paneElement(hit.pane);
948
+ if (!pane)
949
+ return;
950
+ if (pane.hasAttribute("data-stx-fragment")) {
951
+ this.queuedReveal = hit;
952
+ return;
953
+ }
954
+ const rows = this.rowElements(pane);
955
+ const row = hit.id ? rows.find((element) => element.getAttribute("data-setting") === hit.id) : rows[hit.position];
956
+ if (row)
957
+ this.reveal(row);
958
+ }
898
959
  reveal(row) {
899
960
  if (this.body) {
900
961
  const frame = this.body.getBoundingClientRect();
@@ -79,6 +79,9 @@ export declare const hasLabel: boolean;
79
79
  * is for a button that has neither.
80
80
  */
81
81
  export declare const ariaLabel: unknown;
82
+ export declare const ariaExpanded: unknown;
83
+ export declare const ariaControls: unknown;
84
+ export declare const ariaPressed: unknown;
82
85
  export declare const leftIcon: unknown;
83
86
  export declare const rightIcon: unknown;
84
87
  export declare const className: unknown;
@@ -223,5 +226,5 @@ declare const desktopVariants: string[];
223
226
  export declare const desktopVariant: unknown;
224
227
  /** `title` names the button only when nothing in the slot does: beside content it is the tooltip. */
225
228
  export declare const titleNames: unknown;
226
- declare type __DtsxStxComponentType = DefineComponent<{ variant?: string, appearance?: unknown, size?: string, disabled?: unknown, loading?: unknown, type?: string, fullWidth?: unknown, symbol?: string, iconOnly?: unknown, label?: unknown, title?: string, ariaLabel?: unknown, "aria-label"?: string, leftIcon?: string, rightIcon?: string, className?: string }>;
229
+ declare type __DtsxStxComponentType = DefineComponent<{ variant?: string, appearance?: unknown, size?: string, disabled?: unknown, loading?: unknown, type?: string, fullWidth?: unknown, symbol?: string, iconOnly?: unknown, label?: unknown, title?: string, ariaLabel?: unknown, "aria-label"?: string, ariaExpanded?: string, ariaControls?: string, ariaPressed?: string, leftIcon?: string, rightIcon?: string, className?: string }>;
227
230
  export default __dtsx_component__;
@@ -40,9 +40,13 @@ export declare interface ButtonProps {
40
40
  fullWidth?: boolean
41
41
  label?: string
42
42
  text?: string
43
+ ariaExpanded?: AriaBoolean | null
44
+ ariaControls?: string | null
45
+ ariaPressed?: AriaBoolean | 'mixed' | null
43
46
  leftIcon?: string
44
47
  rightIcon?: string
45
48
  className?: string
46
49
  onClick?: (event: Event) => void
47
50
  }
51
+ declare type AriaBoolean = boolean | 'true' | 'false';
48
52
  export { default as Button } from './Button';
@@ -14,6 +14,8 @@ declare const step: unknown;
14
14
  export declare const minuteStep: boolean;
15
15
  export declare const placeholder: unknown;
16
16
  export declare const label: unknown;
17
+ export declare const triggerLabel: unknown;
18
+ export declare const triggerPlaceholder: unknown;
17
19
  export declare const instanceId: unknown;
18
20
  export declare const rootClasses: unknown;
19
21
  export declare const triggerClasses: 'inline-flex items-center gap-2 rounded-control bg-field px-3 py-2 text-sm text-fg ring-1 ring-inset ring-line-strong hover:bg-field-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50';
@@ -5,8 +5,10 @@ declare const __dtsx_component__: __DtsxStxComponentType;
5
5
  * sidebar item carries; a pane with a `parent` is a sub-pane, reached by a
6
6
  * navigation row and not from the sidebar.
7
7
  *
8
- * Every pane is in the page from the start and all but one are hidden. The
9
- * shell shows the open one; `active` leaves this one showing before it has.
8
+ * The shell shows the open pane. `active` leaves it showing before the
9
+ * shell runs. In static web builds, `defer` moves an inactive pane's
10
+ * contents into an asset fetched when the pane opens. Request-rendered web
11
+ * builds can serve it through the owning page if deferred regions are enabled.
10
12
  *
11
13
  * On a native host ($native) a pane is a scroll view of its own, so each pane
12
14
  * keeps its place when the window moves between them.
@@ -16,8 +18,9 @@ export declare const title: unknown;
16
18
  export declare const keywords: unknown;
17
19
  export declare const parent: unknown;
18
20
  export declare const active: ReturnType<typeof $bool>;
21
+ export declare const deferred: ReturnType<typeof $bool>;
19
22
  export declare const role: unknown;
20
23
  export declare const className: unknown;
21
24
  export declare const T: unknown;
22
- declare type __DtsxStxComponentType = DefineComponent<{ id?: string, title?: unknown, keywords?: string, parent?: string, active?: unknown, className?: string }>;
25
+ declare type __DtsxStxComponentType = DefineComponent<{ id?: string, title?: unknown, keywords?: string, parent?: string, active?: unknown, defer?: unknown, className?: string }>;
23
26
  export default __dtsx_component__;
@@ -5,6 +5,9 @@ export declare const pane: unknown;
5
5
  export declare const searchable: unknown;
6
6
  export declare const searchPlaceholder: unknown;
7
7
  export declare const storageKey: unknown;
8
+ export declare const loadingPane: unknown;
9
+ export declare const failedPane: unknown;
10
+ export declare const retryPane: unknown;
8
11
  /*
9
12
  * `window` is a window that is all Settings: it fills the viewport and leaves
10
13
  * room for the traffic lights. `sheet` is the same two columns inside a page.
@@ -30,5 +33,5 @@ export declare const SYMBOLS: unknown;
30
33
  export declare const nativeSidebarWidth: boolean;
31
34
  export declare const hasAccount: unknown;
32
35
  export declare const wash: unknown;
33
- declare type __DtsxStxComponentType = DefineComponent<{ title?: string, pane?: string, searchable?: unknown, searchPlaceholder?: string, storageKey?: string, presentation?: unknown, className?: string, id?: string, sidebarWidth?: unknown, height?: string }> & { readonly __stxEmits?: ["pane", "search", "navigate"] }
36
+ declare type __DtsxStxComponentType = DefineComponent<{ title?: string, pane?: string, searchable?: unknown, searchPlaceholder?: string, storageKey?: string, loadingPane?: string, failedPane?: string, retryPane?: string, presentation?: unknown, className?: string, id?: string, sidebarWidth?: unknown, height?: string }> & { readonly __stxEmits?: ["pane", "search", "navigate"] }
34
37
  export default __dtsx_component__;
@@ -5,6 +5,9 @@ export declare interface SettingsWindowProps {
5
5
  searchable?: boolean
6
6
  searchPlaceholder?: string
7
7
  storageKey?: string
8
+ loadingPane?: string
9
+ failedPane?: string
10
+ retryPane?: string
8
11
  presentation?: 'window' | 'sheet'
9
12
  sidebarWidth?: number
10
13
  height?: string
@@ -31,6 +34,7 @@ export declare interface SettingsPaneProps {
31
34
  keywords?: string
32
35
  parent?: string
33
36
  active?: boolean
37
+ defer?: boolean
34
38
  className?: string
35
39
  }
36
40
  export declare interface SettingsGroupProps {
@@ -4,6 +4,9 @@ export declare interface SettingsWindowOptions {
4
4
  storageKey?: string
5
5
  storage?: SettingsTreeStorage
6
6
  globalKeys?: boolean
7
+ loadingPane?: string
8
+ failedPane?: string
9
+ retryPane?: string
7
10
  }
8
11
  export declare interface SettingsPaneDetail {
9
12
  id: string
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/components",
3
3
  "type": "module",
4
- "version": "0.2.961",
4
+ "version": "0.2.962",
5
5
  "description": "A modern component library built with STX, featuring headwind utility classes and TypeScript syntax highlighting.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -144,8 +144,8 @@
144
144
  "dependencies": {
145
145
  "@iconify-json/f7": "^1.2.2",
146
146
  "@stacksjs/ts-css": "^0.3.11",
147
- "@stacksjs/stx": "0.2.961",
148
- "bun-plugin-stx": "0.2.961",
147
+ "@stacksjs/stx": "0.2.962",
148
+ "bun-plugin-stx": "0.2.962",
149
149
  "ts-syntax-highlighter": "^0.2.20",
150
150
  "ts-video-player": "^0.1.11"
151
151
  },
@@ -1,38 +1,3 @@
1
- <script server>
2
- import { SETTINGS_NATIVE } from './native-theme'
3
-
4
- /*
5
- * <SettingsSidebarGroup>: a run of sidebar items, set a little apart from the
6
- * next. System Settings gives its groups no headings; `label` is there for
7
- * the window that needs one.
8
- *
9
- * On a native host ($native) the gap above the group is a view of its own
10
- * (`data-settings-group-gap`), which the window shows above every group but
11
- * the first one showing: there is no sibling selector to do it.
12
- */
13
- export const label = $props.label || ''
14
- export const className = $props.className || ''
15
- export const T = SETTINGS_NATIVE
16
- </script>
17
-
18
- @if($native)
19
- <div data-settings-group class="{{ T.group }} {{ className }}">
20
- <div data-settings-group-gap class="{{ T.groupGap }} hidden"></div>
21
- @if(label)
22
- <span class="{{ T.groupLabel }}">{{ label }}</span>
23
- @endif
24
- <slot />
25
- </div>
26
- @else
27
- <div data-settings-group role="presentation" class="stx-settings-group {{ className }}">
28
- @if(label)
29
- <div class="stx-settings-group-label" role="presentation">{{ label }}</div>
30
- @endif
31
- <slot />
32
- </div>
33
- @endif
34
-
35
- <style data-native-exclude>
36
1
  :where(:root) {
37
2
  --stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
38
3
  --stx-mac-font-size: 13px;
@@ -101,25 +66,3 @@ export const T = SETTINGS_NATIVE
101
66
  --stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
102
67
  }
103
68
  }
104
-
105
- :where([data-settings-group]) {
106
- --stx-settings-group-gap: 13px;
107
- --stx-settings-item-gap: 2px;
108
- }
109
- .stx-settings-group {
110
- display: flex;
111
- flex-direction: column;
112
- gap: var(--stx-settings-item-gap);
113
- }
114
- .stx-settings-group[hidden] { display: none; }
115
- /* The gap sits above every group but the first one showing, so a search that hides a group hides its gap. */
116
- .stx-settings-group:not([hidden]) ~ .stx-settings-group,
117
- :where([data-stx-scope]):has(> .stx-settings-group:not([hidden])) ~ :where([data-stx-scope]) > .stx-settings-group { margin-top: var(--stx-settings-group-gap); }
118
- .stx-settings-group-label {
119
- padding: 0 8px 3px;
120
- color: var(--stx-mac-ink-secondary);
121
- font-size: var(--stx-mac-font-size-small);
122
- font-weight: 600;
123
- letter-spacing: 0;
124
- }
125
- </style>
@@ -162,76 +162,8 @@ defineExpose({ value: chosen })
162
162
  </div>
163
163
  @endif
164
164
 
165
- <style data-native-exclude>
166
- :where(:root) {
167
- --stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
168
- --stx-mac-font-size: 13px;
169
- --stx-mac-font-size-small: 11px;
170
- --stx-mac-hairline: 0.5px;
171
- --stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
172
- --stx-mac-card-radius: 12px;
173
- --stx-mac-control-radius: 6px;
174
- --stx-mac-row-height: 38px;
175
- --stx-mac-row-inset: 10px;
176
- --stx-mac-sidebar-width: 226px;
177
- --stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
178
- --stx-mac-accent-ink: #ffffff;
179
- --stx-mac-ink: rgba(0, 0, 0, 0.85);
180
- --stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
181
- --stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
182
- --stx-mac-window: #ffffff;
183
- --stx-mac-sidebar: #f2f1f0;
184
- --stx-mac-card: rgba(0, 0, 0, 0.04);
185
- --stx-mac-separator: rgba(0, 0, 0, 0.1);
186
- --stx-mac-hover: rgba(0, 0, 0, 0.05);
187
- --stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
188
- --stx-mac-well: rgba(0, 0, 0, 0.07);
189
- --stx-mac-control: #ffffff;
190
- --stx-mac-control-line: rgba(0, 0, 0, 0.12);
191
- --stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
192
- --stx-mac-switch-on: #34c759;
193
- --stx-mac-knob: #ffffff;
194
- --stx-mac-danger: #ff3b30;
195
- }
196
- :where(.dark) {
197
- --stx-mac-accent: var(--stx-accent, #0a84ff);
198
- --stx-mac-accent-ink: #ffffff;
199
- --stx-mac-ink: rgba(255, 255, 255, 0.85);
200
- --stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
201
- --stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
202
- --stx-mac-window: #1e1e1e;
203
- --stx-mac-sidebar: #2a2a2a;
204
- --stx-mac-card: rgba(255, 255, 255, 0.05);
205
- --stx-mac-separator: rgba(255, 255, 255, 0.1);
206
- --stx-mac-hover: rgba(255, 255, 255, 0.06);
207
- --stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
208
- --stx-mac-well: rgba(255, 255, 255, 0.1);
209
- --stx-mac-control: rgba(255, 255, 255, 0.14);
210
- --stx-mac-control-line: rgba(255, 255, 255, 0.06);
211
- --stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
212
- --stx-mac-switch-on: #30d158;
213
- --stx-mac-knob: #ffffff;
214
- --stx-mac-danger: #ff453a;
215
- }
216
- @media (max-resolution: 1.5dppx) {
217
- :where(:root) {
218
- --stx-mac-hairline: 1px;
219
- }
220
- }
221
- @media (prefers-contrast: more) {
222
- :where(:root) {
223
- --stx-mac-separator: rgba(0, 0, 0, 0.4);
224
- --stx-mac-control-line: rgba(0, 0, 0, 0.5);
225
- --stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
226
- --stx-mac-hairline: 1px;
227
- }
228
- :where(.dark) {
229
- --stx-mac-separator: rgba(255, 255, 255, 0.45);
230
- --stx-mac-control-line: rgba(255, 255, 255, 0.5);
231
- --stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
232
- }
233
- }
234
-
165
+ <style data-native-exclude data-stx-public-style src="../../theme/macos.css"></style>
166
+ <style data-native-exclude data-stx-public-style>
235
167
  :where([data-stx-appearance-picker]) {
236
168
  --stx-appearance-width: 67px;
237
169
  --stx-appearance-height: 44px;
@@ -71,6 +71,9 @@ export const hasLabel = label !== ''
71
71
  * is for a button that has neither.
72
72
  */
73
73
  export const ariaLabel = $props.ariaLabel || $props['aria-label'] || ''
74
+ export const ariaExpanded = String($props.ariaExpanded ?? '')
75
+ export const ariaControls = String($props.ariaControls ?? '')
76
+ export const ariaPressed = String($props.ariaPressed ?? '')
74
77
  export const leftIcon = $props.leftIcon || ''
75
78
  export const rightIcon = $props.rightIcon || ''
76
79
  export const className = $props.className || ''
@@ -245,6 +248,10 @@ const isLoading = useReactiveProp('loading', {{ loading }})
245
248
  // (:ariaLabel="action.label" in a row of icon buttons) stayed on the boxless
246
249
  // scope wrapper and never reached the button, which then had no name at all.
247
250
  const ariaLabelProp = useReactiveProp('ariaLabel', {{ ariaLabel }}, { parse: value => value == null ? '' : String(value) })
251
+ // Parent signals retain their types. Stringify at the button so false is present.
252
+ const ariaExpandedProp = useReactiveProp('ariaExpanded', {{ ariaExpanded }})
253
+ const ariaControlsProp = useReactiveProp('ariaControls', {{ ariaControls }})
254
+ const ariaPressedProp = useReactiveProp('ariaPressed', {{ ariaPressed }})
248
255
  const disabledProp = useReactiveProp('disabled', {{ disabled }})
249
256
 
250
257
  // Loading implies disabled, the same combination the server computes for the
@@ -285,6 +292,12 @@ function onClick(event) {
285
292
  :aria-busy="isLoading() ? 'true' : 'false'"
286
293
  @if(ariaLabel)aria-label="{{ ariaLabel }}"@endif
287
294
  :aria-label="String(ariaLabelProp() ?? '') || null"
295
+ @if(ariaExpanded)aria-expanded="{{ ariaExpanded }}"@endif
296
+ :aria-expanded="String(ariaExpandedProp() ?? '') || null"
297
+ @if(ariaControls)aria-controls="{{ ariaControls }}"@endif
298
+ :aria-controls="String(ariaControlsProp() ?? '') || null"
299
+ @if(ariaPressed)aria-pressed="{{ ariaPressed }}"@endif
300
+ :aria-pressed="String(ariaPressedProp() ?? '') || null"
288
301
  @click="onClick($event)"
289
302
  ><slot /></button>
290
303
  <button
@@ -302,6 +315,12 @@ function onClick(event) {
302
315
  :aria-busy="isLoading() ? 'true' : 'false'"
303
316
  @if(ariaLabel)aria-label="{{ ariaLabel }}"@endif
304
317
  :aria-label="String(ariaLabelProp() ?? '') || null"
318
+ @if(ariaExpanded)aria-expanded="{{ ariaExpanded }}"@endif
319
+ :aria-expanded="String(ariaExpandedProp() ?? '') || null"
320
+ @if(ariaControls)aria-controls="{{ ariaControls }}"@endif
321
+ :aria-controls="String(ariaControlsProp() ?? '') || null"
322
+ @if(ariaPressed)aria-pressed="{{ ariaPressed }}"@endif
323
+ :aria-pressed="String(ariaPressedProp() ?? '') || null"
305
324
  @click="onClick($event)"
306
325
  >
307
326
  <div data-native="ActivityIndicator" :show="isLoading()" class="{{ nativeTintClass }}" :color="platformControls ? null : legacyNativeTint" role="status"></div>
@@ -325,6 +344,12 @@ function onClick(event) {
325
344
  :aria-busy="isLoading() ? 'true' : 'false'"
326
345
  @if(ariaLabel)aria-label="{{ ariaLabel }}"@endif
327
346
  :aria-label="String(ariaLabelProp() ?? '') || null"
347
+ @if(ariaExpanded)aria-expanded="{{ ariaExpanded }}"@endif
348
+ :aria-expanded="String(ariaExpandedProp() ?? '') || null"
349
+ @if(ariaControls)aria-controls="{{ ariaControls }}"@endif
350
+ :aria-controls="String(ariaControlsProp() ?? '') || null"
351
+ @if(ariaPressed)aria-pressed="{{ ariaPressed }}"@endif
352
+ :aria-pressed="String(ariaPressedProp() ?? '') || null"
328
353
  @if(tooltip)title="{{ tooltip }}"@endif
329
354
  @click="onClick($event)"
330
355
  >
@@ -358,6 +383,12 @@ function onClick(event) {
358
383
  :aria-busy="isLoading() ? 'true' : 'false'"
359
384
  @if(ariaLabel)aria-label="{{ ariaLabel }}"@endif
360
385
  :aria-label="String(ariaLabelProp() ?? '') || null"
386
+ @if(ariaExpanded)aria-expanded="{{ ariaExpanded }}"@endif
387
+ :aria-expanded="String(ariaExpandedProp() ?? '') || null"
388
+ @if(ariaControls)aria-controls="{{ ariaControls }}"@endif
389
+ :aria-controls="String(ariaControlsProp() ?? '') || null"
390
+ @if(ariaPressed)aria-pressed="{{ ariaPressed }}"@endif
391
+ :aria-pressed="String(ariaPressedProp() ?? '') || null"
361
392
  @if(tooltip)title="{{ tooltip }}"@endif
362
393
  @click="onClick($event)"
363
394
  >
@@ -423,76 +454,8 @@ function onClick(event) {
423
454
  </button>
424
455
  @endif
425
456
 
426
- <style data-native-exclude>
427
- :where(:root) {
428
- --stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
429
- --stx-mac-font-size: 13px;
430
- --stx-mac-font-size-small: 11px;
431
- --stx-mac-hairline: 0.5px;
432
- --stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
433
- --stx-mac-card-radius: 12px;
434
- --stx-mac-control-radius: 6px;
435
- --stx-mac-row-height: 38px;
436
- --stx-mac-row-inset: 10px;
437
- --stx-mac-sidebar-width: 226px;
438
- --stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
439
- --stx-mac-accent-ink: #ffffff;
440
- --stx-mac-ink: rgba(0, 0, 0, 0.85);
441
- --stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
442
- --stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
443
- --stx-mac-window: #ffffff;
444
- --stx-mac-sidebar: #f2f1f0;
445
- --stx-mac-card: rgba(0, 0, 0, 0.04);
446
- --stx-mac-separator: rgba(0, 0, 0, 0.1);
447
- --stx-mac-hover: rgba(0, 0, 0, 0.05);
448
- --stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
449
- --stx-mac-well: rgba(0, 0, 0, 0.07);
450
- --stx-mac-control: #ffffff;
451
- --stx-mac-control-line: rgba(0, 0, 0, 0.12);
452
- --stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
453
- --stx-mac-switch-on: #34c759;
454
- --stx-mac-knob: #ffffff;
455
- --stx-mac-danger: #ff3b30;
456
- }
457
- :where(.dark) {
458
- --stx-mac-accent: var(--stx-accent, #0a84ff);
459
- --stx-mac-accent-ink: #ffffff;
460
- --stx-mac-ink: rgba(255, 255, 255, 0.85);
461
- --stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
462
- --stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
463
- --stx-mac-window: #1e1e1e;
464
- --stx-mac-sidebar: #2a2a2a;
465
- --stx-mac-card: rgba(255, 255, 255, 0.05);
466
- --stx-mac-separator: rgba(255, 255, 255, 0.1);
467
- --stx-mac-hover: rgba(255, 255, 255, 0.06);
468
- --stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
469
- --stx-mac-well: rgba(255, 255, 255, 0.1);
470
- --stx-mac-control: rgba(255, 255, 255, 0.14);
471
- --stx-mac-control-line: rgba(255, 255, 255, 0.06);
472
- --stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
473
- --stx-mac-switch-on: #30d158;
474
- --stx-mac-knob: #ffffff;
475
- --stx-mac-danger: #ff453a;
476
- }
477
- @media (max-resolution: 1.5dppx) {
478
- :where(:root) {
479
- --stx-mac-hairline: 1px;
480
- }
481
- }
482
- @media (prefers-contrast: more) {
483
- :where(:root) {
484
- --stx-mac-separator: rgba(0, 0, 0, 0.4);
485
- --stx-mac-control-line: rgba(0, 0, 0, 0.5);
486
- --stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
487
- --stx-mac-hairline: 1px;
488
- }
489
- :where(.dark) {
490
- --stx-mac-separator: rgba(255, 255, 255, 0.45);
491
- --stx-mac-control-line: rgba(255, 255, 255, 0.5);
492
- --stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
493
- }
494
- }
495
-
457
+ <style data-native-exclude data-stx-public-style src="../../theme/macos.css"></style>
458
+ <style data-native-exclude data-stx-public-style data-stx-shared-style>
496
459
  .stx-mac-button {
497
460
  --stx-mac-button-pressed: color-mix(in srgb, var(--stx-mac-ink) 8%, transparent);
498
461
  display: inline-flex;
@@ -4,6 +4,8 @@ import { createPropValidator, PropTypes } from '../../utils/prop-validation'
4
4
 
5
5
  export { default as Button } from './Button.stx'
6
6
 
7
+ type AriaBoolean = boolean | 'true' | 'false'
8
+
7
9
  export interface ButtonProps {
8
10
  variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger'
9
11
  /**
@@ -21,6 +23,10 @@ export interface ButtonProps {
21
23
  label?: string
22
24
  /** Compatibility alias for native Button text; a nonempty label takes precedence. */
23
25
  text?: string
26
+ ariaExpanded?: AriaBoolean | null
27
+ /** Space-separated IDs of elements controlled by this button. */
28
+ ariaControls?: string | null
29
+ ariaPressed?: AriaBoolean | 'mixed' | null
24
30
  leftIcon?: string
25
31
  rightIcon?: string
26
32
  className?: string
@@ -40,6 +46,9 @@ export const buttonPropSchema: PropSchema = {
40
46
  fullWidth: PropTypes.boolean,
41
47
  label: PropTypes.string,
42
48
  text: PropTypes.string,
49
+ ariaExpanded: PropTypes.oneOf([true, false, 'true', 'false']),
50
+ ariaControls: PropTypes.string,
51
+ ariaPressed: PropTypes.oneOf([true, false, 'true', 'false', 'mixed']),
43
52
  leftIcon: PropTypes.string,
44
53
  rightIcon: PropTypes.string,
45
54
  className: PropTypes.string,