@ponchia/ui 0.5.0 → 0.6.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.
- package/CHANGELOG.md +322 -0
- package/MIGRATIONS.json +14 -0
- package/README.md +28 -5
- package/annotations/index.d.ts +398 -276
- package/annotations/index.d.ts.map +1 -0
- package/annotations/index.js +315 -45
- package/behaviors/carousel.js +17 -16
- package/behaviors/combobox.js +47 -16
- package/behaviors/command.js +18 -15
- package/behaviors/connectors.js +4 -5
- package/behaviors/crosshair.js +4 -5
- package/behaviors/dialog.js +3 -2
- package/behaviors/disclosure.js +3 -2
- package/behaviors/dismissible.js +3 -2
- package/behaviors/forms.js +41 -13
- package/behaviors/glyph.js +4 -5
- package/behaviors/internal.js +47 -0
- package/behaviors/legend.js +23 -2
- package/behaviors/menu.js +3 -2
- package/behaviors/popover.js +78 -7
- package/behaviors/spotlight.js +4 -5
- package/behaviors/table.js +39 -12
- package/behaviors/tabs.js +14 -14
- package/behaviors/theme.js +5 -3
- package/behaviors/toast.js +13 -1
- package/classes/classes.json +1857 -0
- package/classes/index.d.ts +28 -13
- package/classes/index.js +34 -18
- package/classes/vscode.css-custom-data.json +12 -0
- package/connectors/index.d.ts +189 -69
- package/connectors/index.d.ts.map +1 -0
- package/connectors/index.js +120 -24
- package/css/app.css +43 -13
- package/css/base.css +15 -10
- package/css/connectors.css +17 -0
- package/css/content.css +7 -1
- package/css/dataviz.css +5 -1
- package/css/disclosure.css +38 -6
- package/css/dots.css +57 -0
- package/css/feedback.css +60 -2
- package/css/forms.css +42 -1
- package/css/legend.css +11 -7
- package/css/marks.css +38 -8
- package/css/motion.css +24 -44
- package/css/navigation.css +7 -0
- package/css/overlay.css +31 -1
- package/css/primitives.css +91 -5
- package/css/report.css +40 -63
- package/css/site.css +16 -2
- package/css/sources.css +43 -1
- package/css/spotlight.css +1 -1
- package/css/tokens.css +36 -1
- package/css/workbench.css +1 -1
- package/dist/bronto.css +1 -1
- package/dist/css/analytical.css +1 -1
- package/dist/css/app.css +1 -1
- package/dist/css/base.css +1 -1
- package/dist/css/connectors.css +1 -1
- package/dist/css/content.css +1 -1
- package/dist/css/disclosure.css +1 -1
- package/dist/css/dots.css +1 -1
- package/dist/css/feedback.css +1 -1
- package/dist/css/forms.css +1 -1
- package/dist/css/legend.css +1 -1
- package/dist/css/marks.css +1 -1
- package/dist/css/motion.css +1 -1
- package/dist/css/navigation.css +1 -1
- package/dist/css/overlay.css +1 -1
- package/dist/css/primitives.css +1 -1
- package/dist/css/report.css +1 -1
- package/dist/css/site.css +1 -1
- package/dist/css/sources.css +1 -1
- package/dist/css/spotlight.css +1 -1
- package/dist/css/tokens.css +1 -1
- package/dist/css/workbench.css +1 -1
- package/docs/adr/0003-theme-model.md +1 -1
- package/docs/annotations.md +94 -14
- package/docs/architecture.md +50 -6
- package/docs/contrast.md +116 -92
- package/docs/d2.md +195 -0
- package/docs/legends.md +18 -2
- package/docs/marks.md +9 -2
- package/docs/mermaid.md +152 -0
- package/docs/reference.md +78 -22
- package/docs/reporting.md +395 -57
- package/docs/sources.md +27 -0
- package/docs/stability.md +9 -2
- package/docs/usage.md +101 -4
- package/docs/vega.md +225 -0
- package/docs/workbench.md +7 -1
- package/glyphs/glyphs.js +6 -4
- package/llms.txt +139 -14
- package/package.json +50 -12
- package/qwik/index.d.ts +42 -59
- package/qwik/index.d.ts.map +1 -0
- package/qwik/index.js +55 -3
- package/react/index.d.ts +39 -61
- package/react/index.d.ts.map +1 -0
- package/react/index.js +57 -3
- package/solid/index.d.ts +64 -61
- package/solid/index.d.ts.map +1 -0
- package/solid/index.js +60 -3
- package/tokens/d2.d.ts +38 -0
- package/tokens/d2.js +71 -0
- package/tokens/d2.json +43 -0
- package/tokens/index.d.ts +5 -5
- package/tokens/index.js +15 -1
- package/tokens/index.json +9 -0
- package/tokens/mermaid.d.ts +23 -0
- package/tokens/mermaid.js +181 -0
- package/tokens/mermaid.json +163 -0
- package/tokens/resolved.json +45 -1
- package/tokens/skins.js +3 -2
- package/tokens/tokens.dtcg.json +26 -0
- package/tokens/vega.d.ts +34 -0
- package/tokens/vega.js +155 -0
- package/tokens/vega.json +179 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ponchia/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CSS-first design system for interfaces that explain themselves — works in HTML, every framework, and PDF, no component runtime. A standard component set plus an opt-in analytical & report layer (annotations, legends, connectors, data-viz, report grammar). Monochrome with one rationed accent, re-skinnable from one --accent knob. Zero runtime dependencies.",
|
|
6
6
|
"keywords": [
|
|
@@ -62,6 +62,9 @@
|
|
|
62
62
|
"docs/stability.md",
|
|
63
63
|
"docs/usage.md",
|
|
64
64
|
"docs/reporting.md",
|
|
65
|
+
"docs/mermaid.md",
|
|
66
|
+
"docs/d2.md",
|
|
67
|
+
"docs/vega.md",
|
|
65
68
|
"docs/annotations.md",
|
|
66
69
|
"docs/legends.md",
|
|
67
70
|
"docs/marks.md",
|
|
@@ -85,59 +88,75 @@
|
|
|
85
88
|
"format": "prettier --write .",
|
|
86
89
|
"check:format": "prettier --check .",
|
|
87
90
|
"size:report": "node scripts/size-report.mjs",
|
|
91
|
+
"report:pdf": "node scripts/render-pdf.mjs",
|
|
92
|
+
"gen": "npm run prepack",
|
|
93
|
+
"fresh:build": "node scripts/gen-all.mjs",
|
|
88
94
|
"tokens:build": "node scripts/gen-tokens-json.mjs",
|
|
89
95
|
"tokens:css:build": "node scripts/gen-tokens-css.mjs",
|
|
90
96
|
"dtcg:build": "node scripts/gen-dtcg.mjs",
|
|
91
97
|
"resolved:build": "node scripts/gen-resolved.mjs",
|
|
92
98
|
"dts:build": "node scripts/gen-dts.mjs",
|
|
99
|
+
"dts:emit": "node scripts/emit-dts.mjs",
|
|
93
100
|
"glyphs:build": "node scripts/gen-glyphs.mjs",
|
|
94
101
|
"skins:build": "node scripts/gen-skins.mjs",
|
|
95
102
|
"charts:build": "node scripts/gen-charts.mjs",
|
|
103
|
+
"mermaid:build": "node scripts/gen-mermaid.mjs",
|
|
104
|
+
"d2:build": "node scripts/gen-d2.mjs",
|
|
105
|
+
"vega:build": "node scripts/gen-vega.mjs",
|
|
96
106
|
"reference:build": "node scripts/gen-reference.mjs",
|
|
107
|
+
"classes:json:build": "node scripts/gen-classes-json.mjs",
|
|
97
108
|
"contrast:build": "node scripts/gen-contrast.mjs",
|
|
98
109
|
"vscode:build": "node scripts/gen-vscode-data.mjs",
|
|
99
110
|
"dist:build": "node scripts/build-dist.mjs",
|
|
100
111
|
"check:exports": "node scripts/check-exports.mjs",
|
|
101
|
-
"check:
|
|
112
|
+
"check:fresh": "node scripts/check-fresh.mjs",
|
|
102
113
|
"check:classes": "node scripts/check-classes.mjs",
|
|
103
|
-
"check:
|
|
114
|
+
"check:recipe-types": "node scripts/check-recipe-types.mjs",
|
|
115
|
+
"check:chain": "node scripts/check-chain.mjs",
|
|
104
116
|
"check:behaviors": "node scripts/check-behaviors.mjs",
|
|
105
|
-
"check:
|
|
106
|
-
"check:helpers-dts": "node scripts/check-helpers-dts.mjs",
|
|
117
|
+
"check:dts-emit": "node scripts/check-dts-emit.mjs",
|
|
107
118
|
"check:glyphs": "node scripts/check-glyphs.mjs",
|
|
108
119
|
"check:color-policy": "node scripts/check-color-policy.mjs",
|
|
109
120
|
"check:skins": "node scripts/check-skins.mjs",
|
|
110
121
|
"check:charts": "node scripts/check-charts.mjs",
|
|
122
|
+
"check:mermaid": "node scripts/check-mermaid.mjs",
|
|
123
|
+
"check:d2": "node scripts/check-d2.mjs",
|
|
124
|
+
"check:vega": "node scripts/check-vega.mjs",
|
|
111
125
|
"check:report": "node scripts/check-report.mjs",
|
|
112
126
|
"check:legend": "node scripts/check-legend.mjs",
|
|
113
127
|
"check:types": "tsc -p tsconfig.json",
|
|
114
|
-
"check:dtcg": "node scripts/check-dtcg.mjs",
|
|
115
|
-
"check:resolved": "node scripts/check-resolved.mjs",
|
|
116
128
|
"check:shiki": "node scripts/check-shiki.mjs",
|
|
117
129
|
"check:dist": "node scripts/check-dist.mjs",
|
|
118
130
|
"check:pack": "node scripts/check-pack.mjs",
|
|
119
131
|
"check:release": "node scripts/check-release.mjs",
|
|
120
|
-
"check:
|
|
132
|
+
"check:versions": "node scripts/check-versions.mjs",
|
|
133
|
+
"check:doc-recipes": "node scripts/check-doc-recipes.mjs",
|
|
134
|
+
"check:contract": "node scripts/check-contract.mjs",
|
|
121
135
|
"check:contrast": "node scripts/check-contrast.mjs",
|
|
122
|
-
"check:
|
|
123
|
-
"check": "
|
|
136
|
+
"check:publint": "publint --strict",
|
|
137
|
+
"check:attw": "attw --pack --ignore-rules no-resolution cjs-resolves-to-esm",
|
|
138
|
+
"check": "npm run lint && npm run check:format && npm run check:exports && npm run check:fresh && npm run check:classes && npm run check:recipe-types && npm run check:types && npm run check:shiki && npm run check:dist && npm run check:pack && npm run check:publint && npm run check:attw && npm run check:release && npm run check:versions && npm run check:doc-recipes && npm run check:contract && npm run check:contrast && npm run check:behaviors && npm run check:dts-emit && npm run check:glyphs && npm run check:color-policy && npm run check:skins && npm run check:charts && npm run check:mermaid && npm run check:d2 && npm run check:vega && npm run check:report && npm run check:legend && npm run check:chain",
|
|
124
139
|
"test": "node --test \"test/*.test.mjs\"",
|
|
125
|
-
"prepack": "npm run tokens:css:build && npm run tokens:build && npm run dtcg:build && npm run resolved:build && npm run dts:build && npm run reference:build && npm run contrast:build && npm run vscode:build && npm run skins:build && npm run charts:build && npm run dist:build && npm run glyphs:build",
|
|
140
|
+
"prepack": "npm run tokens:css:build && npm run tokens:build && npm run dtcg:build && npm run resolved:build && npm run dts:build && npm run dts:emit && npm run reference:build && npm run classes:json:build && npm run contrast:build && npm run vscode:build && npm run skins:build && npm run charts:build && npm run mermaid:build && npm run d2:build && npm run vega:build && npm run dist:build && npm run glyphs:build",
|
|
126
141
|
"prepublishOnly": "npm run check && npm test"
|
|
127
142
|
},
|
|
128
143
|
"devDependencies": {
|
|
144
|
+
"@arethetypeswrong/cli": "^0.18.3",
|
|
129
145
|
"@axe-core/playwright": "^4.11.3",
|
|
130
146
|
"@builder.io/qwik": "^1.20.0",
|
|
131
147
|
"@playwright/test": "^1.60.0",
|
|
132
148
|
"jsdom": "^29.1.1",
|
|
133
149
|
"prettier": "^3.8.3",
|
|
150
|
+
"publint": "^0.3.21",
|
|
134
151
|
"react": "^19.2.6",
|
|
135
152
|
"react-dom": "^19.2.6",
|
|
136
153
|
"solid-js": "^1.9.13",
|
|
137
154
|
"stylelint": "^17.11.1",
|
|
138
155
|
"stylelint-config-standard": "^40.0.0",
|
|
139
156
|
"stylelint-use-logical": "^2.1.3",
|
|
140
|
-
"typescript": "^6.0.3"
|
|
157
|
+
"typescript": "^6.0.3",
|
|
158
|
+
"vega": "^6.2.0",
|
|
159
|
+
"vega-lite": "^6.4.3"
|
|
141
160
|
},
|
|
142
161
|
"peerDependencies": {
|
|
143
162
|
"@builder.io/qwik": ">=1.5",
|
|
@@ -241,6 +260,9 @@
|
|
|
241
260
|
"./docs/stability.md": "./docs/stability.md",
|
|
242
261
|
"./docs/usage.md": "./docs/usage.md",
|
|
243
262
|
"./docs/reporting.md": "./docs/reporting.md",
|
|
263
|
+
"./docs/mermaid.md": "./docs/mermaid.md",
|
|
264
|
+
"./docs/d2.md": "./docs/d2.md",
|
|
265
|
+
"./docs/vega.md": "./docs/vega.md",
|
|
244
266
|
"./docs/annotations.md": "./docs/annotations.md",
|
|
245
267
|
"./docs/legends.md": "./docs/legends.md",
|
|
246
268
|
"./docs/marks.md": "./docs/marks.md",
|
|
@@ -260,6 +282,7 @@
|
|
|
260
282
|
"types": "./classes/index.d.ts",
|
|
261
283
|
"default": "./classes/index.js"
|
|
262
284
|
},
|
|
285
|
+
"./classes.json": "./classes/classes.json",
|
|
263
286
|
"./behaviors": {
|
|
264
287
|
"types": "./behaviors/index.d.ts",
|
|
265
288
|
"default": "./behaviors/index.js"
|
|
@@ -297,6 +320,21 @@
|
|
|
297
320
|
"default": "./tokens/charts.js"
|
|
298
321
|
},
|
|
299
322
|
"./charts.json": "./tokens/charts.json",
|
|
323
|
+
"./mermaid": {
|
|
324
|
+
"types": "./tokens/mermaid.d.ts",
|
|
325
|
+
"default": "./tokens/mermaid.js"
|
|
326
|
+
},
|
|
327
|
+
"./mermaid.json": "./tokens/mermaid.json",
|
|
328
|
+
"./d2": {
|
|
329
|
+
"types": "./tokens/d2.d.ts",
|
|
330
|
+
"default": "./tokens/d2.js"
|
|
331
|
+
},
|
|
332
|
+
"./d2.json": "./tokens/d2.json",
|
|
333
|
+
"./vega": {
|
|
334
|
+
"types": "./tokens/vega.d.ts",
|
|
335
|
+
"default": "./tokens/vega.js"
|
|
336
|
+
},
|
|
337
|
+
"./vega.json": "./tokens/vega.json",
|
|
300
338
|
"./fonts/*": "./fonts/*"
|
|
301
339
|
}
|
|
302
340
|
}
|
package/qwik/index.d.ts
CHANGED
|
@@ -1,60 +1,43 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
1
|
+
/** Generic escape hatch. NOTE for Qwik: prefer the specific `use*` hooks
|
|
2
|
+
* below — they inline a statically-imported behavior so the optimizer can
|
|
3
|
+
* serialize the task. Passing a runtime function here is only safe when it
|
|
4
|
+
* is itself optimizer-visible (a module import).
|
|
5
|
+
* @param {(opts?: DelegateOpts) => Cleanup | void} init
|
|
6
|
+
* @param {BrontoBindingOptsResolver} [opts]
|
|
7
|
+
* @returns {void} */
|
|
8
|
+
export function useBrontoBehavior(init: (opts?: DelegateOpts) => Cleanup | void, opts?: BrontoBindingOptsResolver): void;
|
|
9
|
+
export function useThemeToggle(opts?: BrontoBindingOptsResolver<ThemeStorageOpts & DelegateOpts>): void;
|
|
10
|
+
export function useDismissible(opts?: BrontoBindingOptsResolver): void;
|
|
11
|
+
export function useDisclosure(opts?: BrontoBindingOptsResolver): void;
|
|
12
|
+
export function useMenu(opts?: BrontoBindingOptsResolver): void;
|
|
13
|
+
export function useFormValidation(opts?: BrontoBindingOptsResolver): void;
|
|
14
|
+
export function useCombobox(opts?: BrontoBindingOptsResolver): void;
|
|
15
|
+
export function usePopover(opts?: BrontoBindingOptsResolver): void;
|
|
16
|
+
export function useTableSort(opts?: BrontoBindingOptsResolver): void;
|
|
17
|
+
export function useTabs(opts?: BrontoBindingOptsResolver): void;
|
|
18
|
+
export function useDialog(opts?: BrontoBindingOptsResolver): void;
|
|
19
|
+
export function useCarousel(opts?: BrontoBindingOptsResolver): void;
|
|
20
|
+
export function useDotGlyph(opts?: BrontoBindingOptsResolver): void;
|
|
21
|
+
export function useLegend(opts?: BrontoBindingOptsResolver): void;
|
|
22
|
+
export function useConnectors(opts?: BrontoBindingOptsResolver): void;
|
|
23
|
+
export function useSpotlight(opts?: BrontoBindingOptsResolver): void;
|
|
24
|
+
export function useCrosshair(opts?: BrontoBindingOptsResolver): void;
|
|
25
|
+
export function useCommand(opts?: BrontoBindingOptsResolver): void;
|
|
26
|
+
export function useToast(): (message: string, opts?: ToastOpts) => Cleanup;
|
|
27
|
+
export { applyStoredTheme };
|
|
28
|
+
export type Cleanup = import("../behaviors/index.js").Cleanup;
|
|
29
|
+
export type DelegateOpts = import("../behaviors/index.js").DelegateOpts;
|
|
30
|
+
export type ThemeStorageOpts = import("../behaviors/index.js").ThemeStorageOpts;
|
|
31
|
+
export type ToastOpts = import("../behaviors/index.js").ToastOpts;
|
|
32
|
+
export type BrontoBindingRoot = Document | Element | {
|
|
33
|
+
value: Document | Element | null | undefined;
|
|
34
|
+
} | {
|
|
35
|
+
current: Document | Element | null | undefined;
|
|
36
|
+
} | (() => Document | Element | null | undefined) | null | undefined;
|
|
37
|
+
export type BrontoBindingOpts<T extends DelegateOpts = import("../behaviors/index.js").DelegateOpts> = Omit<T, "root"> & {
|
|
38
|
+
root?: BrontoBindingRoot;
|
|
19
39
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
| null
|
|
25
|
-
| undefined;
|
|
26
|
-
|
|
27
|
-
/** Run any delegated behavior for the component's lifetime (init on visible,
|
|
28
|
-
* its returned cleanup on dispose). Prefer the specific `use*` hooks in Qwik
|
|
29
|
-
* so the optimizer can serialize the task; this generic form is safe only with
|
|
30
|
-
* an optimizer-visible (module-imported) behavior. */
|
|
31
|
-
export declare function useBrontoBehavior(
|
|
32
|
-
init: (opts?: DelegateOpts) => Cleanup | void,
|
|
33
|
-
opts?: BrontoBindingOptsResolver,
|
|
34
|
-
): void;
|
|
35
|
-
|
|
36
|
-
export declare function useThemeToggle(
|
|
37
|
-
opts?: BrontoBindingOptsResolver<ThemeStorageOpts & DelegateOpts>,
|
|
38
|
-
): void;
|
|
39
|
-
export declare function useDismissible(opts?: BrontoBindingOptsResolver): void;
|
|
40
|
-
export declare function useDisclosure(opts?: BrontoBindingOptsResolver): void;
|
|
41
|
-
export declare function useMenu(opts?: BrontoBindingOptsResolver): void;
|
|
42
|
-
export declare function useFormValidation(opts?: BrontoBindingOptsResolver): void;
|
|
43
|
-
export declare function useCombobox(opts?: BrontoBindingOptsResolver): void;
|
|
44
|
-
export declare function usePopover(opts?: BrontoBindingOptsResolver): void;
|
|
45
|
-
export declare function useTableSort(opts?: BrontoBindingOptsResolver): void;
|
|
46
|
-
export declare function useTabs(opts?: BrontoBindingOptsResolver): void;
|
|
47
|
-
export declare function useDialog(opts?: BrontoBindingOptsResolver): void;
|
|
48
|
-
export declare function useCarousel(opts?: BrontoBindingOptsResolver): void;
|
|
49
|
-
export declare function useDotGlyph(opts?: BrontoBindingOptsResolver): void;
|
|
50
|
-
export declare function useLegend(opts?: BrontoBindingOptsResolver): void;
|
|
51
|
-
export declare function useConnectors(opts?: BrontoBindingOptsResolver): void;
|
|
52
|
-
export declare function useSpotlight(opts?: BrontoBindingOptsResolver): void;
|
|
53
|
-
export declare function useCrosshair(opts?: BrontoBindingOptsResolver): void;
|
|
54
|
-
export declare function useCommand(opts?: BrontoBindingOptsResolver): void;
|
|
55
|
-
|
|
56
|
-
/** The `toast()` imperative (no lifecycle of its own). */
|
|
57
|
-
export declare function useToast(): (message: string, opts?: ToastOpts) => Cleanup;
|
|
58
|
-
|
|
59
|
-
export { applyStoredTheme } from '../behaviors/index.js';
|
|
60
|
-
export { cls, ui, cx } from '../classes/index.js';
|
|
40
|
+
export type BrontoBindingOptsResolver<T extends DelegateOpts = import("../behaviors/index.js").DelegateOpts> = BrontoBindingOpts<T> | (() => BrontoBindingOpts<T> | null | undefined) | null | undefined;
|
|
41
|
+
import { applyStoredTheme } from '../behaviors/index.js';
|
|
42
|
+
export { cls, ui, cx } from "../classes/index.js";
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AA8GA;;;;;;sBAMsB;AACtB,wCAHY,CAAC,IAAI,CAAC,EAAE,YAAY,KAAK,OAAO,GAAG,IAAI,SACvC,yBAAyB,GACvB,IAAI,CAIjB;AAGM,sCADK,yBAAyB,CAAC,gBAAgB,GAAG,YAAY,CAAC,GAAmB,IAAI,CAGhC;AAEtD,sCADK,yBAAyB,GAAmB,IAAI,CAGH;AAElD,qCADK,yBAAyB,GAAmB,IAAI,CAGA;AAErD,+BADK,yBAAyB,GAAmB,IAAI,CAGN;AAE/C,yCADK,yBAAyB,GAAmB,IAAI,CAGI;AAEzD,mCADK,yBAAyB,GAAmB,IAAI,CAGF;AAEnD,kCADK,yBAAyB,GAAmB,IAAI,CAGH;AAElD,oCADK,yBAAyB,GAAmB,IAAI,CAGD;AAEpD,+BADK,yBAAyB,GAAmB,IAAI,CAGN;AAE/C,iCADK,yBAAyB,GAAmB,IAAI,CAGJ;AAEjD,mCADK,yBAAyB,GAAmB,IAAI,CAGF;AAEnD,mCADK,yBAAyB,GAAmB,IAAI,CAGF;AAEnD,iCADK,yBAAyB,GAAmB,IAAI,CAGJ;AAEjD,qCADK,yBAAyB,GAAmB,IAAI,CAGA;AAErD,oCADK,yBAAyB,GAAmB,IAAI,CAGD;AAEpD,oCADK,yBAAyB,GAAmB,IAAI,CAGD;AAEpD,kCADK,yBAAyB,GAAmB,IAAI,CAGH;AAIlD,4BADO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,OAAO,CACzB;;sBAtKtB,OAAO,uBAAuB,EAAE,OAAO;2BACvC,OAAO,uBAAuB,EAAE,YAAY;+BAC5C,OAAO,uBAAuB,EAAE,gBAAgB;wBAChD,OAAO,uBAAuB,EAAE,SAAS;gCAEzC,QAAQ,GACd,OAAO,GACP;IAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GAChD;IAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GAClD,CAAC,MAAM,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,GAC7C,IAAI,GACJ,SAAS;8BAIa,CAAC,SAAhB,YAAa,mDACd,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,iBAAiB,CAAA;CAAE;sCAI9B,CAAC,SAAhB,YAAa,mDACd,iBAAiB,CAAC,CAAC,CAAC,GAC1B,CAAC,MAAM,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAC/C,IAAI,GACJ,SAAS;iCAuBT,uBAAuB"}
|
package/qwik/index.js
CHANGED
|
@@ -24,6 +24,32 @@
|
|
|
24
24
|
* Scope a behavior to a subtree by passing a Qwik signal:
|
|
25
25
|
* const root = useSignal();
|
|
26
26
|
* useDialog({ root }); // <section ref={root}> … </section>
|
|
27
|
+
*
|
|
28
|
+
* @typedef {import('../behaviors/index.js').Cleanup} Cleanup
|
|
29
|
+
* @typedef {import('../behaviors/index.js').DelegateOpts} DelegateOpts
|
|
30
|
+
* @typedef {import('../behaviors/index.js').ThemeStorageOpts} ThemeStorageOpts
|
|
31
|
+
* @typedef {import('../behaviors/index.js').ToastOpts} ToastOpts
|
|
32
|
+
*
|
|
33
|
+
* @typedef {Document
|
|
34
|
+
* | Element
|
|
35
|
+
* | { value: Document | Element | null | undefined }
|
|
36
|
+
* | { current: Document | Element | null | undefined }
|
|
37
|
+
* | (() => Document | Element | null | undefined)
|
|
38
|
+
* | null
|
|
39
|
+
* | undefined} BrontoBindingRoot
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @template {DelegateOpts} [T=DelegateOpts]
|
|
44
|
+
* @typedef {Omit<T, 'root'> & { root?: BrontoBindingRoot }} BrontoBindingOpts
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @template {DelegateOpts} [T=DelegateOpts]
|
|
49
|
+
* @typedef {BrontoBindingOpts<T>
|
|
50
|
+
* | (() => BrontoBindingOpts<T> | null | undefined)
|
|
51
|
+
* | null
|
|
52
|
+
* | undefined} BrontoBindingOptsResolver
|
|
27
53
|
*/
|
|
28
54
|
import { useVisibleTask$ } from '@builder.io/qwik';
|
|
29
55
|
import {
|
|
@@ -64,8 +90,13 @@ function resolveRoot(root) {
|
|
|
64
90
|
function resolveOpts(opts) {
|
|
65
91
|
const value = resolveMaybe(opts);
|
|
66
92
|
if (!value || typeof value !== 'object') return undefined;
|
|
93
|
+
// No `root` key → no scope requested; leave root out so the behavior
|
|
94
|
+
// delegates from `document`. A `root` key that resolves falsy means a scope
|
|
95
|
+
// WAS requested but the ref is not ready: emit `root: null` so the behavior
|
|
96
|
+
// no-ops instead of hijacking the whole document.
|
|
97
|
+
if (!('root' in value)) return { ...value };
|
|
67
98
|
const root = resolveRoot(value.root);
|
|
68
|
-
return
|
|
99
|
+
return { ...value, root: root || null };
|
|
69
100
|
}
|
|
70
101
|
|
|
71
102
|
/** Run a delegated behavior on visible and register its cleanup on dispose.
|
|
@@ -80,65 +111,86 @@ function start(init, opts, ctx) {
|
|
|
80
111
|
/** Generic escape hatch. NOTE for Qwik: prefer the specific `use*` hooks
|
|
81
112
|
* below — they inline a statically-imported behavior so the optimizer can
|
|
82
113
|
* serialize the task. Passing a runtime function here is only safe when it
|
|
83
|
-
* is itself optimizer-visible (a module import).
|
|
114
|
+
* is itself optimizer-visible (a module import).
|
|
115
|
+
* @param {(opts?: DelegateOpts) => Cleanup | void} init
|
|
116
|
+
* @param {BrontoBindingOptsResolver} [opts]
|
|
117
|
+
* @returns {void} */
|
|
84
118
|
export function useBrontoBehavior(init, opts) {
|
|
85
119
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
86
120
|
useVisibleTask$((ctx) => start(init, opts, ctx));
|
|
87
121
|
}
|
|
88
122
|
|
|
123
|
+
/** @param {BrontoBindingOptsResolver<ThemeStorageOpts & DelegateOpts>} [opts] @returns {void} */
|
|
89
124
|
export const useThemeToggle = (opts) =>
|
|
90
125
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
91
126
|
useVisibleTask$((ctx) => start(initThemeToggle, opts, ctx));
|
|
127
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
92
128
|
export const useDismissible = (opts) =>
|
|
93
129
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
94
130
|
useVisibleTask$((ctx) => start(dismissible, opts, ctx));
|
|
131
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
95
132
|
export const useDisclosure = (opts) =>
|
|
96
133
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
97
134
|
useVisibleTask$((ctx) => start(initDisclosure, opts, ctx));
|
|
135
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
98
136
|
export const useMenu = (opts) =>
|
|
99
137
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
100
138
|
useVisibleTask$((ctx) => start(initMenu, opts, ctx));
|
|
139
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
101
140
|
export const useFormValidation = (opts) =>
|
|
102
141
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
103
142
|
useVisibleTask$((ctx) => start(initFormValidation, opts, ctx));
|
|
143
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
104
144
|
export const useCombobox = (opts) =>
|
|
105
145
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
106
146
|
useVisibleTask$((ctx) => start(initCombobox, opts, ctx));
|
|
147
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
107
148
|
export const usePopover = (opts) =>
|
|
108
149
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
109
150
|
useVisibleTask$((ctx) => start(initPopover, opts, ctx));
|
|
151
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
110
152
|
export const useTableSort = (opts) =>
|
|
111
153
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
112
154
|
useVisibleTask$((ctx) => start(initTableSort, opts, ctx));
|
|
155
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
113
156
|
export const useTabs = (opts) =>
|
|
114
157
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
115
158
|
useVisibleTask$((ctx) => start(initTabs, opts, ctx));
|
|
159
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
116
160
|
export const useDialog = (opts) =>
|
|
117
161
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
118
162
|
useVisibleTask$((ctx) => start(initDialog, opts, ctx));
|
|
163
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
119
164
|
export const useCarousel = (opts) =>
|
|
120
165
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
121
166
|
useVisibleTask$((ctx) => start(initCarousel, opts, ctx));
|
|
167
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
122
168
|
export const useDotGlyph = (opts) =>
|
|
123
169
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
124
170
|
useVisibleTask$((ctx) => start(initDotGlyph, opts, ctx));
|
|
171
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
125
172
|
export const useLegend = (opts) =>
|
|
126
173
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
127
174
|
useVisibleTask$((ctx) => start(initLegend, opts, ctx));
|
|
175
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
128
176
|
export const useConnectors = (opts) =>
|
|
129
177
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
130
178
|
useVisibleTask$((ctx) => start(initConnectors, opts, ctx));
|
|
179
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
131
180
|
export const useSpotlight = (opts) =>
|
|
132
181
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
133
182
|
useVisibleTask$((ctx) => start(initSpotlight, opts, ctx));
|
|
183
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
134
184
|
export const useCrosshair = (opts) =>
|
|
135
185
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
136
186
|
useVisibleTask$((ctx) => start(initCrosshair, opts, ctx));
|
|
187
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
137
188
|
export const useCommand = (opts) =>
|
|
138
189
|
// eslint-disable-next-line qwik/no-use-visible-task -- delegated DOM glue + cleanup
|
|
139
190
|
useVisibleTask$((ctx) => start(initCommand, opts, ctx));
|
|
140
191
|
|
|
141
|
-
/** The `toast()` imperative (no lifecycle of its own).
|
|
192
|
+
/** The `toast()` imperative (no lifecycle of its own).
|
|
193
|
+
* @returns {(message: string, opts?: ToastOpts) => Cleanup} */
|
|
142
194
|
export const useToast = () => toast;
|
|
143
195
|
|
|
144
196
|
// No-flash theme application must run before paint — do it in an inline head
|
package/react/index.d.ts
CHANGED
|
@@ -1,62 +1,40 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
|
|
1
|
+
/** Run a delegated behavior for the component's lifetime (init on mount, its
|
|
2
|
+
* returned cleanup on unmount). The behavior is run once; `opts` resolves
|
|
3
|
+
* on mount so refs are usable for scoped roots.
|
|
4
|
+
* @param {(opts?: DelegateOpts) => Cleanup | void} init
|
|
5
|
+
* @param {BrontoBindingOptsResolver} [opts]
|
|
6
|
+
* @returns {void} */
|
|
7
|
+
export function useBrontoBehavior(init: (opts?: DelegateOpts) => Cleanup | void, opts?: BrontoBindingOptsResolver): void;
|
|
8
|
+
export function useThemeToggle(opts?: BrontoBindingOptsResolver<ThemeStorageOpts & DelegateOpts>): void;
|
|
9
|
+
export function useDismissible(opts?: BrontoBindingOptsResolver): void;
|
|
10
|
+
export function useDisclosure(opts?: BrontoBindingOptsResolver): void;
|
|
11
|
+
export function useMenu(opts?: BrontoBindingOptsResolver): void;
|
|
12
|
+
export function useFormValidation(opts?: BrontoBindingOptsResolver): void;
|
|
13
|
+
export function useCombobox(opts?: BrontoBindingOptsResolver): void;
|
|
14
|
+
export function usePopover(opts?: BrontoBindingOptsResolver): void;
|
|
15
|
+
export function useTableSort(opts?: BrontoBindingOptsResolver): void;
|
|
16
|
+
export function useTabs(opts?: BrontoBindingOptsResolver): void;
|
|
17
|
+
export function useDialog(opts?: BrontoBindingOptsResolver): void;
|
|
18
|
+
export function useCarousel(opts?: BrontoBindingOptsResolver): void;
|
|
19
|
+
export function useDotGlyph(opts?: BrontoBindingOptsResolver): void;
|
|
20
|
+
export function useLegend(opts?: BrontoBindingOptsResolver): void;
|
|
21
|
+
export function useConnectors(opts?: BrontoBindingOptsResolver): void;
|
|
22
|
+
export function useSpotlight(opts?: BrontoBindingOptsResolver): void;
|
|
23
|
+
export function useCrosshair(opts?: BrontoBindingOptsResolver): void;
|
|
24
|
+
export function useCommand(opts?: BrontoBindingOptsResolver): void;
|
|
25
|
+
export function useToast(): (message: string, opts?: ToastOpts) => Cleanup;
|
|
26
|
+
export { applyStoredTheme };
|
|
27
|
+
export type Cleanup = import("../behaviors/index.js").Cleanup;
|
|
28
|
+
export type DelegateOpts = import("../behaviors/index.js").DelegateOpts;
|
|
29
|
+
export type ThemeStorageOpts = import("../behaviors/index.js").ThemeStorageOpts;
|
|
30
|
+
export type ToastOpts = import("../behaviors/index.js").ToastOpts;
|
|
31
|
+
export type BrontoBindingRoot = Document | Element | {
|
|
32
|
+
current: Document | Element | null | undefined;
|
|
33
|
+
} | (() => Document | Element | null | undefined) | null | undefined;
|
|
34
|
+
export type BrontoBindingOpts<T extends DelegateOpts = import("../behaviors/index.js").DelegateOpts> = Omit<T, "root"> & {
|
|
35
|
+
root?: BrontoBindingRoot;
|
|
22
36
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
| null
|
|
28
|
-
| undefined;
|
|
29
|
-
|
|
30
|
-
/** Run any delegated behavior for the component's lifetime (init on mount,
|
|
31
|
-
* its returned cleanup on unmount). The behavior is run once. Options resolve
|
|
32
|
-
* on mount, so scoped roots may be React refs or resolver callbacks. */
|
|
33
|
-
export declare function useBrontoBehavior(
|
|
34
|
-
init: (opts?: DelegateOpts) => Cleanup | void,
|
|
35
|
-
opts?: BrontoBindingOptsResolver,
|
|
36
|
-
): void;
|
|
37
|
-
|
|
38
|
-
export declare function useThemeToggle(
|
|
39
|
-
opts?: BrontoBindingOptsResolver<ThemeStorageOpts & DelegateOpts>,
|
|
40
|
-
): void;
|
|
41
|
-
export declare function useDismissible(opts?: BrontoBindingOptsResolver): void;
|
|
42
|
-
export declare function useDisclosure(opts?: BrontoBindingOptsResolver): void;
|
|
43
|
-
export declare function useMenu(opts?: BrontoBindingOptsResolver): void;
|
|
44
|
-
export declare function useFormValidation(opts?: BrontoBindingOptsResolver): void;
|
|
45
|
-
export declare function useCombobox(opts?: BrontoBindingOptsResolver): void;
|
|
46
|
-
export declare function usePopover(opts?: BrontoBindingOptsResolver): void;
|
|
47
|
-
export declare function useTableSort(opts?: BrontoBindingOptsResolver): void;
|
|
48
|
-
export declare function useTabs(opts?: BrontoBindingOptsResolver): void;
|
|
49
|
-
export declare function useDialog(opts?: BrontoBindingOptsResolver): void;
|
|
50
|
-
export declare function useCarousel(opts?: BrontoBindingOptsResolver): void;
|
|
51
|
-
export declare function useDotGlyph(opts?: BrontoBindingOptsResolver): void;
|
|
52
|
-
export declare function useLegend(opts?: BrontoBindingOptsResolver): void;
|
|
53
|
-
export declare function useConnectors(opts?: BrontoBindingOptsResolver): void;
|
|
54
|
-
export declare function useSpotlight(opts?: BrontoBindingOptsResolver): void;
|
|
55
|
-
export declare function useCrosshair(opts?: BrontoBindingOptsResolver): void;
|
|
56
|
-
export declare function useCommand(opts?: BrontoBindingOptsResolver): void;
|
|
57
|
-
|
|
58
|
-
/** The `toast()` imperative (no lifecycle of its own). */
|
|
59
|
-
export declare function useToast(): (message: string, opts?: ToastOpts) => Cleanup;
|
|
60
|
-
|
|
61
|
-
export { applyStoredTheme } from '../behaviors/index.js';
|
|
62
|
-
export { cls, ui, cx } from '../classes/index.js';
|
|
37
|
+
export type BrontoBindingOptsResolver<T extends DelegateOpts = import("../behaviors/index.js").DelegateOpts> = BrontoBindingOpts<T> | (() => BrontoBindingOpts<T> | null | undefined) | null | undefined;
|
|
38
|
+
import { applyStoredTheme } from '../behaviors/index.js';
|
|
39
|
+
export { cls, ui, cx } from "../classes/index.js";
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AA4FA;;;;;sBAKsB;AACtB,wCAHY,CAAC,IAAI,CAAC,EAAE,YAAY,KAAK,OAAO,GAAG,IAAI,SACvC,yBAAyB,GACvB,IAAI,CAGjB;AAGM,sCADK,yBAAyB,CAAC,gBAAgB,GAAG,YAAY,CAAC,GAAmB,IAAI,CACb;AAEzE,sCADK,yBAAyB,GAAmB,IAAI,CACgB;AAErE,qCADK,yBAAyB,GAAmB,IAAI,CACkB;AAEvE,+BADK,yBAAyB,GAAmB,IAAI,CACM;AAE3D,yCADK,yBAAyB,GAAmB,IAAI,CAC0B;AAE/E,mCADK,yBAAyB,GAAmB,IAAI,CACc;AAEnE,kCADK,yBAAyB,GAAmB,IAAI,CACY;AAEjE,oCADK,yBAAyB,GAAmB,IAAI,CACgB;AAErE,+BADK,yBAAyB,GAAmB,IAAI,CACM;AAE3D,iCADK,yBAAyB,GAAmB,IAAI,CACU;AAE/D,mCADK,yBAAyB,GAAmB,IAAI,CACc;AAEnE,mCADK,yBAAyB,GAAmB,IAAI,CACc;AAEnE,iCADK,yBAAyB,GAAmB,IAAI,CACU;AAE/D,qCADK,yBAAyB,GAAmB,IAAI,CACkB;AAEvE,oCADK,yBAAyB,GAAmB,IAAI,CACgB;AAErE,oCADK,yBAAyB,GAAmB,IAAI,CACgB;AAErE,kCADK,yBAAyB,GAAmB,IAAI,CACY;AAIjE,4BADO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,OAAO,CACzB;;sBArHtB,OAAO,uBAAuB,EAAE,OAAO;2BACvC,OAAO,uBAAuB,EAAE,YAAY;+BAC5C,OAAO,uBAAuB,EAAE,gBAAgB;wBAChD,OAAO,uBAAuB,EAAE,SAAS;gCAEzC,QAAQ,GACd,OAAO,GACP;IAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GAClD,CAAC,MAAM,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,GAC7C,IAAI,GACJ,SAAS;8BAIa,CAAC,SAAhB,YAAa,mDACd,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,iBAAiB,CAAA;CAAE;sCAI9B,CAAC,SAAhB,YAAa,mDACd,iBAAiB,CAAC,CAAC,CAAC,GAC1B,CAAC,MAAM,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAC/C,IAAI,GACJ,SAAS;iCAuBT,uBAAuB"}
|
package/react/index.js
CHANGED
|
@@ -16,6 +16,34 @@
|
|
|
16
16
|
* const toast = useToast();
|
|
17
17
|
* return <button onClick={() => toast('Saved', { tone: 'success' })}>Save</button>;
|
|
18
18
|
* }
|
|
19
|
+
*
|
|
20
|
+
* The public types below are JSDoc `@typedef`s; the shipped `index.d.ts` is
|
|
21
|
+
* generated from them (and these signatures) by `tsc --emitDeclarationOnly`.
|
|
22
|
+
*
|
|
23
|
+
* @typedef {import('../behaviors/index.js').Cleanup} Cleanup
|
|
24
|
+
* @typedef {import('../behaviors/index.js').DelegateOpts} DelegateOpts
|
|
25
|
+
* @typedef {import('../behaviors/index.js').ThemeStorageOpts} ThemeStorageOpts
|
|
26
|
+
* @typedef {import('../behaviors/index.js').ToastOpts} ToastOpts
|
|
27
|
+
*
|
|
28
|
+
* @typedef {Document
|
|
29
|
+
* | Element
|
|
30
|
+
* | { current: Document | Element | null | undefined }
|
|
31
|
+
* | (() => Document | Element | null | undefined)
|
|
32
|
+
* | null
|
|
33
|
+
* | undefined} BrontoBindingRoot
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @template {DelegateOpts} [T=DelegateOpts]
|
|
38
|
+
* @typedef {Omit<T, 'root'> & { root?: BrontoBindingRoot }} BrontoBindingOpts
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @template {DelegateOpts} [T=DelegateOpts]
|
|
43
|
+
* @typedef {BrontoBindingOpts<T>
|
|
44
|
+
* | (() => BrontoBindingOpts<T> | null | undefined)
|
|
45
|
+
* | null
|
|
46
|
+
* | undefined} BrontoBindingOptsResolver
|
|
19
47
|
*/
|
|
20
48
|
import { useEffect } from 'react';
|
|
21
49
|
import {
|
|
@@ -53,36 +81,62 @@ function resolveRoot(root) {
|
|
|
53
81
|
function resolveOpts(opts) {
|
|
54
82
|
const value = resolveMaybe(opts);
|
|
55
83
|
if (!value || typeof value !== 'object') return undefined;
|
|
84
|
+
// No `root` key → no scope requested; leave root out so the behavior
|
|
85
|
+
// delegates from `document`. A `root` key that resolves falsy means a scope
|
|
86
|
+
// WAS requested but the ref is not ready: emit `root: null` so the behavior
|
|
87
|
+
// no-ops instead of hijacking the whole document.
|
|
88
|
+
if (!('root' in value)) return { ...value };
|
|
56
89
|
const root = resolveRoot(value.root);
|
|
57
|
-
return
|
|
90
|
+
return { ...value, root: root || null };
|
|
58
91
|
}
|
|
59
92
|
|
|
60
93
|
/** Run a delegated behavior for the component's lifetime (init on mount, its
|
|
61
94
|
* returned cleanup on unmount). The behavior is run once; `opts` resolves
|
|
62
|
-
* on mount so refs are usable for scoped roots.
|
|
95
|
+
* on mount so refs are usable for scoped roots.
|
|
96
|
+
* @param {(opts?: DelegateOpts) => Cleanup | void} init
|
|
97
|
+
* @param {BrontoBindingOptsResolver} [opts]
|
|
98
|
+
* @returns {void} */
|
|
63
99
|
export function useBrontoBehavior(init, opts) {
|
|
64
100
|
useEffect(() => init(resolveOpts(opts)), []); // eslint-disable-line react-hooks/exhaustive-deps -- delegated once on mount
|
|
65
101
|
}
|
|
66
102
|
|
|
103
|
+
/** @param {BrontoBindingOptsResolver<ThemeStorageOpts & DelegateOpts>} [opts] @returns {void} */
|
|
67
104
|
export const useThemeToggle = (opts) => useBrontoBehavior(initThemeToggle, opts);
|
|
105
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
68
106
|
export const useDismissible = (opts) => useBrontoBehavior(dismissible, opts);
|
|
107
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
69
108
|
export const useDisclosure = (opts) => useBrontoBehavior(initDisclosure, opts);
|
|
109
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
70
110
|
export const useMenu = (opts) => useBrontoBehavior(initMenu, opts);
|
|
111
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
71
112
|
export const useFormValidation = (opts) => useBrontoBehavior(initFormValidation, opts);
|
|
113
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
72
114
|
export const useCombobox = (opts) => useBrontoBehavior(initCombobox, opts);
|
|
115
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
73
116
|
export const usePopover = (opts) => useBrontoBehavior(initPopover, opts);
|
|
117
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
74
118
|
export const useTableSort = (opts) => useBrontoBehavior(initTableSort, opts);
|
|
119
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
75
120
|
export const useTabs = (opts) => useBrontoBehavior(initTabs, opts);
|
|
121
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
76
122
|
export const useDialog = (opts) => useBrontoBehavior(initDialog, opts);
|
|
123
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
77
124
|
export const useCarousel = (opts) => useBrontoBehavior(initCarousel, opts);
|
|
125
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
78
126
|
export const useDotGlyph = (opts) => useBrontoBehavior(initDotGlyph, opts);
|
|
127
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
79
128
|
export const useLegend = (opts) => useBrontoBehavior(initLegend, opts);
|
|
129
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
80
130
|
export const useConnectors = (opts) => useBrontoBehavior(initConnectors, opts);
|
|
131
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
81
132
|
export const useSpotlight = (opts) => useBrontoBehavior(initSpotlight, opts);
|
|
133
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
82
134
|
export const useCrosshair = (opts) => useBrontoBehavior(initCrosshair, opts);
|
|
135
|
+
/** @param {BrontoBindingOptsResolver} [opts] @returns {void} */
|
|
83
136
|
export const useCommand = (opts) => useBrontoBehavior(initCommand, opts);
|
|
84
137
|
|
|
85
|
-
/** The `toast()` imperative (no lifecycle of its own).
|
|
138
|
+
/** The `toast()` imperative (no lifecycle of its own).
|
|
139
|
+
* @returns {(message: string, opts?: ToastOpts) => Cleanup} */
|
|
86
140
|
export const useToast = () => toast;
|
|
87
141
|
|
|
88
142
|
// No-flash theme application has to run before paint; do it in an inline head
|