@stacksjs/components 0.2.890 → 0.2.891

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/{AppearancePicker-61r20jpp.stx → AppearancePicker-30fetv0a.stx} +45 -0
  2. package/dist/{Button-r8q6v9m3.stx → Button-ghdfqwg0.stx} +54 -1
  3. package/dist/{Checkbox-52mhrzkz.stx → Checkbox-355qsbwd.stx} +13 -3
  4. package/dist/{PasswordInput-z2g5ha65.stx → PasswordInput-hhq64qzr.stx} +15 -1
  5. package/dist/{SegmentedControl-7q0t8c9s.stx → SegmentedControl-b93n9n2v.stx} +9 -1
  6. package/dist/{Select-ygzchedx.stx → Select-p8mgxthn.stx} +13 -2
  7. package/dist/{SettingsGroup-dkae46k5.stx → SettingsGroup-g1hnxp1p.stx} +52 -0
  8. package/dist/{SettingsPane-jbd1gbdt.stx → SettingsPane-9svk1w3e.stx} +21 -2
  9. package/dist/{SettingsPaneHeader-f0cvkqs7.stx → SettingsPaneHeader-am42srhp.stx} +24 -0
  10. package/dist/{SettingsRow-4cxbsf1q.stx → SettingsRow-kgda3nv1.stx} +63 -0
  11. package/dist/{SettingsSidebarGroup-p2ygv5yy.stx → SettingsSidebarGroup-4ag5qjpw.stx} +17 -0
  12. package/dist/{SettingsSidebarItem-x8fsn3w5.stx → SettingsSidebarItem-ga2jxq53.stx} +33 -0
  13. package/dist/SettingsUpdateRow-ajpnqx8a.stx +143 -0
  14. package/dist/{SettingsWindow-mm490ymt.stx → SettingsWindow-586aps08.stx} +186 -19
  15. package/dist/{Switch-ga9ap8n8.stx → Switch-vd8k23sr.stx} +4 -1
  16. package/dist/{TextInput-m4a4kpfy.stx → TextInput-492d1c3n.stx} +15 -2
  17. package/dist/component-api/component-api.js +21 -3
  18. package/dist/index.js +24 -24
  19. package/dist/settings/settings.js +371 -15
  20. package/dist/ui/appearance-picker/AppearancePicker.d.ts +1 -0
  21. package/dist/ui/button/Button.d.ts +16 -0
  22. package/dist/ui/checkbox/Checkbox.d.ts +7 -0
  23. package/dist/ui/input/PasswordInput.d.ts +10 -0
  24. package/dist/ui/input/TextInput.d.ts +11 -0
  25. package/dist/ui/segmented-control/SegmentedControl.d.ts +7 -0
  26. package/dist/ui/settings/SettingsGroup.d.ts +5 -0
  27. package/dist/ui/settings/SettingsPane.d.ts +4 -0
  28. package/dist/ui/settings/SettingsPaneHeader.d.ts +10 -1
  29. package/dist/ui/settings/SettingsRow.d.ts +20 -1
  30. package/dist/ui/settings/SettingsSidebarGroup.d.ts +5 -0
  31. package/dist/ui/settings/SettingsSidebarItem.d.ts +11 -1
  32. package/dist/ui/settings/SettingsUpdateRow.d.ts +34 -0
  33. package/dist/ui/settings/SettingsWindow.d.ts +12 -0
  34. package/dist/ui/settings/index.d.ts +18 -0
  35. package/dist/ui/settings/native-theme.d.ts +130 -0
  36. package/dist/ui/settings/native.d.ts +51 -0
  37. package/dist/ui/settings/settings.d.ts +5 -2
  38. package/dist/ui/settings/update.d.ts +45 -0
  39. package/dist/utils/component-api.d.ts +2 -0
  40. package/package.json +3 -3
  41. package/src/ui/appearance-picker/AppearancePicker.stx +45 -0
  42. package/src/ui/appearance-picker/README.md +4 -0
  43. package/src/ui/button/Button.stx +54 -1
  44. package/src/ui/checkbox/Checkbox.stx +13 -3
  45. package/src/ui/input/PasswordInput.stx +15 -1
  46. package/src/ui/input/TextInput.stx +15 -2
  47. package/src/ui/segmented-control/SegmentedControl.stx +9 -1
  48. package/src/ui/select/Select.stx +13 -2
  49. package/src/ui/settings/README.md +210 -15
  50. package/src/ui/settings/SettingsGroup.stx +52 -0
  51. package/src/ui/settings/SettingsPane.stx +21 -2
  52. package/src/ui/settings/SettingsPaneHeader.stx +24 -0
  53. package/src/ui/settings/SettingsRow.stx +63 -0
  54. package/src/ui/settings/SettingsSidebarGroup.stx +17 -0
  55. package/src/ui/settings/SettingsSidebarItem.stx +33 -0
  56. package/src/ui/settings/SettingsUpdateRow.stx +143 -0
  57. package/src/ui/settings/SettingsWindow.stx +186 -19
  58. package/src/ui/settings/index.ts +31 -3
  59. package/src/ui/settings/native-theme.ts +169 -0
  60. package/src/ui/settings/native.ts +456 -0
  61. package/src/ui/settings/settings.ts +5 -2
  62. package/src/ui/settings/update.ts +119 -0
  63. package/src/ui/switch/Switch.stx +4 -1
  64. package/src/utils/component-api.ts +36 -3
