@kohaku-ui/renderer-wc 0.1.0 → 0.3.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 +59 -0
- package/dist/dom.d.ts +2 -1
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js +3 -8
- package/dist/dom.js.map +1 -1
- package/dist/kohaku-surface.d.ts.map +1 -1
- package/dist/kohaku-surface.js +61 -6
- package/dist/kohaku-surface.js.map +1 -1
- package/dist/parts/action-button.js +1 -1
- package/dist/parts/action-button.js.map +1 -1
- package/dist/parts/chart.d.ts.map +1 -1
- package/dist/parts/chart.js +31 -30
- package/dist/parts/chart.js.map +1 -1
- package/dist/parts/control-select.d.ts.map +1 -1
- package/dist/parts/control-select.js +2 -8
- package/dist/parts/control-select.js.map +1 -1
- package/dist/parts/form.d.ts.map +1 -1
- package/dist/parts/form.js +16 -14
- package/dist/parts/form.js.map +1 -1
- package/dist/parts/kit.d.ts.map +1 -1
- package/dist/parts/kit.js +2 -2
- package/dist/parts/kit.js.map +1 -1
- package/dist/parts/layout.js +3 -3
- package/dist/parts/layout.js.map +1 -1
- package/dist/parts/list.d.ts.map +1 -1
- package/dist/parts/list.js +5 -3
- package/dist/parts/list.js.map +1 -1
- package/dist/parts/loading.d.ts.map +1 -1
- package/dist/parts/loading.js +2 -1
- package/dist/parts/loading.js.map +1 -1
- package/dist/parts/metric.d.ts.map +1 -1
- package/dist/parts/metric.js +7 -5
- package/dist/parts/metric.js.map +1 -1
- package/dist/parts/overlay.d.ts.map +1 -1
- package/dist/parts/overlay.js +8 -8
- package/dist/parts/overlay.js.map +1 -1
- package/dist/parts/spreadsheet.d.ts +2 -1
- package/dist/parts/spreadsheet.d.ts.map +1 -1
- package/dist/parts/spreadsheet.js +168 -27
- package/dist/parts/spreadsheet.js.map +1 -1
- package/dist/parts/tabs.js +4 -4
- package/dist/parts/tabs.js.map +1 -1
- package/dist/parts/text.d.ts.map +1 -1
- package/dist/parts/text.js +12 -11
- package/dist/parts/text.js.map +1 -1
- package/dist/sandbox-mount.d.ts.map +1 -1
- package/dist/sandbox-mount.js +28 -15
- package/dist/sandbox-mount.js.map +1 -1
- package/dist/tree.d.ts.map +1 -1
- package/dist/tree.js +4 -3
- package/dist/tree.js.map +1 -1
- package/dist/types.d.ts +46 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -10
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @kohaku-ui/renderer-wc
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`a26f9be`](https://github.com/yosuque/kohaku/commit/a26f9be35f5702287e79f67f13bd3298bfb73bc5), [`ad51284`](https://github.com/yosuque/kohaku/commit/ad5128464169d389e0c462c59184d411ba359d8e), [`cffc1aa`](https://github.com/yosuque/kohaku/commit/cffc1aac259bfdc8f22c48ae57427a809853924e)]:
|
|
8
|
+
- @kohaku-ui/spec-core@0.3.0
|
|
9
|
+
- @kohaku-ui/data-binding@0.3.0
|
|
10
|
+
- @kohaku-ui/registry@0.3.0
|
|
11
|
+
- @kohaku-ui/renderer-core@0.3.0
|
|
12
|
+
- @kohaku-ui/sandbox@0.3.0
|
|
13
|
+
|
|
14
|
+
## 0.2.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [#23](https://github.com/yosuque/kohaku/pull/23) [`ffff046`](https://github.com/yosuque/kohaku/commit/ffff046628f1779bbc9b1a1a4c9d4256f82a9cd3) Thanks [@yosuque](https://github.com/yosuque)! - `provenance.generatorVersion` / `provenance.kit` (both MAY, spec/SPEC.md §2.1 Appendix item 13):
|
|
19
|
+
the composer now stamps the Spec's `provenance` with the generator identity (`ComposePolicy.generatorVersion`)
|
|
20
|
+
and design kit (`designSystem.kit`'s `{id, version}`) in effect at composition time, whenever either is
|
|
21
|
+
set — on every tier, and preserved unchanged through a cache hit or an L1→L0 fixation.
|
|
22
|
+
|
|
23
|
+
`mountSandbox`'s `kitCss?: string` option is now `@deprecated` (kept, unchanged, backward compatible) in
|
|
24
|
+
favor of `kit?: DesignKitStylesheet | string | ((node, spec) => DesignKitStylesheet | string | undefined)`.
|
|
25
|
+
A versioned `DesignKitStylesheet` (`{id, version, css}`) is compared against the Spec's own
|
|
26
|
+
`provenance.kit` and a mismatch is reported via `bridge.onTelemetry({kind: "kit-mismatch"})` — fail-open,
|
|
27
|
+
never blocking rendering (**SPEC-KIT-001**, SHOULD). This closes the gap where a design kit's CSS and
|
|
28
|
+
vocabulary version had no verification mechanism (a vocabulary bump with no matching CSS change, or vice
|
|
29
|
+
versa, previously rendered unstyled markup with no signal).
|
|
30
|
+
|
|
31
|
+
`kit`'s resolver form, called with the frame's own `node`/`spec`, is available on both `SandboxFrame`
|
|
32
|
+
(React) and `<kohaku-surface>`'s `context.sandbox.kit` (WC, closing the prior React/WC asymmetry). A host
|
|
33
|
+
can read `spec.provenance.kit` inside it to serve each artifact the stylesheet it was actually composed
|
|
34
|
+
against, rather than one stylesheet for the whole surface — replacing `kitCss: ""`'s all-or-nothing
|
|
35
|
+
rollback (previously, silencing a regression in newly generated artifacts by clearing `kitCss` also
|
|
36
|
+
stripped styling from every already-generated artifact under the old kit).
|
|
37
|
+
|
|
38
|
+
Fully additive: existing `kitCss` callers, and Specs whose provenance carries neither field, are
|
|
39
|
+
unaffected. `PROMPT_REVISION` and `policyFingerprint` are untouched by this change.
|
|
40
|
+
|
|
41
|
+
- [#23](https://github.com/yosuque/kohaku/pull/23) [`8f6fe5a`](https://github.com/yosuque/kohaku/commit/8f6fe5aaee025c83c8494f5dc4bd97a2a7513b11) Thanks [@yosuque](https://github.com/yosuque)! - Design kit for L2 free generation: `DesignSystemGuide.kit` (built-in `DEFAULT_KIT_VOCABULARY`) presents component classes (`k-card`, `k-kpi`, `k-table`, …) and a token-driven utility subset to the model and enables the `L2_UNKNOWN_CLASS` lint; `mountSandbox` / `SandboxFrame` / `<kohaku-surface>` inject renderer-core's `defaultDesignKit.css` by default (`kitCss: ""` opts out, any other string is your own kit). The L2 system prompt now carries a design brief. Also, `collectL2Issues` and `collectUnknownKitClasses` are now exported from `@kohaku-ui/composer`'s root barrel (`collectL2Issues` was previously internal).
|
|
42
|
+
|
|
43
|
+
This CSS injection is still not keyed by prompt revision or by the compose cache key, so it still applies to every L2 artifact the host renders — not only new generations — including artifacts already in the compose cache, already fixated, and already promoted into a catalog. Concretely, previously generated HTML now picks up `*,*::before,*::after{box-sizing:border-box}`, `html,body{margin:0;padding:0}`, the `body` rule setting font family/size/line-height/colour/background (an artifact that set only `color` and relied on the browser's white background now sits on the theme background instead, e.g. going dark in dark mode), the `h1`–`h4` heading scale, and the `:focus-visible` ring. An empty CSS string (`kit: ""` / `kitCss: ""` — the `SandboxFrame` prop, `mountSandbox`'s option, or `<kohaku-surface>`'s `context.sandbox.kit`) is still the per-surface opt-out; re-reviewing promoted L2 catalog entries after upgrading is advisable.
|
|
44
|
+
|
|
45
|
+
A separate follow-up narrows this limitation without removing it: `mountSandbox`'s `kit` option now also accepts a versioned `DesignKitStylesheet` (`{id, version, css}`, superseding the now-`@deprecated` `kitCss` string) and a per-node resolver `(node, spec) => …`. The composer stamps the kit and generator identity it composed with onto every delivered Spec (`provenance.generatorVersion` / `provenance.kit`, both MAY — spec/SPEC.md §2.1 Appendix item 13), preserved unchanged through a cache hit or a fixation, and a versioned `kit` is compared against it (`bridge.onTelemetry({kind: "kit-mismatch"})`, fail-open — SPEC-KIT-001). A resolver reading `spec.provenance.kit` can then serve each artifact the CSS it was actually written against instead of one CSS for the whole surface — the fix for the all-or-nothing rollback this note originally described (`kitCss: ""` silencing a new artifact's regression by also stripping styling from every already-generated one). See docs/user-guide.md's design-kit section ("Detecting a stale kit" / "Rolling a kit change back per artifact").
|
|
46
|
+
|
|
47
|
+
- [#23](https://github.com/yosuque/kohaku/pull/23) [`01ed79f`](https://github.com/yosuque/kohaku/commit/01ed79fb52322acafabe89736561d8a66b2ccd39) Thanks [@yosuque](https://github.com/yosuque)! - Built-in parts read the non-color tokens (radius / space / font sizes / shadows) instead of literal px, the KPI renders as a card, tables get a muted header with 1px dividers, and hover / active / focus-visible states come from a theme-neutral stylesheet injected once per document (React) / shadow root (WC) — `PARTS_STATE_CSS` is injected unconditionally in this release, with no opt-out. The L2 sandbox chrome is tokenized and `badge="hidden"` removes the badge. Dialogs and toasts render with a stronger elevation, since `shadow.md`'s default was raised. Pre-existing presenter style functions gained an optional trailing `sizing` argument (default = the light theme's sizing); the new helpers (`metric*Style`, `dataStateNoticeStyle`, `gapFor`, `text-style.ts`, `misc-style.ts`) take `sizing` as a required parameter. New exports: `useSizing` (renderer-react) and `DEFAULT_SIZING` (renderer-core). `FORM_ROOT_STYLE` / `FIELD_ROW_STYLE` / `GAP` are deprecated in favour of `formRootStyle` / `fieldRowStyle` / `gapFor`.
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- [#9](https://github.com/yosuque/kohaku/pull/9) [`1c2a1da`](https://github.com/yosuque/kohaku/commit/1c2a1da8760ce3af8a49d90d803f6a574c851bbe) Thanks [@yosuque](https://github.com/yosuque)! - Bound client-supplied lineage strings (`surface`/`renderer`/`locale` to 64 chars, `specHash`/`artifactId` to 128) in host-rest's request schemas; verify a fixation's `intentHash`/`structureHash` against its own `pinnedSpec` before delivery in composer's `materializeFixation`; resolve `host-a2ui`'s per-ref data model concurrently instead of one ref at a time; and stop `<kohaku-surface>` from rebuilding its whole tree when only `onEvent`/`onNodeError`/`onActionResult` changes, plus repair properties assigned before the element was upgraded (the standard Custom Elements pattern).
|
|
52
|
+
|
|
53
|
+
- [#9](https://github.com/yosuque/kohaku/pull/9) [`0e47898`](https://github.com/yosuque/kohaku/commit/0e478989d5f34980498d27cc95dfae40f8f4868b) Thanks [@yosuque](https://github.com/yosuque)! - Implement `presentSpreadsheet`'s already-declared `sortChange` and `cellEdit` events and `editable` prop in both renderers: a user sort toggle can now emit `sortChange` (`{ value: { field, dir } }`), and `editable: true` turns idle cells into edit-trigger buttons that swap to a text input, coercing the typed value by column type and delivering a changed, valid edit via `cellEdit` (`{ row, value: { column, value, previousValue, rowIndex } }`) over the invoke path — with an optimistic local display that a fresh fetch discards automatically. Also cap `presentSpreadsheet`'s local (non-serverSide) row rendering at 500 rows and make the truncation footer honest when the source reports no `total`.
|
|
54
|
+
- Updated dependencies [[`ffff046`](https://github.com/yosuque/kohaku/commit/ffff046628f1779bbc9b1a1a4c9d4256f82a9cd3), [`8f6fe5a`](https://github.com/yosuque/kohaku/commit/8f6fe5aaee025c83c8494f5dc4bd97a2a7513b11), [`cec01e1`](https://github.com/yosuque/kohaku/commit/cec01e166d2947fe8b4bbbfbe5c306c33aaccf99), [`01ed79f`](https://github.com/yosuque/kohaku/commit/01ed79fb52322acafabe89736561d8a66b2ccd39), [`0e47898`](https://github.com/yosuque/kohaku/commit/0e478989d5f34980498d27cc95dfae40f8f4868b), [`a318995`](https://github.com/yosuque/kohaku/commit/a318995245309f7b492b52a44fbae1a8c891a353), [`cb9f653`](https://github.com/yosuque/kohaku/commit/cb9f6538511151dd59980cc5e98c19d16f3f099d)]:
|
|
55
|
+
- @kohaku-ui/spec-core@0.2.0
|
|
56
|
+
- @kohaku-ui/sandbox@0.2.0
|
|
57
|
+
- @kohaku-ui/renderer-core@0.2.0
|
|
58
|
+
- @kohaku-ui/data-binding@0.2.0
|
|
59
|
+
- @kohaku-ui/registry@0.2.0
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SizingTokens } from "@kohaku-ui/renderer-core";
|
|
1
2
|
/** A teardown function that does nothing. */
|
|
2
3
|
export declare const noop: () => void;
|
|
3
4
|
/** Combines multiple teardowns into one. */
|
|
@@ -19,5 +20,5 @@ export declare function text(value: string): Text;
|
|
|
19
20
|
* Generic placeholder for when a part cannot be rendered (unimplemented type / sandbox not injected / render failure).
|
|
20
21
|
* Same markup as renderer-react's NodeNotice (SpecView.tsx).
|
|
21
22
|
*/
|
|
22
|
-
export declare function nodeNotice(message: string, color: string): HTMLElement;
|
|
23
|
+
export declare function nodeNotice(message: string, color: string, sizing: SizingTokens): HTMLElement;
|
|
23
24
|
//# sourceMappingURL=dom.d.ts.map
|
package/dist/dom.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAGA,6CAA6C;AAC7C,eAAO,MAAM,IAAI,QAAO,IAAU,CAAC;AAEnC,4CAA4C;AAC5C,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,MAAM,IAAI,CAKtE;AAmED;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,EAAE,EAAE,WAAW,GAAG,UAAU,EAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GACxD,IAAI,CAKN;AAED,gIAAgI;AAChI,wBAAgB,EAAE,CAChB,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EACpE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GACzD,WAAW,CAKb;AAED,kIAAkI;AAClI,wBAAgB,QAAQ,CACtB,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,GAClE,IAAI,CAKN;AAID,uHAAuH;AACvH,wBAAgB,KAAK,CACnB,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,MAAM,CAAC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AG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,GAClE,IAAI,CAKN;AAID,uHAAuH;AACvH,wBAAgB,KAAK,CACnB,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EACpE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GACzD,UAAU,CAKZ;AAED,8HAA8H;AAC9H,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAExC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,WAAW,CAI5F"}
|
package/dist/dom.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Groundwork for the raw-DOM builders. Generating strings equivalent to React's inline-style expansion is
|
|
2
2
|
// the mechanism behind pixel-match. The px-suffixing rules for style values follow React's dangerousStyleValue.
|
|
3
|
+
import { renderFailureNoticeStyle } from "@kohaku-ui/renderer-core";
|
|
3
4
|
/** A teardown function that does nothing. */
|
|
4
5
|
export const noop = () => { };
|
|
5
6
|
/** Combines multiple teardowns into one. */
|
|
@@ -118,14 +119,8 @@ export function text(value) {
|
|
|
118
119
|
* Generic placeholder for when a part cannot be rendered (unimplemented type / sandbox not injected / render failure).
|
|
119
120
|
* Same markup as renderer-react's NodeNotice (SpecView.tsx).
|
|
120
121
|
*/
|
|
121
|
-
export function nodeNotice(message, color) {
|
|
122
|
-
const node = el("div", { role: "note" },
|
|
123
|
-
border: `1px dashed ${color}`,
|
|
124
|
-
color,
|
|
125
|
-
borderRadius: 6,
|
|
126
|
-
padding: "8px 12px",
|
|
127
|
-
fontSize: 13,
|
|
128
|
-
});
|
|
122
|
+
export function nodeNotice(message, color, sizing) {
|
|
123
|
+
const node = el("div", { role: "note" }, renderFailureNoticeStyle(color, sizing));
|
|
129
124
|
node.appendChild(text(message));
|
|
130
125
|
return node;
|
|
131
126
|
}
|
package/dist/dom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,gHAAgH;AAEhH,6CAA6C;AAC7C,MAAM,CAAC,MAAM,IAAI,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AAEnC,4CAA4C;AAC5C,MAAM,UAAU,gBAAgB,CAAC,SAAyB;IACxD,OAAO,GAAG,EAAE;QACV,4GAA4G;QAC5G,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;YAAE,SAAS,CAAC,CAAC,CAAE,EAAE,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAS;IAC/B,yBAAyB;IACzB,aAAa;IACb,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,SAAS;IACT,cAAc;IACd,iBAAiB;IACjB,aAAa;IACb,SAAS;IACT,MAAM;IACN,UAAU;IACV,cAAc;IACd,YAAY;IACZ,cAAc;IACd,WAAW;IACX,UAAU;IACV,SAAS;IACT,YAAY;IACZ,aAAa;IACb,cAAc;IACd,YAAY;IACZ,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,SAAS;IACT,OAAO;IACP,SAAS;IACT,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,aAAa;IACb,cAAc;IACd,aAAa;IACb,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,eAAe;IACf,aAAa;CACd,CAAC,CAAC;AAEH,kDAAkD;AAClD,SAAS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pE,KAA0D;IAE1D,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,CAAe,CAAC;IACjE,IAAI,KAAK,IAAI,IAAI;QAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzC,IAAI,KAAK,IAAI,IAAI;QAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,8HAA8H;AAC9H,MAAM,UAAU,IAAI,CAAC,KAAa;IAChC,OAAO,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,KAAa,EAAE,MAAoB;IAC7E,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IAClF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kohaku-surface.d.ts","sourceRoot":"","sources":["../src/kohaku-surface.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"kohaku-surface.d.ts","sourceRoot":"","sources":["../src/kohaku-surface.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,gBAAgB,EAItB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAIxF,OAAO,KAAK,EAAe,cAAc,EAAY,MAAM,YAAY,CAAC;AAExE,2FAA2F;AAC3F,eAAO,MAAM,YAAY,iBAAiB,CAAC;AA0B3C;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,WAAW;;IAW5C,cAYC;IAED,iBAAiB,IAAI,IAAI,CAUxB;IAED,oBAAoB,IAAI,IAAI,CAG3B;IAUD,gGAAgG;IAChG,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IACD,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAK3B;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,cAAc,CAE5B;IACD,IAAI,OAAO,CAAC,IAAI,EAAE,cAAc,EAG/B;IAED,4EAA4E;IAC5E,IAAI,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,EAEvC;IACD,IAAI,KAAK,CAAC,CAAC,EAAE,WAAW,GAAG,SAAS,EAEnC;IACD,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAE/B;IACD,IAAI,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,SAAS,EAEpD;IACD,IAAI,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,EAEvC;IACD,IAAI,WAAW,CAAC,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,EAE/C;IACD,IAAI,cAAc,CAAC,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,EAErD;IACD,IAAI,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,EAEvC;CA2EF;AAED,mEAAmE;AACnE,wBAAgB,mBAAmB,CAAC,OAAO,SAAmB,GAAG,IAAI,CAIpE"}
|
package/dist/kohaku-surface.js
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
import { createDataInvalidationBus, createSpecStateStore, DEFAULT_LOCALE, DEFAULT_MESSAGES, themeTokensToCssVars, } from "@kohaku-ui/renderer-core";
|
|
1
|
+
import { createDataInvalidationBus, createSpecStateStore, DEFAULT_LOCALE, DEFAULT_MESSAGES, PARTS_STATE_CSS, themeTokensToCssVars, } from "@kohaku-ui/renderer-core";
|
|
2
2
|
import { ROOT_COMPONENT_ID } from "@kohaku-ui/spec-core";
|
|
3
3
|
import { noop } from "./dom.js";
|
|
4
4
|
import { createCoreRenderRegistry } from "./registry.js";
|
|
5
5
|
import { createRuntime, mountTree } from "./tree.js";
|
|
6
6
|
/** Name of the forward event dispatched by <kohaku-surface> (detail is a SurfaceEvent). */
|
|
7
7
|
export const KOHAKU_EVENT = "kohaku-event";
|
|
8
|
+
/**
|
|
9
|
+
* Individual context properties whose change requires tearing down and rebuilding the mounted tree
|
|
10
|
+
* (they are baked into the RenderRuntime at #render time — binding/theme/locale/messages feed the
|
|
11
|
+
* BoundDataController / theme resolution / message lookup, and sandbox is read at mount time by the
|
|
12
|
+
* sandbox.html part builder). `onEvent` / `onNodeError` / `onActionResult` are deliberately **not** in
|
|
13
|
+
* this set: they are read live from `#context` at call time (see `#dispatchForward` and the wrapper
|
|
14
|
+
* closures built in `#render`), so reassigning one of them mid-lifecycle must not force a full rebuild.
|
|
15
|
+
*/
|
|
16
|
+
const REBUILD_KEYS = new Set(["binding", "theme", "locale", "messages", "sandbox"]);
|
|
17
|
+
/** Every property <kohaku-surface> exposes as a plain instance accessor (used by #upgradeProperty). */
|
|
18
|
+
const UPGRADE_PROPS = [
|
|
19
|
+
"spec",
|
|
20
|
+
"context",
|
|
21
|
+
"binding",
|
|
22
|
+
"theme",
|
|
23
|
+
"locale",
|
|
24
|
+
"messages",
|
|
25
|
+
"onEvent",
|
|
26
|
+
"onNodeError",
|
|
27
|
+
"onActionResult",
|
|
28
|
+
"sandbox",
|
|
29
|
+
];
|
|
8
30
|
/**
|
|
9
31
|
* The single host element <kohaku-surface> (Shadow DOM). It builds the entire UI Spec tree into one shadow root
|
|
10
32
|
* (rather than a Custom Element per part type — a single-element surface). Spec / context are received as properties.
|
|
@@ -28,13 +50,25 @@ export class KohakuSurface extends HTMLElement {
|
|
|
28
50
|
super();
|
|
29
51
|
const shadow = this.attachShadow({ mode: "open" });
|
|
30
52
|
const style = document.createElement("style");
|
|
31
|
-
// Minimal reset
|
|
32
|
-
|
|
53
|
+
// Minimal reset (appearance is carried by each part's inline style = the pixel-match mechanism), plus
|
|
54
|
+
// the theme-neutral L1 state stylesheet (hover/active/focus-visible rules for the parts). Unlike
|
|
55
|
+
// renderer-react, which hoists one de-duplicated <style> per document (React 19's href/precedence),
|
|
56
|
+
// each shadow root is its own style scope, so it is injected here once per <kohaku-surface> instance.
|
|
57
|
+
style.textContent = `:host{display:block}${PARTS_STATE_CSS}`;
|
|
33
58
|
this.#root = document.createElement("div");
|
|
34
59
|
this.#root.className = "kohaku-root";
|
|
35
60
|
shadow.append(style, this.#root);
|
|
36
61
|
}
|
|
37
62
|
connectedCallback() {
|
|
63
|
+
// Standard Custom Elements "upgrade property" pattern: a value assigned on this element before the
|
|
64
|
+
// class was registered (customElements.define) — a common pattern when the element is constructed
|
|
65
|
+
// eagerly and defined lazily — lands as a plain own-property that shadows this class's accessor
|
|
66
|
+
// forever, so its setter logic (patchContext / re-render) would never fire again once the element is
|
|
67
|
+
// upgraded. Re-apply each such value through its accessor exactly once, here, at upgrade time
|
|
68
|
+
// (connectedCallback always fires after the class is defined). A no-op for an element created after
|
|
69
|
+
// define() (no own-property was ever set).
|
|
70
|
+
for (const prop of UPGRADE_PROPS)
|
|
71
|
+
this.#upgradeProperty(prop);
|
|
38
72
|
if (this.#spec != null)
|
|
39
73
|
this.#render();
|
|
40
74
|
}
|
|
@@ -42,6 +76,14 @@ export class KohakuSurface extends HTMLElement {
|
|
|
42
76
|
this.#teardown();
|
|
43
77
|
this.#teardown = noop;
|
|
44
78
|
}
|
|
79
|
+
#upgradeProperty(prop) {
|
|
80
|
+
const self = this;
|
|
81
|
+
if (!Object.hasOwn(this, prop))
|
|
82
|
+
return;
|
|
83
|
+
const value = self[prop];
|
|
84
|
+
delete self[prop];
|
|
85
|
+
self[prop] = value;
|
|
86
|
+
}
|
|
45
87
|
/** UI Spec. Setting it triggers resetForIntent → rebuild the tree + reattach the controller. */
|
|
46
88
|
get spec() {
|
|
47
89
|
return this.#spec;
|
|
@@ -94,16 +136,20 @@ export class KohakuSurface extends HTMLElement {
|
|
|
94
136
|
// Skip rebuild if there is no effective change after applying the patch (prevents a full rebuild when the same value is re-assigned to a setter).
|
|
95
137
|
// A shallow reference comparison suffices (binding/theme/messages, etc. are updated by swapping object references).
|
|
96
138
|
let changed = false;
|
|
139
|
+
let needsRebuild = false;
|
|
97
140
|
for (const key of Object.keys(patch)) {
|
|
98
141
|
if (this.#context[key] !== patch[key]) {
|
|
99
142
|
changed = true;
|
|
100
|
-
|
|
143
|
+
if (REBUILD_KEYS.has(key))
|
|
144
|
+
needsRebuild = true;
|
|
101
145
|
}
|
|
102
146
|
}
|
|
103
147
|
if (!changed)
|
|
104
148
|
return;
|
|
105
149
|
this.#context = { ...this.#context, ...patch };
|
|
106
|
-
|
|
150
|
+
// onEvent/onNodeError/onActionResult changing does not, by itself, require tearing down and rebuilding
|
|
151
|
+
// the mounted tree (see REBUILD_KEYS's doc) — they are read live from #context, not baked into it.
|
|
152
|
+
if (needsRebuild && this.#spec != null)
|
|
107
153
|
this.#render();
|
|
108
154
|
}
|
|
109
155
|
#render() {
|
|
@@ -136,7 +182,16 @@ export class KohakuSurface extends HTMLElement {
|
|
|
136
182
|
theme,
|
|
137
183
|
locale,
|
|
138
184
|
messages,
|
|
139
|
-
|
|
185
|
+
// onNodeError/onActionResult are wrapped so RenderRuntime always reads the *current* #context value
|
|
186
|
+
// at call time, rather than the value snapshotted at this #render — see REBUILD_KEYS's doc: changing
|
|
187
|
+
// just one of these callbacks does not go through #render again, so RenderRuntime's own onNodeError/
|
|
188
|
+
// onActionResult fields (baked in once here) must forward through a stable indirection instead of
|
|
189
|
+
// holding a stale reference to whatever callback existed when the tree was last built.
|
|
190
|
+
ctx: {
|
|
191
|
+
...this.#context,
|
|
192
|
+
onNodeError: (args) => this.#context.onNodeError?.(args),
|
|
193
|
+
onActionResult: (args) => this.#context.onActionResult?.(args),
|
|
194
|
+
},
|
|
140
195
|
registry: this.#registry,
|
|
141
196
|
dispatchForward: (event) => this.#dispatchForward(event),
|
|
142
197
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kohaku-surface.js","sourceRoot":"","sources":["../src/kohaku-surface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EAEpB,cAAc,EACd,gBAAgB,
|
|
1
|
+
{"version":3,"file":"kohaku-surface.js","sourceRoot":"","sources":["../src/kohaku-surface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EAEpB,cAAc,EACd,gBAAgB,EAChB,eAAe,EAIf,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAiC,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGrD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAuB,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;AAE1G,uGAAuG;AACvG,MAAM,aAAa,GAAG;IACpB,MAAM;IACN,SAAS;IACT,SAAS;IACT,OAAO;IACP,QAAQ;IACR,UAAU;IACV,SAAS;IACT,aAAa;IACb,gBAAgB;IAChB,SAAS;CACD,CAAC;AAEX;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,KAAK,CAAiB;IACtB,KAAK,GAAkB,IAAI,CAAC;IAC5B,QAAQ,GAAmB,EAAE,CAAC;IAC9B,SAAS,GAA6B,wBAAwB,EAAE,CAAC;IAEjE,gJAAgJ;IAChJ,MAAM,GAA0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;gBACxD,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC;aAC/D;YACD,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;SACzD,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IAChE,CAAC;IAED,gBAAgB,CAAC,KAAmB;QAClC,iIAAiI;QACjI,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACpG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;CACF;AAED,mEAAmE;AACnE,MAAM,UAAU,mBAAmB,CAAC,OAAO,GAAG,gBAAgB;IAC5D,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;QACxC,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -26,7 +26,7 @@ export const actionButton = (rt, parent, node, row) => {
|
|
|
26
26
|
button.setAttribute("aria-busy", "true");
|
|
27
27
|
else
|
|
28
28
|
button.removeAttribute("aria-busy");
|
|
29
|
-
setStyle(button, actionButtonStyle(variant, tokens, { disabled }));
|
|
29
|
+
setStyle(button, actionButtonStyle(variant, tokens, { disabled }, rt.sizing));
|
|
30
30
|
};
|
|
31
31
|
apply({ phase: "idle" });
|
|
32
32
|
button.addEventListener("click", () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-button.js","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M,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../src/parts/chart.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../src/parts/chart.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,aAAa,CAAC;AAI9D;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,WAC0D,CAAC"}
|
package/dist/parts/chart.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CHART_TOKEN_KEYS, chartCaptionStyle, chartPointRow, chartTableStyle, describeChartDataTable, resolveChartConfig, resolveToken, visuallyHiddenStyle, } from "@kohaku-ui/renderer-core";
|
|
2
2
|
import { el, setStyle, text } from "../dom.js";
|
|
3
3
|
import { buildChartSvg } from "./chart-svg.js";
|
|
4
4
|
import { dataStateNotice, mountBoundPart } from "./kit.js";
|
|
@@ -12,12 +12,12 @@ export const presentChart = (rt, parent, node) => mountBoundPart(rt, parent, nod
|
|
|
12
12
|
function renderChart(rt, node, state) {
|
|
13
13
|
if (state.status !== "ready")
|
|
14
14
|
return dataStateNotice(rt, state);
|
|
15
|
-
const palette = String(resolveToken(rt.theme,
|
|
15
|
+
const palette = String(resolveToken(rt.theme, CHART_TOKEN_KEYS.palette)).split(",");
|
|
16
16
|
// Resolve the colors of reference lines / axes / point strokes / axis labels from tokens (equivalent to React's useToken path).
|
|
17
17
|
const chartColors = {
|
|
18
|
-
axis: String(resolveToken(rt.theme,
|
|
19
|
-
dotStroke: String(resolveToken(rt.theme,
|
|
20
|
-
axisLabel: String(resolveToken(rt.theme,
|
|
18
|
+
axis: String(resolveToken(rt.theme, CHART_TOKEN_KEYS.axis)),
|
|
19
|
+
dotStroke: String(resolveToken(rt.theme, CHART_TOKEN_KEYS.dotStroke)),
|
|
20
|
+
axisLabel: String(resolveToken(rt.theme, CHART_TOKEN_KEYS.axisLabel)),
|
|
21
21
|
};
|
|
22
22
|
// The config / view model (prop defaults, default label, pointClickable) comes from renderer-core; only the markup is emitted here.
|
|
23
23
|
const cfg = resolveChartConfig(node, rt.spec, state.data.rows, rt.messages);
|
|
@@ -36,13 +36,13 @@ function renderChart(rt, node, state) {
|
|
|
36
36
|
// Give it a name via figure's implicit role + aria-label (no role="img" — let the descendant a11y table be read).
|
|
37
37
|
const figure = el("figure", { "data-kohaku": node.id, "aria-label": label }, { margin: 0, width: "100%" });
|
|
38
38
|
if (title != null) {
|
|
39
|
-
const caption = el("figcaption", {},
|
|
39
|
+
const caption = el("figcaption", {}, chartCaptionStyle(rt.sizing));
|
|
40
40
|
caption.appendChild(text(title));
|
|
41
41
|
figure.appendChild(caption);
|
|
42
42
|
}
|
|
43
43
|
if (kind === "pie" || kind === "scatter") {
|
|
44
44
|
// Not a hand-drawn SVG kind. Substitute with a visible data table (a visible table separate from the a11y table).
|
|
45
|
-
figure.appendChild(visibleFallbackTable(x, yKeys, rows));
|
|
45
|
+
figure.appendChild(visibleFallbackTable(x, yKeys, rows, rt.sizing));
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
// When non-interactive, mark the SVG aria-hidden and defer to the a11y table. When interactive, remove aria-hidden
|
|
@@ -53,51 +53,52 @@ function renderChart(rt, node, state) {
|
|
|
53
53
|
svgHolder.appendChild(buildChartSvg(cfg, chartColors, palette, point));
|
|
54
54
|
figure.appendChild(svgHolder);
|
|
55
55
|
}
|
|
56
|
-
figure.appendChild(a11yTable(label, x, yKeys, rows));
|
|
56
|
+
figure.appendChild(a11yTable(label, x, yKeys, rows, rt.sizing));
|
|
57
57
|
return figure;
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Visually hidden data-table substitute (same as renderer-react's ChartDataTable). Row count is truncated
|
|
61
|
+
* at the cap. The a11y alternative must stay visually hidden regardless of sizing, so visuallyHiddenStyle's
|
|
62
|
+
* position/width/height/clip win over chartTableStyle's own width -- only borderCollapse/fontSize survive
|
|
63
|
+
* from it (a purely additive consistency pickup; the table was previously unstyled beyond visuallyHiddenStyle).
|
|
64
|
+
*/
|
|
65
|
+
function a11yTable(label, x, yKeys, rows, sizing) {
|
|
66
|
+
const { headers, cells } = describeChartDataTable(x, yKeys, rows);
|
|
61
67
|
const table = el("table");
|
|
62
|
-
setStyle(table, visuallyHiddenStyle);
|
|
68
|
+
setStyle(table, { ...chartTableStyle(sizing), ...visuallyHiddenStyle });
|
|
63
69
|
const caption = el("caption");
|
|
64
70
|
caption.appendChild(text(label));
|
|
65
71
|
table.appendChild(caption);
|
|
66
|
-
table.appendChild(headRow(
|
|
67
|
-
table.appendChild(bodyRows(
|
|
72
|
+
table.appendChild(headRow(headers));
|
|
73
|
+
table.appendChild(bodyRows(cells));
|
|
68
74
|
return table;
|
|
69
75
|
}
|
|
70
76
|
/** Visible fallback table for pie/scatter (a plain visible table). */
|
|
71
|
-
function visibleFallbackTable(x, yKeys, rows) {
|
|
72
|
-
const
|
|
73
|
-
table
|
|
74
|
-
table.appendChild(
|
|
77
|
+
function visibleFallbackTable(x, yKeys, rows, sizing) {
|
|
78
|
+
const { headers, cells } = describeChartDataTable(x, yKeys, rows);
|
|
79
|
+
const table = el("table", {}, chartTableStyle(sizing));
|
|
80
|
+
table.appendChild(headRow(headers));
|
|
81
|
+
table.appendChild(bodyRows(cells));
|
|
75
82
|
return table;
|
|
76
83
|
}
|
|
77
|
-
function headRow(
|
|
84
|
+
function headRow(headers) {
|
|
78
85
|
const thead = el("thead");
|
|
79
86
|
const tr = el("tr");
|
|
80
|
-
const
|
|
81
|
-
xh.appendChild(text(x));
|
|
82
|
-
tr.appendChild(xh);
|
|
83
|
-
for (const key of yKeys) {
|
|
87
|
+
for (const header of headers) {
|
|
84
88
|
const th = el("th", { scope: "col" });
|
|
85
|
-
th.appendChild(text(
|
|
89
|
+
th.appendChild(text(header));
|
|
86
90
|
tr.appendChild(th);
|
|
87
91
|
}
|
|
88
92
|
thead.appendChild(tr);
|
|
89
93
|
return thead;
|
|
90
94
|
}
|
|
91
|
-
function bodyRows(
|
|
95
|
+
function bodyRows(cells) {
|
|
92
96
|
const tbody = el("tbody");
|
|
93
|
-
for (const row of
|
|
97
|
+
for (const row of cells) {
|
|
94
98
|
const tr = el("tr");
|
|
95
|
-
const
|
|
96
|
-
xd.appendChild(text(String(row[x] ?? "")));
|
|
97
|
-
tr.appendChild(xd);
|
|
98
|
-
for (const key of yKeys) {
|
|
99
|
+
for (const cell of row) {
|
|
99
100
|
const td = el("td");
|
|
100
|
-
td.appendChild(text(
|
|
101
|
+
td.appendChild(text(cell));
|
|
101
102
|
tr.appendChild(td);
|
|
102
103
|
}
|
|
103
104
|
tbody.appendChild(tr);
|
package/dist/parts/chart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.js","sourceRoot":"","sources":["../../src/parts/chart.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"chart.js","sourceRoot":"","sources":["../../src/parts/chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,YAAY,EAEZ,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,aAAa,EAA0B,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,IAA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;AACf,CAAC;AAED,SAAS,QAAQ,CAAC,KAAiB;IACjC,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IAC1B,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACpB,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;YACvB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YACpB,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3B,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-select.d.ts","sourceRoot":"","sources":["../../src/parts/control-select.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"control-select.d.ts","sourceRoot":"","sources":["../../src/parts/control-select.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,WA+C3B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { boundStateKey, normalizeSelectOptions } from "@kohaku-ui/renderer-core";
|
|
1
|
+
import { boundStateKey, controlSelectStyle, normalizeSelectOptions } from "@kohaku-ui/renderer-core";
|
|
2
2
|
import { el, text } from "../dom.js";
|
|
3
3
|
import { tokenStr } from "./kit.js";
|
|
4
4
|
/**
|
|
@@ -12,13 +12,7 @@ export const controlSelect = (rt, parent, node, row) => {
|
|
|
12
12
|
const options = normalizeSelectOptions(node.props["options"]);
|
|
13
13
|
const placeholder = node.props["placeholder"];
|
|
14
14
|
const label = node.props["label"];
|
|
15
|
-
const select = el("select", { "data-kohaku": node.id }, {
|
|
16
|
-
border: `1px solid ${border}`,
|
|
17
|
-
borderRadius: 6,
|
|
18
|
-
padding: "7px 10px",
|
|
19
|
-
fontSize: 13.5,
|
|
20
|
-
alignSelf: "flex-start",
|
|
21
|
-
});
|
|
15
|
+
const select = el("select", { "data-kohaku": node.id }, { ...controlSelectStyle(border, rt.sizing), alignSelf: "flex-start" });
|
|
22
16
|
if (label != null)
|
|
23
17
|
select.setAttribute("aria-label", String(label));
|
|
24
18
|
if (placeholder != null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-select.js","sourceRoot":"","sources":["../../src/parts/control-select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"control-select.js","sourceRoot":"","sources":["../../src/parts/control-select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACrG,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IAClE,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,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AI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC;IACF,MAAM,CAAC,KAAK,GAAG,SAAS,EAAE,CAAC;IAE3B,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,EAAE;QACrC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,8HAA8H;IAC9H,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACpC,MAAM,IAAI,GAAG,SAAS,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI;YAAE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,GAAG,EAAE;QACV,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/parts/form.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/parts/form.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/parts/form.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAe,WAAW,EAA2B,MAAM,aAAa,CAAC;AAGrF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,WAmJzB,CAAC"}
|