@plitzi/sdk-style 0.38.6 → 0.38.8

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 CHANGED
@@ -1,5 +1,216 @@
1
1
  # @plitzi/sdk-style
2
2
 
3
+ ## 0.38.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [1b45aae]
8
+ - @plitzi/sdk-shared@0.38.8
9
+ - @plitzi/sdk-event-bridge@0.38.8
10
+ - @plitzi/sdk-variables@0.38.8
11
+
12
+ ## 0.38.7
13
+
14
+ ### Patch Changes
15
+
16
+ - c7bbc2b: ## A server project's `src/main.ts` is a few lines
17
+
18
+ - **`serveProject` from `@plitzi/sdk-server/project`**: the generated `src/main.ts` hands the space, its actions and
19
+ its options to the server, and the rest comes with the package — the port, the plugins of `src/plugins` and
20
+ `vendor/plugins`, the functions and runtime, `public/`, `src/data/`, the `kv` in `state/kv.json`, `/health`,
21
+ `tmp/dev-server.json` and the reloads while developing. A fix there arrives with `npm update`, not `plitzi upgrade`.
22
+ - **No more `tmp/space.json` while developing**: a saved space is authored again in its own process and handed to the
23
+ server over IPC (`plitzi/author.ts --ipc`, in place of `--out`); the server swaps it in memory and the open pages
24
+ reload, and a refused space keeps the last one that authored. `plitzi doctor` reports a leftover `tmp/space.json`.
25
+ - **`projectAuthoring()` in `@plitzi/sdk-authoring/node`**: what a project's space is checked against — its plugins'
26
+ declarations, its built plugins, its data files — once, for the server and `npm run author` alike. Neither it nor
27
+ `serveProject` takes a root: it is the working directory, where every script runs (`projectAuthoringAt(root)` for a
28
+ tool working on another folder).
29
+ - **`authorProjectSpace` and `projectSpace()` in `@plitzi/sdk-authoring/node`**: the project's space read from
30
+ `src/space/index.ts` — `dist/space/index.js` when the server runs built — once its root and layout are checked, and
31
+ authored. `src/main.ts` is `serveProject({ space: authorProjectSpace, actions, connectors, serverOptions })`, with no
32
+ import of the space; `plitzi/author.ts`, the visual tests and the CLI's checks read it the same way. A module that
33
+ exports no `space` is refused saying what to export (`ProjectSpaceError`).
34
+ - **`.env` lives at the root and Node reads it** as each script starts (`--env-file-if-exists=.env`; `start:dev`
35
+ preloads `@plitzi/sdk-server/env`, since a watched process would restart on every change beside the file). Settings
36
+ read at the top level of `src/config/serverOptions.ts` or the actions are set. Every project gets `.env` and
37
+ `.env.example`; `plitzi upgrade` removes the old `src/env.ts`.
38
+ - **One check of a project's layout** (`@plitzi/sdk-shared/project/layout`): a plugin folder with no entry, a
39
+ JavaScript entry, `src/plugin/` for `src/plugins/`, a `.env` inside `src/`, a space exported by default, a broken
40
+ `vendor/` plugin… The server refuses to boot listing every error with its fix, `npm run author` and the CLI's checks
41
+ refuse with the same words, `plitzi doctor` lists them under `layout` and `--fix` makes the ones with a single fix,
42
+ and `plitzi lint` points at doctor. A plugin folder added broken while developing is reported in the terminal
43
+ instead of failing in esbuild. Plugins may start at `index.tsx`.
44
+ - **`createJsonAdapters` serves documents held in memory**: `offlineData` may be a function returning them, not only a
45
+ path.
46
+ - **One source for a project's layout**, `@plitzi/sdk-shared/project/paths`; `src/config/serverOptions.ts` is typed
47
+ `ProjectServerOptions`. `plitzi upgrade files --write` brings an existing project's `main.ts` and `author.ts` up.
48
+ - **`npm run build` no longer fails on a plugin's stylesheet**: `tsconfig.build.json` includes `plitzi/assets.d.ts`,
49
+ which a space importing a plugin's declaration reaches through its component.
50
+
51
+ ## A write refreshes what shows it
52
+ - **Writes now refresh server-driven providers.** `runServerAction`, `webHook`, `writeRecord` and the
53
+ `invalidateQueries` step reach `runtime: 'server'` api containers by id, by `query` URL, or all of them, just as
54
+ they reach cached browser requests. Before, they reached only the browser's query cache, so a saved write left the
55
+ page showing the old value until a reload. Hidden providers refresh when they are shown.
56
+ - **A refresh because something changed asks around every cache.** `performQuery`, writes and invalidations send
57
+ `Cache-Control: no-cache`; `/_rsc` resolves such a request again instead of serving its cached slice, and keeps the
58
+ new answer. A `refreshSeconds` timer and a "load more" page still go through the caches.
59
+ - **`refreshRsc`'s fourth argument is an options object**, `{ location?, fresh? }`.
60
+
61
+ ## A space's functions read its data
62
+ - **`ctx.data('products.json')`** reads one file of the space's data (a project's `src/data/`), parsed and read-only,
63
+ as of the run's version. Plugins' functions are refused it.
64
+ - **Self-hosted servers read `dataDir` through the same lookup as the platform**, so `/data/<file>` providers and
65
+ `ctx.data` read the same files; `plitzi functions dev` reads `src/data`. `/data/../x.json` is now the provider's
66
+ error state instead of falling through to `publicDir`.
67
+ - **Importing a file outside `functions/` names the boundary and the fix**: read the space's data with
68
+ `ctx.data('<file>')`.
69
+
70
+ ## Signing in on a self-hosted server
71
+ - **`createServer({ auth })` tells the pages it renders where to sign in** (`server.auth`: provider, endpoints and
72
+ the session hint cookie), so a space signs in with no auth settings declared. Settings a space does declare still
73
+ win, and a space that names another provider ignores the server's description. New `pageAuth` server option, for a
74
+ deployment whose `/auth` flows are served by another host.
75
+ - **A page with no auth provider no longer offers `auth.login` / `auth.logout`**, and a sign-in that cannot work says
76
+ why in the console (`[plitzi] auth.login: …`) instead of failing silently. What a visitor keeps there
77
+ (`keepState`, `paintedState`) is the browser's, as on any space without accounts: what was kept as a guest's on such
78
+ a page before is let go once, on the first visit after the upgrade.
79
+ - **Renewal verifies the refresh token itself.** `findByRefreshToken` no longer has to report `refreshExpiresAt`; when
80
+ it does, it overrides the token's own expiry.
81
+ - **New authoring reference `auth.md`**: providers, `authLogin` and its result, `authLogout`, `{{ auth.* }}`,
82
+ `accessLevel`, visitor roles, action `access` and `ctx.user`.
83
+
84
+ ## Flows
85
+ - **Authoring refuses a `when` that asks a step for a key it never publishes** (`condition-field-unpublished`).
86
+ `whenSucceeded` / `whenFailed` after `authLogin` always ran the failure branch: they read a server action's
87
+ `status`. The message names what the step publishes and suggests testing `signedIn.ok` with `when`.
88
+ - **`explain` lists what a step publishes** (`Reads:`) and finds the auth steps by their builders (`authLogin`,
89
+ `authLogout`, `authRefreshDetails`). `authLogin({ username, password })` no longer needs `mode`.
90
+
91
+ ## Elements
92
+ - **Images no longer default to a 140×140 square**: they are 140px wide and as tall as their ratio, so `width` or
93
+ `aspect-ratio` on a class just works. `object-fit` shows in the builder too.
94
+ - **`formControl` with `subType: 'switch'` renders an on/off switch** (`role="switch"`) — it rendered only its label.
95
+ Checkboxes and switches show a `true` default or binding as ticked.
96
+ - **The theme toggle drops the native button look**, and the **`current` style state covers the chosen item of any
97
+ set**: the link to the page shown, a pressed toggle, a selected tab. The exported `CURRENT_PAGE_SELECTOR` is now
98
+ `CURRENT_SELECTOR`.
99
+ - **Element defaults in the style inspector and the MCP catalogue match what the SDK renders**, held by a test. The
100
+ dialog's `bodyContainer` and `headerCloseButton` slots now reach the page; pagination lays out as declared.
101
+ - **Markdown takes a class for each part of the document** through its own slot (`heading`, `paragraph`, `link`,
102
+ `list`, `listItem`, `quote`, `code`, `codeBlock`, `image`, `table`, `anchor`), and `headingLinks: false` drops the
103
+ link each heading offers to itself while keeping its id, so `/page#anchor` links still work. Its description spells
104
+ out the HTML it outputs.
105
+ - **Tabs show every trigger.** The SDK hid every inactive tab item, the header's included, so a set of tabs showed
106
+ one tab and no way to the others; only the body's panels take turns now.
107
+ - **A link that names a query is current only on that query**: of `/?window=6h` and `/?window=24h`, the one shown
108
+ carries `aria-current` — with the path alone, every one of them did. A link with no query is still current on its
109
+ page whatever the query.
110
+
111
+ ## The style language says what `customCss` used to
112
+ - **Pseudo-elements on a class**: `pseudos: { after: { css: { content: '"→"' }, states: { hover: { … } } } }` —
113
+ `before`, `after`, `marker`, `placeholder`, `first-letter`, `first-line`, `selection`, each in the class's states and
114
+ variants. Authoring refuses what draws nothing: a `before`/`after` with no `content`, a `content` without its quotes,
115
+ a property the browser drops on that pseudo-element.
116
+ - **Conditions on a class**: `conditions: { 'motion-reduce': { … }, 'container card (max-width: 30rem)': { … } }` —
117
+ reduced or allowed motion, and container widths, each with its states and pseudo-elements.
118
+ - **The space's `keyframes`**, validated and written at the top of `customCss`; an `animation-name` no keyframes declare
119
+ is warned (`animation-name-unknown`).
120
+ - **New states**: `expanded` (`aria-expanded`), `first`, `last`, `odd`, `even`; the tab panel on show is `current`, and
121
+ the theme toggle's icon of the scheme in use is `current` on its `icon` slot.
122
+ - **`ancestors['>']`** is the parent, whatever it wears — a closed component's part reacting to the element around it.
123
+ - The builder's style inspector, the MCP's definition ops (`pseudos`, `conditions`, and variants with their states) and
124
+ the export to code read and write all of it; an MCP `patchDefinition` no longer drops what it did not name. Rules in
125
+ `customCss` a class can hold now — `.link::after`, one under `@media (prefers-reduced-motion: reduce)`, `.row:first-child`,
126
+ `.row:nth-child(even)`, `.toggle[aria-expanded='true']` — are folded into the class on export and suggested by
127
+ `custom-css-class`.
128
+
129
+ ## Elements take a class for each part
130
+ - **`formControl`**: `field` (the `<input>` itself), `icon` (the show-password button) and `requiredMark` slots; a switch's
131
+ knob reads in dark mode and takes `--plitzi-switch-thumb`, `--plitzi-switch-thumb-checked`, `--plitzi-switch-thumb-shadow`.
132
+ - **`pagination`**: `previous`, `page` (the one shown is its `current` state), `next`, `loadMore`.
133
+ - **`richText`** and **`markdown`**: a slot per part — `heading` and `heading1`…`heading6`, `strong`, `emphasis`,
134
+ `divider`, `tableHead`, `tableRow`, `tableHeaderCell`, `tableCell`, and the code block's frame, header, language and
135
+ copy button. Both heading slots dress one `<h3>`, so `heading-level-overridden` warns when they set the same property
136
+ and the stylesheet's order makes the general one win. A document is drawn by the SDK's own renderer
137
+ (`MarkdownDocument` in `@plitzi/sdk-elements`) — plitzi-ui's `Markdown` keeps GitHub's stylesheet for a library's
138
+ consumers — and reads as a document unstyled: headings, lists, code, tables and quotes get their type from the SDK's
139
+ base layer, at no weight (`:where()`), so a class on a part's slot replaces what it sets property by property. A
140
+ `richText` body reads the same.
141
+ - `custom-css-slot` suggests the slot for a `customCss` rule on a part's SDK class — only where a class on the slot can
142
+ say the rest of the selector (a state, a pseudo-element); `element-slot-unknown` warns of a slot an element does not
143
+ have.
144
+
145
+ ## Links, refreshes and toasts
146
+ - **`current: 'section'` on a link** keeps it current on its page and every page under its path (`aria-current="true"`
147
+ there), styled by the `current` state — no `activeOn` binding for a section.
148
+ - **A refresh asks only about elements the page shown holds**: a provider on the page being left no longer sends a
149
+ `/_rsc` about the new address.
150
+ - **The toasts' parts are `notifications` fields**: `minHeight`, `fontWeight`, `lineHeight`, `iconSize`, `iconGap`,
151
+ `closeColor`, `closeOpacity`, `progressHeight`.
152
+ - **A page asked for with its space's token hydrates its own space.** On a host serving many spaces
153
+ (`?access-token=`), the space document fetched beside the page went without the token, so the host's own space
154
+ answered it and the browser hydrated another space's document over the page — a hydration error, and its tree
155
+ rebuilt. The document's address now carries the token the page was asked for with.
156
+ - **The SDK's stylesheet carries the space's variables from the server's HTML.** It read them from what a provider
157
+ below it publishes while the page renders, which the server had not done yet when it wrote the sheet; it now
158
+ resolves them from the document itself (`useResolvedVariables` of `@plitzi/sdk-shared/dataSource/hooks`), the same
159
+ on both sides.
160
+ - **A realtime message the pub/sub cannot deliver is answered, not fatal.** A publish that Redis refuses — a timeout under
161
+ load — is answered `503` with `reason: 'unavailable'`, by the `POST` and in the WebSocket's `ack` alike; a connect,
162
+ a disconnect or a revoke that fails is logged, on either transport. Each used to reject with nobody waiting, and the server's `unhandledRejection` handler
163
+ shut the whole process down.
164
+
165
+ ## Reporting to Plitzi
166
+ - **`plitzi feedback`** starts a report of what broke, misled or cost time: it writes the page the report is laid out
167
+ in (`tmp/feedback/`) with the installed versions, the project and what `doctor` finds already in it, and tells the
168
+ agent how to fill it — each finding reproduced first, with evidence, impact, workaround and fix, no secrets — and to
169
+ publish it as an artifact whose link the developer sends. `--previous <url>` continues an earlier report.
170
+
171
+ ## Pages that load on every browser
172
+ - **The import map comes before anything that loads a module**, in the page server's HTML, a published site's
173
+ (`index.hbs` on the platform), the SDK's and the builder's. React's `modulepreload` links came first, and a browser
174
+ that had fetched a module already — Chrome before 133 — ignored the map: every bare `import "react"` failed
175
+ ("Failed to resolve module specifier") and the page never hydrated.
176
+
177
+ ## The dev tools
178
+ - **A page loads the React its dev tools need.** The development build only while the visitor has the dev tools on
179
+ (shift+F12, within what the deployment allows); turned off, the next load is a production page, React included. It
180
+ followed the authorization alone, so a space that allowed debugging always shipped development React.
181
+
182
+ ## check and lint
183
+ - **`plitzi check`, `push`, `lint` and `fix` hold the space to what `npm run author` and the server do**: its data
184
+ files too, so `push` no longer sends a space whose browser provider reads `src/data/` (`server-data-in-browser`).
185
+ - **`plitzi check` lists each list's rows as drawn and as held in its source** (`feed 4 of 8 rows`,
186
+ `hits not rendered (16 in its source)`). In `--json`, `lists` is now `{ id: { rendered, source } }`.
187
+ - **`plitzi check` no longer reports bindings inside a container the page isn't showing**, nor text "in the colour
188
+ behind it" because of a bar painted over it or a pane that clips it.
189
+ - **`window.__plitzi.sources()` no longer turns a shared array into `'[…]'`**, and a list row no longer replaces its
190
+ list's `items`.
191
+ - **`plitzi lint` says authoring suggestions are quieted with `quiet` on the element**, and reports a
192
+ `plitzi-lint-disable` comment that names one (`disable-names-suggestion`).
193
+ - **`plitzi check` says when a page sent the browser elsewhere** (a page for signed-in visitors, to the sign-in) instead
194
+ of reporting every element missing, and `--as <username>` signs in first through the server's `/auth` routes, the
195
+ password from `PLITZI_CHECK_PASSWORD`.
196
+ - **`plitzi upgrade` never replaces @plitzi packages installed locally** — a tarball, a link, a portal, an override: it
197
+ leaves them and the install, and says which and the command that would install the registry's.
198
+ - **`plitzi explain` covers every code**: authoring's, `plitzi lint`'s and the project layout's.
199
+ - **Authoring reads the global sources' fields**: `auth.authenticated` in a condition is refused with "did you mean
200
+ `isAuthenticated`?" (`global-field-unknown`), and `invalidateElements` must name providers that exist
201
+ (`element-ids-target`). A template's reads of `computed`, `flags` and the global sources come off the parsed
202
+ template: a string inside it (`'https://auth.acme.com'`) is no longer read as `auth.acme`.
203
+ - **`custom-css-notifications` no longer reads the rules `notifications` itself writes** as toasts dressed by hand.
204
+ - **A refused space or layout is a report, not a stack**: the server's entry point imports the space once the layout is
205
+ checked, and `npm start` and `npm run author` print every problem and exit with 1.
206
+ - **New authoring suggestion `class-overrides-class`**: one class's shorthand (`padding`) silently erases a longhand
207
+ (`padding-top`) another class on the same element writes out.
208
+
209
+ - Updated dependencies [c7bbc2b]
210
+ - @plitzi/sdk-event-bridge@0.38.7
211
+ - @plitzi/sdk-shared@0.38.7
212
+ - @plitzi/sdk-variables@0.38.7
213
+
3
214
  ## 0.38.6