@@ -1,3 +1,4 @@
1
+ import { settingsNativeGlyph } from './native-theme';
1
2
  import type { DefineComponent } from '@stacksjs/stx';
2
3
  declare const __dtsx_component__: __DtsxStxComponentType;
3
4
  /*
@@ -7,6 +8,11 @@ declare const __dtsx_component__: __DtsxStxComponentType;
7
8
  *
8
9
  * It only draws. The shell selects it, gives it its place in the tab order
9
10
  * and links it to its pane.
11
+ *
12
+ * On a native host ($native) the glyph is an SF Symbol, named by `symbol`
13
+ * (`gearshape.fill`): an Iconify class is CSS, which a native host has none
14
+ * of. `icon` stays the web's. The selected row is the blue pill, drawn from
15
+ * `aria-selected`, which the window sets on the row and on what is inside it.
10
16
  * @defaultValue `['grey', 'blue', 'red', 'orange', 'yellow', 'green', 'indigo', 'purple', 'pink', 'ink']`
11
17
  */
12
18
  declare const TONES: string[];
@@ -18,5 +24,9 @@ export declare const badge: boolean;
18
24
  /* Words a search should find this item by, beyond its label. */
19
25
  export declare const keywords: unknown;
20
26
  export declare const className: unknown;
21
- declare type __DtsxStxComponentType = DefineComponent<{ id?: string, label?: string, icon?: string, tone?: unknown, badge?: boolean, keywords?: string, className?: string }>;
27
+ export declare const symbol: unknown;
28
+ export declare const T: unknown;
29
+ export declare const tileFill: unknown;
30
+ export declare const glyphInk: ReturnType<typeof settingsNativeGlyph>;
31
+ declare type __DtsxStxComponentType = DefineComponent<{ id?: string, label?: string, icon?: string, tone?: unknown, badge?: boolean, keywords?: string, className?: string, symbol?: string }>;
22
32
  export default __dtsx_component__;
@@ -0,0 +1,34 @@
1
+ import type { DefineComponent } from '@stacksjs/stx';
2
+ declare const __dtsx_component__: __DtsxStxComponentType;
3
+ /*
4
+ * <SettingsUpdateRow>: the row every app that updates itself needs. The app
5
+ * and its version, a sentence about where the update stands, and the one
6
+ * button that moves it on: Check Now, Download and Install (with its
7
+ * progress), or Restart to Update.
8
+ *
9
+ * <SettingsGroup header="Software Update">
10
+ * <SettingsUpdateRow appName="Library" :status="status()"
11
+ * @check="craft.updater.check()" @install="craft.updater.install()"
12
+ * @relaunch="craft.updater.relaunch()" />
13
+ * </SettingsGroup>
14
+ *
15
+ * `status` is what the updater reports (`craft.updater`'s `UpdateStatus`, or
16
+ * a web app's own of the same shape). The row does nothing on its own: it
17
+ * says what the status says and emits `check`, `install` or `relaunch`. What
18
+ * it says for each state is `settingsUpdateView` in ./update.
19
+ *
20
+ * It is a <SettingsRow> holding <Button appearance="mac">, so it is the same
21
+ * row on the web and on a native host, and the window's search finds it
22
+ * (`setting`, default `software-update`).
23
+ */
24
+ export declare const appName: unknown;
25
+ export declare const status: boolean;
26
+ export declare const setting: unknown;
27
+ export declare const keywords: unknown;
28
+ export declare const className: unknown;
29
+ export declare const served: unknown;
30
+ export declare const progressClasses: unknown;
31
+ declare const current: unknown;
32
+ declare const view: ReturnType<typeof derived>;
33
+ declare type __DtsxStxComponentType = DefineComponent<{ appName?: string, status?: unknown, setting?: string, keywords?: string, className?: string }> & { readonly __stxEmits?: ["check", "install", "relaunch"], readonly __stxExposed?: { view: typeof view } }
34
+ export default __dtsx_component__;
@@ -18,5 +18,17 @@ export declare const settingsId: unknown;
18
18
  declare const sidebarWidth: unknown;
19
19
  declare const height: unknown;
20
20
  export declare const rootStyle: unknown;
21
+ /*
22
+ * On a native host ($native) the window is two columns of the host's own
23
+ * views, drawn from the class lists in ./native-theme: the sidebar on the
24
+ * system's sidebar material with the system's search field, and the detail
25
+ * column under back, forward and the pane's name. The window fills what it is
26
+ * given, so `presentation` and `height` are the window's own business there.
27
+ */
28
+ export declare const T: unknown;
29
+ export declare const SYMBOLS: unknown;
30
+ export declare const nativeSidebarWidth: boolean;
31
+ export declare const hasAccount: unknown;
32
+ export declare const wash: unknown;
21
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"] }
22
34
  export default __dtsx_component__;
