@domql/utils 3.6.3 → 3.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +77 -0
  2. package/extends.js +1 -1
  3. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @domql/utils
2
+
3
+ Core utility functions for the DOMQL element system.
4
+
5
+ ## Propertization (`props.js`)
6
+
7
+ The propertization system normalizes element definitions by sorting keys between the element root (child elements, framework keys) and `props` (CSS properties, design tokens, custom data).
8
+
9
+ ### Two-phase process
10
+
11
+ 1. **`pickupPropsFromElement`** — Scans element root keys and moves non-element, non-builtin keys into `props`
12
+ 2. **`pickupElementFromProps`** — Scans `props` keys and moves element-like or builtin keys back to the element root
13
+
14
+ ### Key classification rules
15
+
16
+ | Pattern | Classification | Example |
17
+ |---------|---------------|---------|
18
+ | Starts with uppercase | Child element | `Header`, `Button`, `Nav` |
19
+ | Numeric key | Child element | `0`, `1`, `2` |
20
+ | In `DOMQ_PROPERTIES` | Framework builtin | `tag`, `extends`, `on` |
21
+ | In `CSS_SELECTOR_PREFIXES` | CSS-in-props | `:hover`, `@mobileS`, `$isActive` |
22
+ | Has define handler | Define key (stays at root) | `$router`, deprecated: `$propsCollection` |
23
+ | `childProps` | Always in props | `childProps` |
24
+ | `onXxx` + function | Event handler | `onClick`, `onSubmit` |
25
+ | Everything else | Prop | `padding`, `theme`, `color` |
26
+
27
+ ### CSS_SELECTOR_PREFIXES
28
+
29
+ ```javascript
30
+ const CSS_SELECTOR_PREFIXES = new Set([
31
+ ':', '@', '[', '*', '+', '~', '&', '>', '$', '-', '.', '!'
32
+ ])
33
+ ```
34
+
35
+ These single-character prefixes identify keys that should be processed by `css-in-props` via `transformersByPrefix`. When a key starts with one of these characters, it gets moved into `props`.
36
+
37
+ ### Define-awareness
38
+
39
+ The `$` prefix is shared between css-in-props conditionals (`$isActive`) and define handlers (built-in `$router`, plus deprecated v2 handlers like `$propsCollection`, `$collection` that some older projects still use). The propertization must check for define handlers **before** applying prefix rules:
40
+
41
+ ```javascript
42
+ // Check define handlers first — these stay at root
43
+ const defineValue = this.define?.[key]
44
+ const globalDefineValue = this.context?.define?.[key]
45
+ if (isFunction(defineValue) || isFunction(globalDefineValue)) continue
46
+
47
+ // Only then apply prefix-based classification
48
+ if (CSS_SELECTOR_PREFIXES.has(firstChar)) {
49
+ obj.props[key] = value
50
+ }
51
+ ```
52
+
53
+ Without this check, define keys like `$router` (or deprecated `$propsCollection` in older projects) get moved into `props` and become invisible to `throughInitialDefine`, breaking routing and collection-based rendering.
54
+
55
+ ### childProps handling
56
+
57
+ `childProps` is a framework property that configures child element props. It must always stay in `props` (consumed by `inheritParentProps`) even though its value may contain uppercase keys that look like child elements:
58
+
59
+ ```javascript
60
+ // childProps: { Icon: { name: 'star' }, Hgroup: { ... } }
61
+ // The uppercase keys inside are NOT child elements
62
+ if (key === 'childProps') {
63
+ obj.props[key] = value
64
+ delete obj[key]
65
+ continue
66
+ }
67
+ ```
68
+
69
+ ### ignoreChildProps
70
+
71
+ When set on `element.props`, prevents the element from inheriting `childProps` from its parent via `inheritParentProps`. Used by fragment elements to avoid double-application of childProps (since fragments explicitly forward childProps to their children).
72
+
73
+ ## Key Sets (`keys.js`)
74
+
75
+ - **`DOMQ_PROPERTIES`** — Framework-level keys that stay at element root
76
+ - **`PROPS_METHODS`** — Keys on the props prototype (update, __element)
77
+ - **`STATE_METHODS`** — State management methods (update, parse, set, toggle, etc.)
package/extends.js CHANGED
@@ -334,7 +334,7 @@ export const getExtendsInElement = obj => {
334
334
  function traverse (o) {
335
335
  for (const key in o) {
336
336
  if (Object.prototype.hasOwnProperty.call(o, key)) {
337
- // Check if the key starts with a capital letter and exclude keys like @mobileL, $propsCollection
337
+ // Check if the key starts with a capital letter and exclude keys like @mobileL, $router
338
338
  if (matchesComponentNaming(key)) {
339
339
  result.push(key)
340
340
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "3.6.3",
3
+ "version": "3.6.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",