4
215
 
5
216
  ### Patch Changes
@@ -3,6 +3,8 @@ export declare const isStyleObject: (obj: Partial<StyleObject>) => boolean;
3
3
  export declare const isStyleStates: (obj: NonNullable<StyleBlock["states"]>) => boolean;
4
4
  export declare const isStyleVariants: (obj: NonNullable<StyleBlock["variants"]>) => boolean;
5
5
  export declare const isStyleAncestors: (obj: NonNullable<StyleBlock["ancestors"]>) => boolean;
6
+ export declare const isStylePseudos: (obj: NonNullable<StyleBlock["pseudos"]>) => boolean;
7
+ export declare const isStyleConditions: (obj: NonNullable<StyleBlock["conditions"]>) => boolean;
6
8
  export declare const isStyleBlock: (obj: StyleBlock) => boolean;
7
9
  export declare const isStyleAttributes: (obj?: StyleAttributes) => boolean;
8
10
  declare const isValidValue: (path?: StyleCategory, value?: StyleAttributes | StyleValue | Partial<StyleObject> | StyleBlock | StyleVariants | StyleStates, params?: {
@@ -1,7 +1,9 @@
1
+ import { canonicalCondition as e } from "@plitzi/sdk-shared/style/styleConditions";
2
+ import { isStylePseudo as t } from "@plitzi/sdk-shared/style/stylePseudos";
1
3
  //#region src/StyleMap/helpers/isValueValid.ts
2
- var e = (e) => typeof e == "string" || typeof e == "number" || e === void 0, t = (e) => typeof e == "object" && !!e && !Array.isArray(e), n = (n) => t(n) && Object.values(n).every(e), r = (e) => t(e) && Object.values(e).every(n), i = (e) => t(e) && Object.values(e).every((e) => !(!t(e) || "variants" in e || "ancestors" in e || "default" in e && e.default && !n(e.default) || "states" in e && e.states && !r(e.states))), a = (e) => t(e) && Object.values(e).every((e) => t(e) && (!e.default || n(e.default)) && (!e.states || r(e.states)) && (!e.variants || i(e.variants))), o = (e) => !(!t(e) || !e.default || !n(e.default) || e.states && !r(e.states) || e.variants && !i(e.variants) || e.ancestors && !a(e.ancestors)), s = (e) => e === void 0 || t(e) && !Object.keys(e).length || t(e) && "base" in e && Object.values(e).every(o), c = (a, c, l) => {
3
- let { styleSelector: u, styleVariant: d, styleState: f } = l ?? {};
4
- return !a && !u && !d && !f ? s(c) : !a && !u && d && f ? !1 : !a && !u && d ? i(c) : !a && !u && f ? r(c) : a ? e(c) : u ? c === void 0 ? !0 : e(c) || !t(c) ? !1 : n(c) || o(c) || o(c[u]) : !1;
4
+ var n = (e) => typeof e == "string" || typeof e == "number" || e === void 0, r = (e) => typeof e == "object" && !!e && !Array.isArray(e), i = (e) => r(e) && Object.values(e).every(n), a = (e) => r(e) && Object.values(e).every(i), o = (e) => r(e) && Object.values(e).every((e) => !(!r(e) || "variants" in e || "ancestors" in e || "conditions" in e || "pseudos" in e && e.pseudos && !l(e.pseudos) || "default" in e && e.default && !i(e.default) || "states" in e && e.states && !a(e.states))), s = (e) => r(e) && Object.values(e).every((e) => r(e) && (!e.default || i(e.default)) && (!e.states || a(e.states)) && (!e.variants || o(e.variants))), c = (e) => r(e) && (!e.default || i(e.default)) && (!e.states || a(e.states)), l = (e) => r(e) && Object.entries(e).every(([e, n]) => t(e) && c(n)), u = (t) => r(t) && Object.entries(t).every(([t, n]) => e(t) === t && c(n) && (!n.pseudos || l(n.pseudos))), d = (e) => !(!r(e) || !e.default || !i(e.default) || e.states && !a(e.states) || e.variants && !o(e.variants) || e.ancestors && !s(e.ancestors) || e.pseudos && !l(e.pseudos) || e.conditions && !u(e.conditions)), f = (e) => e === void 0 || r(e) && !Object.keys(e).length || r(e) && "base" in e && Object.values(e).every(d), p = (e, t, s) => {
5
+ let { styleSelector: c, styleVariant: l, styleState: u } = s ?? {};
6
+ return !e && !c && !l && !u ? f(t) : !e && !c && l && u ? !1 : !e && !c && l ? o(t) : !e && !c && u ? a(t) : e ? n(t) : c ? t === void 0 ? !0 : n(t) || !r(t) ? !1 : i(t) || d(t) || d(t[c]) : !1;
5
7
  };
6
8
  //#endregion
7
- export { c as default, a as isStyleAncestors, s as isStyleAttributes, o as isStyleBlock, n as isStyleObject, r as isStyleStates, i as isStyleVariants };
9
+ export { p as default, s as isStyleAncestors, f as isStyleAttributes, d as isStyleBlock, u as isStyleConditions, i as isStyleObject, l as isStylePseudos, a as isStyleStates, o as isStyleVariants };
@@ -1,6 +1,5 @@
1
- import { StyleBlock, StyleCategory, StyleItem, StyleObject, StyleState, StyleStates, StyleValue, StyleVariants } from '@plitzi/sdk-shared';
1
+ import { StyleBlock, StyleCategory, StyleItem, StyleObject, StyleStates, StyleTarget, StyleValue, StyleVariants } from '@plitzi/sdk-shared';
2
2
  declare const parseValue: (path: StyleCategory | undefined, value: StyleItem["attributes"] | StyleValue | Partial<StyleObject> | StyleVariants | StyleStates | StyleBlock | undefined, prevValue: StyleObject) => StyleObject;
3
- declare const getTargetPath: (styleSelector: string, styleVariant?: string, styleState?: string, styleAncestor?: string) => string;
4
3
  declare const isEmptyObject: (v: unknown) => v is Record<string, unknown>;
5
- declare const writeStyle: (mode: "add" | "update" | undefined, styleItem: StyleItem, styleSelector: string, path?: StyleCategory, value?: StyleItem["attributes"] | StyleValue | Partial<StyleObject> | StyleVariants | StyleStates | StyleBlock, styleState?: StyleState, styleVariant?: string, styleAncestor?: string) => void;
6
- export { getTargetPath, isEmptyObject, parseValue, writeStyle };
4
+ declare const writeStyle: (mode: "add" | "update" | undefined, styleItem: StyleItem, styleSelector: string, path: StyleCategory | undefined, value: StyleItem["attributes"] | StyleValue | Partial<StyleObject> | StyleVariants | StyleStates | StyleBlock | undefined, target: StyleTarget) => void;
5
+ export { isEmptyObject, parseValue, writeStyle };
@@ -1,7 +1,8 @@
1
1
  import { isStyleObject as e } from "./isValueValid.mjs";
2
- import { get as t, omit as n, set as r } from "@plitzi/plitzi-ui/helpers";
2
+ import { omit as t } from "@plitzi/plitzi-ui/helpers";
3
+ import { isStyleRules as n, setAtKeys as r, styleTargetKeys as i, valueAtKeys as a } from "@plitzi/sdk-shared/style/styleTarget";
3
4
  //#region src/StyleMap/helpers/utils.ts
4
- var i = (t, n, r) => {
5
+ var o = (t, n, r) => {
5
6
  if (t && (typeof n == "string" || typeof n == "number")) return {
6
7
  ...r,
7
8
  [t]: n
@@ -12,61 +13,50 @@ var i = (t, n, r) => {
12
13
  return e;
13
14
  }
14
15
  return r;
15
- }, a = (e, t) => t ? `attributes.${e}.ancestors.${t}` : `attributes.${e}`, o = (e, t, n, r) => {
16
- let i = a(e, r);
17
- return t && n ? `${i}.variants.${t}.states.${n}` : t ? `${i}.variants.${t}.default` : n ? `${i}.states.${n}` : `${i}.default`;
18
- }, s = (e) => !!e && typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0, c = (e, i, a, o) => {
19
- let l = t(e, i);
20
- if (!l) return;
21
- let u = n(l, [a]), d = i.includes(".ancestors.") && Object.values(u).every((e) => s(e));
22
- if (Object.keys(u).length && !d || i === o) {
23
- r(e, i, u);
24
- return;
25
- }
26
- let f = i.lastIndexOf(".");
27
- c(e, i.slice(0, f), i.slice(f + 1), o);
28
- }, l = (l = "add", u, d, f, p, m, h, g) => {
29
- let _ = a(d, g), v = o(d, h, m, g), y = !!m || !!h, b = h ? `${_}.variants` : `${_}.states`;
30
- if (p !== void 0) {
31
- if (e(p) && s(p)) {
32
- if (g && !y) {
33
- c(u, _, "default", `attributes.${d}`);
16
+ }, s = (e) => !!e && typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0, c = (e) => typeof e == "object" && !!e && !Array.isArray(e), l = (e) => {
17
+ let t = [];
18
+ for (let n = 0; n + 1 < e.length; n += 2) t.push([e[n], e[n + 1]]);
19
+ return t;
20
+ }, u = (e) => e.includes("ancestors") || e.includes("conditions") || e.includes("pseudos"), d = (e, t) => Object.fromEntries(Object.entries(e).filter(([e]) => e !== t)), f = (e, t, n) => {
21
+ let i = a(e, t);
22
+ if (!c(i)) return;
23
+ let o = d(i, n), l = u(t) && Object.values(o).every((e) => s(e));
24
+ if (Object.keys(o).length && !l || t.length === 1) {
25
+ r(e, t, o);
26
+ return;
27
+ }
28
+ f(e, t.slice(0, -1), t[t.length - 1]);
29
+ }, p = (c = "add", u, d, p, m, h) => {
30
+ let g = u.attributes, _ = [d, ...i(h)], v = !!h.styleAncestor || !!h.styleCondition, y = _.slice(0, v ? 3 : 1), b = l(_.slice(y.length)).filter(([e]) => e !== "default"), x = b.at(0), S = x ? [...y, x[0]] : void 0;
31
+ if (m !== void 0) {
32
+ if (e(m) && s(m)) {
33
+ if (v && !b.length) {
34
+ f(g, y, "default");
34
35
  return;
35
36
  }
36
- if (l === "update" && y && !t(u, b)) return;
37
- r(u, v, {});
37
+ if (c === "update" && S && a(g, S) === void 0) return;
38
+ r(g, _, {});
38
39
  return;
39
40
  }
40
- let n = t(u, v, {});
41
- r(u, v, i(f, p, n));
42
- return;
43
- }
44
- if (l === "add" && !f && y) {
45
- t(u, b) || r(u, v, {});
46
- return;
47
- }
48
- if (f) {
49
- let e = t(u, v, {});
50
- r(u, v, n(e, [f]));
51
- return;
52
- }
53
- if (h && m) {
54
- c(u, `${_}.variants.${h}.states`, m, `attributes.${d}`);
41
+ let t = a(g, _);
42
+ r(g, _, o(p, m, n(t) ? t : {}));
55
43
  return;
56
44
  }
57
- if (h) {
58
- c(u, `${_}.variants`, h, `attributes.${d}`);
45
+ if (c === "add" && !p && S) {
46
+ a(g, S) === void 0 && r(g, _, {});
59
47
  return;
60
48
  }
61
- if (m) {
62
- c(u, `${_}.states`, m, `attributes.${d}`);
49
+ if (p) {
50
+ let e = a(g, _);
51
+ r(g, _, t(n(e) ? e : {}, [p]));
63
52
  return;
64
53
  }
65
- if (g) {
66
- c(u, `attributes.${d}.ancestors`, g, `attributes.${d}`);
54
+ let C = _.at(-1) === "default" ? _.slice(0, -1) : _;
55
+ if (C.length > 1) {
56
+ f(g, C.slice(0, -1), C[C.length - 1]);
67
57
  return;
68
58
  }
69
- r(u, v, {});
59
+ r(g, _, {});
70
60
  };
71
61
  //#endregion
72
- export { o as getTargetPath, s as isEmptyObject, i as parseValue, l as writeStyle };
62
+ export { s as isEmptyObject, o as parseValue, p as writeStyle };
@@ -3,22 +3,23 @@ import t from "../helpers/getStyleItem.mjs";
3
3
  import n, { isStyleAttributes as r } from "../helpers/isValueValid.mjs";
4
4
  import { writeStyle as i } from "../helpers/utils.mjs";
5
5
  import { set as a } from "@plitzi/plitzi-ui/helpers";
6
+ import { styleTargetProblem as o } from "@plitzi/sdk-shared/style/styleTarget";
6
7
  //#region src/StyleMap/methods/addSelector.ts
7
- var o = (o, s, c, l, u, d, f) => {
8
- if (!f) return !1;
9
- let { componentType: p, styleSelector: m, styleState: h, styleVariant: g, styleAncestor: _ } = f;
10
- if (t(o, s, c) || !p && l === "element" || p && l !== "element" || m && typeof m != "string" || !m && (h || g || _) || u && u.includes(".") || !n(u, d, f)) return !1;
11
- let v = {
12
- name: c,
13
- type: l,
14
- attributes: m ? {
15
- [m]: { default: {} },
8
+ var s = (s, c, l, u, d, f, p) => {
9
+ if (!p) return !1;
10
+ let { componentType: m, styleSelector: h, styleState: g, styleVariant: _, styleAncestor: v, stylePseudo: y, styleCondition: b } = p;
11
+ if (t(s, c, l) || !m && u === "element" || m && u !== "element" || h && typeof h != "string" || !h && (g || _ || v || y || b) || o(p) !== void 0 || d && d.includes(".") || !n(d, f, p)) return !1;
12
+ let x = {
13
+ name: l,
14
+ type: u,
15
+ attributes: h ? {
16
+ [h]: { default: {} },
16
17
  base: { default: {} }
17
18
  } : { base: { default: {} } },
18
- componentType: p,
19
+ componentType: m,
19
20
  cache: ""
20
21
  };
21
- return !m && r(d) ? ((!d || !Object.keys(d).length) && (d = { base: { default: {} } }), v.attributes = d, v.cache = e(v), a(o, `${s}.${c}`, v), !0) : (i("add", v, m ?? "base", u, d, h, g, _), v.cache = e(v), a(o, `${s}.${c}`, v), !0);
22
+ return !h && r(f) ? ((!f || !Object.keys(f).length) && (f = { base: { default: {} } }), x.attributes = f, x.cache = e(x), a(s, `${c}.${l}`, x), !0) : (i("add", x, h ?? "base", d, f, p), x.cache = e(x), a(s, `${c}.${l}`, x), !0);
22
23
  };
23
24
  //#endregion
24
- export { o as default };
25
+ export { s as default };
@@ -3,11 +3,12 @@ import t from "../helpers/getStyleItem.mjs";
3
3
  import n from "../helpers/isValueValid.mjs";
4
4
  import { writeStyle as r } from "../helpers/utils.mjs";
5
5
  import { set as i } from "@plitzi/plitzi-ui/helpers";
6
+ import { styleTargetProblem as a } from "@plitzi/sdk-shared/style/styleTarget";
6
7
  //#region src/StyleMap/methods/updateSelector.ts
7
- var a = (a, o, s, c, l, u) => {
8
- if (!u) return !1;
9
- let { componentType: d, styleSelector: f, styleState: p, styleVariant: m, styleAncestor: h } = u, g = t(a, o, s);
10
- return !g || !f || !d && g.type === "element" || d && g.type !== "element" || f && typeof f != "string" || c && c.includes(".") || !n(c, l, u) ? !1 : (r("update", g, f, c, l, p, m, h), i(g, "cache", e(g)), i(a, `${o}.${s}`, g), !0);
8
+ var o = (o, s, c, l, u, d) => {
9
+ if (!d) return !1;
10
+ let { componentType: f, styleSelector: p } = d, m = t(o, s, c);
11
+ return !m || !p || !f && m.type === "element" || f && m.type !== "element" || p && typeof p != "string" || l && l.includes(".") || a(d) !== void 0 || !n(l, u, d) ? !1 : (r("update", m, p, l, u, d), i(m, "cache", e(m)), i(o, `${s}.${c}`, m), !0);
11
12
  };
12
13
  //#endregion
13
- export { a as default };
14
+ export { o as default };
@@ -1,4 +1,4 @@
1
- import { DisplayMode, Element, StyleItem, StyleState } from '@plitzi/sdk-shared';
1
+ import { DisplayMode, Element, StyleItem, StylePseudo, StyleState } from '@plitzi/sdk-shared';
2
2
  export type InspectorProps = {
3
3
  selectors?: StyleItem[];
4
4
  componentType?: string;
@@ -7,10 +7,12 @@ export type InspectorProps = {
7
7
  styleState?: StyleState;
8
8
  styleVariant?: string;
9
9
  styleAncestor?: string;
10
+ stylePseudo?: StylePseudo;
11
+ styleCondition?: string;
10
12
  styleSelector?: string;
11
13
  element?: Element;
12
14
  displayMode: DisplayMode;
13
15
  mode?: 'element' | 'manager';
14
16
  };
15
- declare const Inspector: ({ selectors, componentType, componentSubType, selector, styleState, styleVariant, styleAncestor, styleSelector, element, displayMode, mode }: InspectorProps) => import('react').JSX.Element;
17
+ declare const Inspector: ({ selectors, componentType, componentSubType, selector, styleState, styleVariant, styleAncestor, stylePseudo, styleCondition, styleSelector, element, displayMode, mode }: InspectorProps) => import('react').JSX.Element;
16
18
  export default Inspector;