@@ -1,3 +1,4 @@
1
+ import type { SettingsUpdateStatus } from './update';
1
2
  export declare interface SettingsWindowProps {
2
3
  title?: string
3
4
  pane?: string
@@ -18,6 +19,7 @@ export declare interface SettingsSidebarItemProps {
18
19
  id: string
19
20
  label: string
20
21
  icon?: string
22
+ symbol?: string
21
23
  tone?: SettingsTone
22
24
  badge?: string | number
23
25
  keywords?: string
@@ -41,6 +43,7 @@ export declare interface SettingsRowProps {
41
43
  label: string
42
44
  description?: string
43
45
  icon?: string
46
+ symbol?: string
44
47
  tone?: SettingsTone
45
48
  setting?: string
46
49
  keywords?: string
@@ -55,11 +58,22 @@ export declare interface SettingsRowProps {
55
58
  }
56
59
  export declare interface SettingsPaneHeaderProps {
57
60
  icon?: string
61
+ symbol?: string
58
62
  tone?: SettingsTone
59
63
  title: string
60
64
  description?: string
61
65
  className?: string
62
66
  }
67
+ export declare interface SettingsUpdateRowProps {
68
+ appName?: string
69
+ status?: Partial<SettingsUpdateStatus> | null
70
+ setting?: string
71
+ keywords?: string
72
+ className?: string
73
+ onCheck?: () => void
74
+ onInstall?: () => void
75
+ onRelaunch?: () => void
76
+ }
63
77
  /** The colour of an icon tile, in the sidebar or leading a row. */
64
78
  export type SettingsTone = 'grey' | 'blue' | 'red' | 'orange' | 'yellow' | 'green' | 'indigo' | 'purple' | 'pink' | 'ink';
65
79
  export * from './core';
@@ -69,5 +83,9 @@ export { default as SettingsPaneHeader } from './SettingsPaneHeader';
69
83
  export { default as SettingsRow } from './SettingsRow';
70
84
  export { default as SettingsSidebarGroup } from './SettingsSidebarGroup';
71
85
  export { default as SettingsSidebarItem } from './SettingsSidebarItem';
86
+ export { default as SettingsUpdateRow } from './SettingsUpdateRow';
72
87
  export { default as SettingsWindow } from './SettingsWindow';
88
+ export * from './native';
89
+ export * from './native-theme';
90
+ export * from './update';
73
91
  export * from './view';
@@ -0,0 +1,130 @@
1
+ /** The glyph on a tile: white, and dark on the light `ink` tile of a dark window. */
2
+ export declare function settingsNativeGlyph(tone: string): string;
3
+ /**
4
+ * What the Settings components are drawn with on a native host.
5
+ *
6
+ * On the web the look is the `--stx-mac-*` custom properties and each
7
+ * component's stylesheet. A native host (Craft's AppKit host) has neither: it
8
+ * draws views from class lists. Every size, padding, radius and colour the
9
+ * native branches use is in this file and nowhere else, so matching a real
10
+ * System Settings window is a matter of editing one place.
11
+ *
12
+ * The numbers are the web look's own (`src/utils/mac-theme.ts` and the
13
+ * components' stylesheets), which were measured from System Settings on
14
+ * macOS 26. A colour is written as a hex with its dark twin, the way the
15
+ * other shared components spell a native colour: `#000000/85` is black at
16
+ * 85%, which the host receives as `#000000d9`.
17
+ */
18
+ /** The tile colours, light and dark. The same ten tones as the web. */
19
+ export declare const SETTINGS_NATIVE_TONES: Readonly<Record<string, string>>;
20
+ /** Text colours. */
21
+ declare const INK: 'text-[#000000]/85 dark:text-[#ffffff]/85';
22
+ declare const INK_SECONDARY: 'text-[#000000]/50 dark:text-[#ffffff]/55';
23
+ declare const INK_TERTIARY: 'text-[#000000]/26 dark:text-[#ffffff]/25';
24
+ declare const DANGER: 'text-[#ff3b30] dark:text-[#ff453a]';
25
+ declare const ACCENT_TEXT: 'text-[#007aff] dark:text-[#0a84ff]';
26
+ export declare const SETTINGS_NATIVE: {
27
+ /** The root. Not named `window`: a template's evaluator refuses that word. */
28
+ shell: 'flex-1 flex-row';
29
+ /** The sidebar column. Its width is `sidebarWidth` (226) and its fill sits under the host's sidebar material. */
30
+ sidebar: 'flex-col bg-[#f2f1f0] dark:bg-[#2a2a2a]';
31
+ sidebarWidth: 226;
32
+ /** The AppKit material drawn behind the sidebar (`material` on the host's box). */
33
+ sidebarMaterial: 'sidebar';
34
+ /** Room above the search field: the window buttons sit over the sidebar of a titlebar-less window. */
35
+ sidebarTop: 'pt-[38px] px-[9px] pb-[6px]';
36
+ /** The search field: the system's own search field at this height. */
37
+ search: 'h-[28px] text-[13px]';
38
+ /** The scrolling list under the search field. */
39
+ nav: 'flex-1 flex-col px-[9px] pb-[12px]';
40
+ account: 'mt-[7px]';
41
+ list: 'flex-col pt-[7px]';
42
+ /** A setting a search found: its label over the name of its pane. */
43
+ results: 'flex-col gap-[2px] pt-[7px]';
44
+ result: 'flex-col justify-center min-h-[38px] px-[8px] py-[4px] rounded-[8px] hover:bg-[#000000]/5 dark:hover:bg-[#ffffff]/6';
45
+ resultLabel: string;
46
+ resultPane: string;
47
+ empty: string;
48
+ group: 'flex-col gap-[2px]';
49
+ /** The gap above every group but the first one showing: with the 2pt between a group's rows, 13pt. */
50
+ groupGap: 'h-[11px]';
51
+ groupLabel: string;
52
+ /** One row: 30pt tall, the selected one a blue pill with 8pt corners. */
53
+ item: string;
54
+ itemTile: 'h-[20px] w-[20px] rounded-[5.5px] items-center justify-center';
55
+ itemGlyph: 'h-[13px] w-[13px]';
56
+ itemLabel: string;
57
+ itemBadge: string;
58
+ detail: 'flex-1 flex-col bg-[#ffffff] dark:bg-[#1e1e1e]';
59
+ /** Back, forward and the open pane's name. */
60
+ toolbar: 'flex-row items-center gap-[12px] h-[52px] pl-[8px] pr-[16px]';
61
+ history: 'flex-row items-center';
62
+ historyButton: string;
63
+ /** The pane's name, large, as System Settings titles a pane. */
64
+ title: string;
65
+ body: 'flex-1 flex-col';
66
+ /** One pane: it scrolls on its own, and its content is inset by this padding. */
67
+ pane: 'flex-1';
68
+ paneContent: 'flex-col px-[20px] pt-[11px] pb-[20px]';
69
+ hero: string;
70
+ heroTile: 'h-[48px] w-[48px] rounded-[12px] items-center justify-center';
71
+ heroGlyph: 'h-[30px] w-[30px]';
72
+ heroTitle: string;
73
+ heroDescription: string;
74
+ heroExtra: 'mt-[8px] flex-col items-center';
75
+ section: 'flex-col mb-[10px]';
76
+ sectionHeader: string;
77
+ card: string;
78
+ sectionFooter: string;
79
+ /** The hairline above every row but the first, inset on both sides. */
80
+ rowRule: string;
81
+ row: 'flex-row items-center gap-[10px] min-h-[38px] px-[10px]';
82
+ /** A navigation row with a tile is a little taller, as System Settings draws it. */
83
+ rowTall: 'min-h-[44px]';
84
+ rowMultiline: 'items-start';
85
+ rowStacked: 'flex-col items-stretch gap-[4px] min-h-[38px] px-[10px]';
86
+ rowPressed: 'active:bg-[#000000]/5 dark:active:bg-[#ffffff]/6';
87
+ /** The wash a found row wears for a moment: 20% of the accent. */
88
+ rowWash: {
89
+ light: '#007aff33';
90
+ dark: '#0a84ff33'
91
+ };
92
+ rowTile: 'h-[24px] w-[24px] rounded-[6px] items-center justify-center';
93
+ rowTileMultiline: 'mt-[10px]';
94
+ rowGlyph: 'h-[15px] w-[15px]';
95
+ rowText: 'flex-1 flex-col justify-center py-[7px]';
96
+ rowTextMultiline: 'flex-1 flex-col py-[10px]';
97
+ rowTextStacked: 'flex-col pt-[10px]';
98
+ rowLabel: string;
99
+ rowLabelDestructive: string;
100
+ rowDescription: string;
101
+ rowControl: 'flex-row items-center justify-end gap-[8px]';
102
+ rowControlMultiline: 'flex-row items-center justify-end gap-[8px] py-[10px]';
103
+ rowControlStacked: 'flex-col items-stretch pb-[7px]';
104
+ rowValue: string;
105
+ rowChevron: string;
106
+ rowDisabled: 'opacity-50';
107
+ appearance: 'flex-row gap-[14px]';
108
+ appearanceOption: 'flex-col items-center gap-[5px]';
109
+ /** The picture's frame: a ring in the accent around the chosen one. */
110
+ appearanceFrame: 'p-[3px] rounded-[9px] border-2 border-transparent aria-checked:border-[#007aff] dark:aria-checked:border-[#0a84ff]';
111
+ appearanceThumb: 'h-[44px] w-[67px] flex-row rounded-[6px] overflow-hidden';
112
+ appearanceLight: 'flex-1 bg-[#e9e9eb]';
113
+ appearanceDark: 'flex-1 bg-[#2c2c2e]';
114
+ appearanceCaption: string;
115
+ updateStatus: string;
116
+ updateError: string;
117
+ updateProgress: string;
118
+ /** Text colours, for a component that needs one outside the lists above. */
119
+ ink: typeof INK;
120
+ inkSecondary: typeof INK_SECONDARY;
121
+ inkTertiary: typeof INK_TERTIARY;
122
+ danger: typeof DANGER;
123
+ accentText: typeof ACCENT_TEXT
124
+ };
125
+ /** SF Symbols the components draw themselves. */
126
+ export declare const SETTINGS_NATIVE_SYMBOLS: {
127
+ back: 'chevron.left';
128
+ forward: 'chevron.right';
129
+ disclosure: 'chevron.right'
130
+ };
@@ -0,0 +1,51 @@
1
+ import type { SettingsNavigateDetail, SettingsPaneDetail, SettingsSearchDetail } from './view';
2
+ /** The part of stx's host adapter (`window.stx._host`) the window uses. */
3
+ export declare interface SettingsTreeHost<N = unknown> {
4
+ parent: (node: N) => N | null
5
+ descendants: (node: N) => N[]
6
+ getAttribute: (node: N, name: string) => string | null
7
+ setAttribute: (node: N, name: string, value: unknown) => void
8
+ removeAttribute: (node: N, name: string) => void
9
+ setStyle: (node: N, value: unknown) => void
10
+ listen: (node: N, event: string, handler: (payload?: unknown) => void) => (() => void)
11
+ observeChildren: (node: N, callback: () => void) => (() => void)
12
+ }
13
+ /** Where the open pane is remembered. On a native host, the app's storage. */
14
+ export declare interface SettingsTreeStorage {
15
+ get: (name: string) => string | null
16
+ set: (name: string, value: string) => void
17
+ }
18
+ export declare interface SettingsTreeOptions {
19
+ pane?: string
20
+ storageKey?: string
21
+ storage?: SettingsTreeStorage
22
+ wash?: () => string
23
+ }
24
+ /** What the shell draws from signals. */
25
+ export declare interface SettingsTreeState {
26
+ pane: string
27
+ title: string
28
+ canGoBack: boolean
29
+ canGoForward: boolean
30
+ query: string
31
+ searching: boolean
32
+ results: Array<{ position: number, label: string, pane: string }>
33
+ empty: boolean
34
+ }
35
+ export declare interface SettingsTreeCallbacks {
36
+ onPane?: (detail: SettingsPaneDetail) => void
37
+ onSearch?: (detail: SettingsSearchDetail) => void
38
+ onNavigate?: (detail: SettingsNavigateDetail) => void
39
+ onState?: (state: SettingsTreeState) => void
40
+ }
41
+ export declare class SettingsWindowTree<N = unknown> {
42
+ constructor(tree: SettingsTreeHost<N>, root: N, options?: SettingsTreeOptions, callbacks?: SettingsTreeCallbacks);
43
+ getPane(): string;
44
+ showPane(id: string): boolean;
45
+ revealSetting(id: string): boolean;
46
+ back(): void;
47
+ forward(): void;
48
+ search(query: string): void;
49
+ chooseResult(position: number): void;
50
+ destroy(): void;
51
+ }
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * The Settings window without its stx templates.
3
3
  *
4
- * `@stacksjs/components/settings`. What the window decides (`./core`, no DOM)
5
- * and the view that applies it to any markup following the DOM contract.
4
+ * `@stacksjs/components/settings`. What the window decides (`./core`, no DOM),
5
+ * the view that applies it to any markup following the DOM contract, the
6
+ * same window over a native host's tree of views, and what an update row says.
6
7
  */
7
8
  export * from './core';
9
+ export * from './native';
10
+ export * from './update';
8
11
  export * from './view';
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The row for `status`.
3
+ *
4
+ * No status yet (the host has not answered) is the app's name and nothing to
5
+ * press. An app that cannot replace itself (`selfUpdating: false`: a Mac App
6
+ * Store copy, a read-only volume) is never offered an install; it says why.
7
+ */
8
+ export declare function settingsUpdateView(status: Partial<SettingsUpdateStatus> | null | undefined, appName?: string): SettingsUpdateView;
9
+ /** The words on the button for each action. */
10
+ export declare const SETTINGS_UPDATE_LABELS: Readonly<Record<SettingsUpdateAction, string>>;
11
+ /** The status an updater reports. The shape of `craft.updater`'s `UpdateStatus`. */
12
+ export declare interface SettingsUpdateStatus {
13
+ currentVersion: string
14
+ state: SettingsUpdateState
15
+ selfUpdating: boolean
16
+ reason?: string
17
+ version?: string
18
+ notes?: string
19
+ publishedAt?: string
20
+ progress?: number
21
+ error?: string
22
+ lastCheckedAt?: string
23
+ }
24
+ export declare interface SettingsUpdateView {
25
+ title: string
26
+ sentence: string
27
+ action: SettingsUpdateAction | null
28
+ actionLabel: string
29
+ busy: boolean
30
+ progress: string
31
+ failed: boolean
32
+ }
33
+ /**
34
+ * What an update row says, without a template.
35
+ *
36
+ * An app that updates itself shows the same row everywhere: its name and
37
+ * version, a sentence about where the update stands, and the one button that
38
+ * moves it on. `settingsUpdateView` turns the status the host reports
39
+ * (`craft.updater`, or a web app's own updater) into those words, so the row
40
+ * is a function of the status and nothing else.
41
+ */
42
+ /** Where an update stands. The states `craft.updater` reports. */
43
+ export type SettingsUpdateState = 'unavailable' | 'idle' | 'checking' | 'current' | 'available' | 'downloading' | 'installing' | 'installed' | 'error';
44
+ /** What the row's button does: the event the row emits when it is pressed. */
45
+ export type SettingsUpdateAction = 'check' | 'install' | 'relaunch';
@@ -1,3 +1,5 @@
1
+ /** Answer `componentApi(id)` with `api` on a host that has no DOM. Returns the undo. */
2
+ export declare function registerComponentApi(id: string, api: unknown): () => void;
1
3
  export declare function componentApi<T = ExposedMethods>(target: Element | string | null | undefined): T | null;
2
4
  /** What a component exposes when nothing more precise is known: methods by name. */
3
5
  // eslint-disable-next-line ts/no-explicit-any
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/components",
3
3
  "type": "module",
4
- "version": "0.2.890",
4
+ "version": "0.2.891",
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",
@@ -129,8 +129,8 @@
129
129
  "dependencies": {
130
130
  "@iconify-json/f7": "^1.2.2",
131
131
  "@stacksjs/ts-css": "^0.3.11",
132
- "@stacksjs/stx": "0.2.890",
133
- "bun-plugin-stx": "0.2.890",
132
+ "@stacksjs/stx": "0.2.891",
133
+ "bun-plugin-stx": "0.2.891",
134
134
  "ts-syntax-highlighter": "^0.2.20",
135
135
  "ts-video-player": "^0.1.11"
136
136
  },
@@ -1,4 +1,6 @@
1
1
  <script server>
2
+ import { SETTINGS_NATIVE } from '../settings/native-theme'
3
+
2
4
  /*
3
5
  * <AppearancePicker>: light, dark, or whatever the system is, picked from
4
6
  * three small pictures of a desktop, as System Settings offers it.
@@ -13,6 +15,11 @@
13
15
  *
14
16
  * A radio group: one tab stop, arrow keys move the choice. The pictures are
15
17
  * drawn in CSS and say nothing to a screen reader; the captions do.
18
+ *
19
+ * On a native host ($native) each choice is a pressable picture drawn from
20
+ * views (a light half, a dark half, both for Auto) with the chosen one ringed
21
+ * in the accent, from the class lists in ../settings/native-theme. There are
22
+ * no arrow keys there: a native host reports no key presses to a screen.
16
23
  */
17
24
  const MODES = ['light', 'dark', 'auto']
18
25
  export const value = MODES.includes($props.value) ? $props.value : 'auto'
@@ -21,6 +28,7 @@ export const label = $props.label || ''
21
28
  export const disabled = $bool($props.disabled)
22
29
  export const pickerId = $props.id || `appearance-picker-${$uid}`
23
30
  export const className = $props.className || ''
31
+ export const T = SETTINGS_NATIVE
24
32
  </script>
25
33
 
26
34
  <script client>
@@ -89,9 +97,45 @@ function onKey(event, mode) {
89
97
  if (picture) picture.focus()
90
98
  }
91
99
 
100
+ // A native host: which half of the picture is light and which dark.
101
+ const lightHalf = {{ $native ? T.appearanceLight : '' }}
102
+ const darkHalf = {{ $native ? T.appearanceDark : '' }}
103
+
92
104
  defineExpose({ value: chosen })
93
105
  </script>
94
106
 
107
+ @if($native)
108
+ <div
109
+ id="{{ pickerId }}"
110
+ role="radiogroup"
111
+ data-stx-appearance-picker
112
+ @if(label)aria-label="{{ label }}"@endif
113
+ :aria-label="groupLabel() || null"
114
+ class="{{ T.appearance }} {{ className }}"
115
+ :class="{ 'opacity-50': isDisabled() }"
116
+ >
117
+ <div
118
+ data-native="Pressable"
119
+ :for="mode in modes()"
120
+ :key="mode.value"
121
+ role="radio"
122
+ class="{{ T.appearanceOption }}"
123
+ :data-mode="mode.value"
124
+ :aria-label="mode.label"
125
+ :aria-checked="isOn(mode) ? 'true' : 'false'"
126
+ @click="choose(mode)"
127
+ >
128
+ <div class="{{ T.appearanceFrame }}" :aria-checked="isOn(mode) ? 'true' : 'false'">
129
+ <div class="{{ T.appearanceThumb }}">
130
+ <div :class="mode.value === 'dark' ? darkHalf : lightHalf"></div>
131
+ <div :class="mode.value === 'light' ? lightHalf : darkHalf"></div>
132
+ </div>
133
+ </div>
134
+ <span class="{{ T.appearanceCaption }}" :text="mode.label"></span>
135
+ </div>
136
+ </div>
137
+ @else
138
+
95
139
  <div
96
140
  id="{{ pickerId }}"
97
141
  role="radiogroup"
@@ -116,6 +160,7 @@ defineExpose({ value: chosen })
116
160
  @keydown="onKey($event, mode)"
117
161
  ><span class="stx-appearance-frame" aria-hidden="true"><span class="stx-appearance-thumb"><span class="stx-appearance-scene" data-scheme="light"></span><span class="stx-appearance-scene" data-scheme="dark"></span></span></span><span class="stx-appearance-caption" :text="mode.label"></span></button>
118
162
  </div>
163
+ @endif
119
164
 
120
165
  <style data-native-exclude>
121
166
  :where(:root) {
@@ -59,3 +59,7 @@ Each picture is 67 by 44 points: wallpaper under a menu bar, a small window with
59
59
  | `--stx-appearance-ring`, `--stx-appearance-ring-gap` | `2.5px`, `2px` |
60
60
  | `--stx-appearance-ring-color` | the accent |
61
61
  | `--stx-appearance-caption-gap` | `5px` |
62
+
63
+ ## On a native host
64
+
65
+ On a native host (Craft's AppKit host) each choice is a pressable picture drawn from the host's views: a light half and a dark half, both light for `light`, both dark for `dark`, with the chosen one ringed in the system blue and its caption beneath. `value`, `v-model:value`, `options`, `label`, `disabled` and `@change` are the same. There are no arrow keys there, since a native host reports no key presses to a screen, and the picture is two flat halves rather than the web's drawing. Its sizes and colours are the `appearance*` entries of `settings/native-theme.ts`.
@@ -181,6 +181,21 @@ export const nativeButtonClasses = `flex-row items-center justify-center ${nativ
181
181
  export const nativeTextClasses = `font-semibold ${nativeSize.text} ${nativeVariant.text}`
182
182
  export const legacyNativeTint = variant === 'primary' || variant === 'danger' ? '#ffffff' : '#007aff'
183
183
  export const nativeTintClass = nativeVariant.text
184
+ /*
185
+ * On a Mac (Craft's AppKit host) a button is the system's push button, an
186
+ * NSButton the host draws, not the phone's filled one: 13pt words on the
187
+ * standard bezel. The host knows four looks by name and only a written
188
+ * `variant` asks for one: `primary` is the default (accent) button, `danger`
189
+ * the destructive one, `ghost` a borderless one, `toolbar` the toolbar's.
190
+ * Anything else, and no variant at all, is the plain push button, as
191
+ * `appearance="mac"` has it on the web, because on a Mac most buttons are.
192
+ * Which host this is is only known on the device, so both are in the screen
193
+ * and the client script keeps one.
194
+ */
195
+ const desktopVariants = ['primary', 'danger', 'ghost', 'toolbar']
196
+ export const desktopVariant = desktopVariants.includes($props.variant) ? $props.variant : ''
197
+ /** `title` names the button only when nothing in the slot does: beside content it is the tooltip. */
198
+ export const titleNames = !slotWords
184
199
  </script>
185
200
 
186
201
  <script client>
@@ -213,7 +228,18 @@ const labelProp = useReactiveProp('label', {{ label }}, { parse: value => value
213
228
  // Preserve native Button's text prop when the same shared file is selected.
214
229
  // Read it as a prop, not a root text binding that would erase icons/spinners.
215
230
  const textProp = useReactiveProp('text', '', { parse: value => value == null ? '' : String(value) })
216
- const labelText = derived(() => labelProp() || textProp())
231
+ /*
232
+ * `title` is the desktop spelling of the words (stacksjs/stx#2091), and it is
233
+ * live as `label` is: `:title="busy() ? 'One moment' : 'Sign In'"` is a
234
+ * binding the server never sees, so read once there it was no words at all
235
+ * and the button drew empty. Beside slot content it stays the tooltip.
236
+ */
237
+ const titleNames = {{ titleNames }}
238
+ const titleProp = useReactiveProp('title', {{ titleWords }}, { parse: value => value == null ? '' : String(value) })
239
+ const labelText = derived(() => labelProp() || textProp() || (titleNames ? titleProp() : ''))
240
+ const symbolProp = useReactiveProp('symbol', {{ symbol }}, { parse: value => value == null ? '' : String(value) })
241
+ // Craft's AppKit host: the button is the system's own (see the server script).
242
+ const desktop = typeof craft !== 'undefined' && craft.platform === 'macos'
217
243
  const isLoading = useReactiveProp('loading', {{ loading }})
218
244
  // The accessible name is live too. Read once on the server, a bound one
219
245
  // (:ariaLabel="action.label" in a row of icon buttons) stayed on the boxless
@@ -237,11 +263,38 @@ function onClick(event) {
237
263
  </script>
238
264
 
239
265
  @if($native)
266
+ {{-- A Mac: the host's push button. Its words are `title` (the label, or the
267
+ slot's text when there is no label), its glyph `symbol`. A caller's
268
+ `class` and `style` land on it, so a font size and a colour are the
269
+ button's own. --}}
270
+ <button
271
+ :if="desktop"
272
+ data-native="Button"
273
+ data-stx-native-host-root
274
+ type="{{ type }}"
275
+ class="text-accent {{ fullWidth ? 'w-full' : '' }} {{ className }}"
276
+ @if(desktopVariant)variant="{{ desktopVariant }}"@endif
277
+ @if(symbol)symbol="{{ symbol }}"@endif
278
+ :symbol="symbolProp() || null"
279
+ @if(iconOnly)iconOnly="true"@endif
280
+ @if(label)title="{{ label }}"@endif
281
+ :title="labelText() || null"
282
+ @if(isDisabled)disabled@endif
283
+ :disabled="isDisabled()"
284
+ aria-busy="{{ loading ? 'true' : 'false' }}"
285
+ :aria-busy="isLoading() ? 'true' : 'false'"
286
+ @if(ariaLabel)aria-label="{{ ariaLabel }}"@endif
287
+ :aria-label="String(ariaLabelProp() ?? '') || null"
288
+ @click="onClick($event)"
289
+ ><slot /></button>
240
290
  <button
291
+ :if="!desktop"
292
+ data-stx-native-host-root
241
293
  type="{{ type }}"
242
294
  class="{{ nativeButtonClasses }}"
243
295
  activeOpacity="0.6"
244
296
  @if(symbol)symbol="{{ symbol }}"@endif
297
+ :symbol="symbolProp() || null"
245
298
  @if(iconOnly)iconOnly="true"@endif
246
299
  @if(isDisabled)disabled@endif
247
300
  :disabled="isDisabled()"
@@ -20,7 +20,14 @@ export const switchAppearance = $props.appearance === 'switch'
20
20
  * are the browser's own; only the classes change, to `stx-mac-checkbox`,
21
21
  * which this file's <style> block draws from the `--stx-mac-*` tokens.
22
22
  */
23
- export const mac = $props.variant === 'mac'
23
+ export const mac = $props.variant === 'mac' && !$native
24
+ /*
25
+ * The Mac look is a stylesheet, and a native host has none: there the box is
26
+ * the platform's own control whatever `variant` says. On a Mac (Craft's
27
+ * AppKit host, known only on the device) `variant="mac"` also sets the words
28
+ * at AppKit's sizes, 13pt over 11pt; a phone keeps its own.
29
+ */
30
+ export const macNative = $props.variant === 'mac' && $native
24
31
 
25
32
  const sizeClasses = { sm: 'h-4 w-4', md: 'h-5 w-5', lg: 'h-6 w-6' }
26
33
  const baseClasses = 'rounded border-line-strong text-accent focus:ring-accent focus:ring-2 focus:ring-offset-2 focus:ring-offset-panel transition-colors'
@@ -89,6 +96,9 @@ const isIndeterminate = useReactiveProp('indeterminate', {{ indeterminate }})
89
96
  const isChecked = useReactiveProp('checked', {{ checked }})
90
97
  const currentLabel = useReactiveProp('label', {{ label }}, { parse: value => value ?? '' })
91
98
 
99
+ // `variant="mac"` on Craft's AppKit host: the words at AppKit's sizes.
100
+ const macDesktop = {{ macNative }} && typeof craft !== 'undefined' && craft.platform === 'macos'
101
+
92
102
  function onInputChange(event) {
93
103
  if (isDisabled()) {
94
104
  event.target.checked = isChecked()
@@ -182,13 +192,13 @@ defineExpose({ isChecked })
182
192
 
183
193
  <div :if="currentLabel() || {{ !!description }}" class="ml-3 text-sm leading-6">
184
194
  <label :if="currentLabel()" for="{{ inputId }}" class="{{ labelClasses }} inline-flex flex-row items-center" :class="{ 'opacity-50 cursor-not-allowed': isDisabled(), 'cursor-pointer': !isDisabled() }">
185
- <span :text="currentLabel()">{{ label }}</span>
195
+ <span :text="currentLabel()"@if($native) :class="{ 'text-[13px]': macDesktop }"@endif>{{ label }}</span>
186
196
  @if(required)
187
197
  <span class="text-danger ml-1">*</span>
188
198
  @endif
189
199
  </label>
190
200
  @if(description)
191
- <p id="{{ descriptionId }}" class="{{ descriptionClasses }}">
201
+ <p id="{{ descriptionId }}" class="{{ descriptionClasses }}"@if($native) :class="{ 'text-[11px]': macDesktop }"@endif>
192
202
  {{ description }}
193
203
  </p>
194
204
  @endif