@yahoo/uds-create-config 1.1.1
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/dist/AssetGroup.d.ts +77 -0
- package/dist/AssetGroup.js +125 -0
- package/dist/Component.d.ts +308 -0
- package/dist/Component.js +896 -0
- package/dist/ComponentGroup.d.ts +20 -0
- package/dist/ComponentGroup.js +46 -0
- package/dist/CompositeStyle.d.ts +27 -0
- package/dist/CompositeStyle.js +52 -0
- package/dist/Config.d.ts +423 -0
- package/dist/Config.js +1429 -0
- package/dist/Mode.d.ts +41 -0
- package/dist/Mode.js +81 -0
- package/dist/Modifier.d.ts +51 -0
- package/dist/Modifier.js +97 -0
- package/dist/MotionDef.d.ts +49 -0
- package/dist/MotionDef.js +97 -0
- package/dist/Props.d.ts +317 -0
- package/dist/Props.js +35 -0
- package/dist/Provider.d.ts +20 -0
- package/dist/Provider.js +14 -0
- package/dist/StyleProp.d.ts +112 -0
- package/dist/StyleProp.js +197 -0
- package/dist/Token.d.ts +55 -0
- package/dist/Token.js +112 -0
- package/dist/TokenGroup.d.ts +32 -0
- package/dist/TokenGroup.js +68 -0
- package/dist/asset-kind.d.ts +55 -0
- package/dist/asset-kind.js +29 -0
- package/dist/brands.d.ts +30 -0
- package/dist/brands.js +20 -0
- package/dist/captureCallerPath.d.ts +48 -0
- package/dist/captureCallerPath.js +95 -0
- package/dist/colorExpressions.d.ts +131 -0
- package/dist/colorExpressions.js +148 -0
- package/dist/defineAssetGroup.d.ts +166 -0
- package/dist/defineAssetGroup.js +264 -0
- package/dist/defineProvider.d.ts +29 -0
- package/dist/defineProvider.js +60 -0
- package/dist/element-marker.d.ts +54 -0
- package/dist/element-marker.js +113 -0
- package/dist/entity-utils.d.ts +56 -0
- package/dist/entity-utils.js +105 -0
- package/dist/factories.d.ts +707 -0
- package/dist/factories.js +393 -0
- package/dist/foreign-component-name.d.ts +21 -0
- package/dist/foreign-component-name.js +42 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +28 -0
- package/dist/interpolate.d.ts +20 -0
- package/dist/interpolate.js +10 -0
- package/dist/jsx/__fixtures__/cross-component-preview.d.ts +3 -0
- package/dist/jsx/__fixtures__/cross-component-preview.js +15 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +15 -0
- package/dist/jsx/jsx-dev-runtime.js +11 -0
- package/dist/jsx/jsx-runtime.d.ts +48 -0
- package/dist/jsx/jsx-runtime.js +305 -0
- package/dist/markers.d.ts +217 -0
- package/dist/markers.js +67 -0
- package/dist/refs.d.ts +158 -0
- package/dist/refs.js +104 -0
- package/dist/renderer/RendererErrorBoundary.d.ts +26 -0
- package/dist/renderer/RendererErrorBoundary.js +30 -0
- package/dist/renderer/UdsRenderer.d.ts +80 -0
- package/dist/renderer/UdsRenderer.js +33 -0
- package/dist/renderer/assetRenderable.d.ts +13 -0
- package/dist/renderer/assetRenderable.js +13 -0
- package/dist/renderer/index.d.ts +14 -0
- package/dist/renderer/index.js +14 -0
- package/dist/renderer/makeRegistry.d.ts +34 -0
- package/dist/renderer/makeRegistry.js +52 -0
- package/dist/renderer/makeUdsRenderer.d.ts +29 -0
- package/dist/renderer/makeUdsRenderer.js +35 -0
- package/dist/renderer/primitives/FragmentRenderer.d.ts +12 -0
- package/dist/renderer/primitives/FragmentRenderer.js +11 -0
- package/dist/renderer/primitives/SlotRenderer.d.ts +21 -0
- package/dist/renderer/primitives/SlotRenderer.js +20 -0
- package/dist/renderer/wrapRegistry.d.ts +64 -0
- package/dist/renderer/wrapRegistry.js +39 -0
- package/dist/renderer/wrappers/component-slots.d.ts +41 -0
- package/dist/renderer/wrappers/component-slots.js +66 -0
- package/dist/renderer/wrappers/event-bridge.d.ts +20 -0
- package/dist/renderer/wrappers/event-bridge.js +78 -0
- package/dist/renderer/wrappers/hex-normalize.d.ts +14 -0
- package/dist/renderer/wrappers/hex-normalize.js +35 -0
- package/dist/renderer/wrappers/html-aliases.d.ts +24 -0
- package/dist/renderer/wrappers/html-aliases.js +62 -0
- package/dist/renderer/wrappers/inline-styles.d.ts +16 -0
- package/dist/renderer/wrappers/inline-styles.js +104 -0
- package/dist/renderer/wrappers/slot-resolution.d.ts +25 -0
- package/dist/renderer/wrappers/slot-resolution.js +68 -0
- package/dist/renderer/wrappers/void-elements.d.ts +23 -0
- package/dist/renderer/wrappers/void-elements.js +28 -0
- package/dist/spec/apply-forced-modifiers.d.ts +19 -0
- package/dist/spec/apply-forced-modifiers.js +49 -0
- package/dist/spec/asset-jsx.d.ts +48 -0
- package/dist/spec/asset-jsx.js +48 -0
- package/dist/spec/collapse-text-labels.d.ts +44 -0
- package/dist/spec/collapse-text-labels.js +107 -0
- package/dist/spec/empty-node-slots.d.ts +51 -0
- package/dist/spec/empty-node-slots.js +141 -0
- package/dist/spec/index.d.ts +10 -0
- package/dist/spec/index.js +10 -0
- package/dist/spec/jsxToSpec.d.ts +48 -0
- package/dist/spec/jsxToSpec.js +506 -0
- package/dist/spec/layer-props.d.ts +52 -0
- package/dist/spec/layer-props.js +149 -0
- package/dist/spec/preview-controls.d.ts +44 -0
- package/dist/spec/preview-controls.js +139 -0
- package/dist/spec/slot-refs.d.ts +39 -0
- package/dist/spec/slot-refs.js +56 -0
- package/dist/spec/specToJsx.d.ts +35 -0
- package/dist/spec/specToJsx.js +127 -0
- package/dist/token-override-rows.d.ts +66 -0
- package/dist/token-override-rows.js +223 -0
- package/dist/tokenValueType.d.ts +34 -0
- package/dist/tokenValueType.js +138 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/css-properties.d.ts +232 -0
- package/dist/types/css-properties.js +14 -0
- package/dist/types/css-property-keywords.d.ts +156 -0
- package/dist/types/css-property-keywords.js +616 -0
- package/dist/types/css-values.d.ts +63 -0
- package/dist/types/css-values.js +16 -0
- package/dist/types.d.ts +708 -0
- package/dist/types.js +12 -0
- package/dist/units.d.ts +14 -0
- package/dist/units.js +16 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +4 -0
- package/package.json +81 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { cssClassName, cssVar } from "./brands.js";
|
|
2
|
+
//#region src/entity-utils.ts
|
|
3
|
+
/**
|
|
4
|
+
* Shared helpers used by entity `.derived` getters.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Kebab-case a single identifier. Inserts a hyphen at each upper-case
|
|
8
|
+
* boundary and lower-cases the result. Single-segment only — for slashed
|
|
9
|
+
* `'namespace/name'` paths, kebab each segment separately.
|
|
10
|
+
*/
|
|
11
|
+
function kebabCase(value) {
|
|
12
|
+
return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Kebab-case + sanitize a single identifier for use inside a CSS custom
|
|
16
|
+
* property name or class name. Dots become `_` and slashes become `-`
|
|
17
|
+
* (so `1.5` → `1_5`, `1/2` → `1-2`, `ui5/emphasized` → `ui5-emphasized`).
|
|
18
|
+
* Mirrors the `safeTokenName` transform used by the runtime styler in
|
|
19
|
+
* `@yahoo/uds-create-utils`, so codegen-declared identifiers and runtime-referenced
|
|
20
|
+
* identifiers stay in lockstep.
|
|
21
|
+
*/
|
|
22
|
+
function cssSafeSegment(value) {
|
|
23
|
+
return kebabCase(value).replace(/\./g, "_").replace(/\//g, "-");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build a CSS variable name from a prefix + namespace + token name.
|
|
27
|
+
* Each segment is kebab-cased; dots in the token name are mapped to
|
|
28
|
+
* `_` and slashes to `-` since CSS custom-property identifiers reject
|
|
29
|
+
* both `.` and `/` (so a `1.5` spacing token emits
|
|
30
|
+
* `--<prefix>-spacing-1_5`, and a subpath token `1/2` or
|
|
31
|
+
* `always/white` emits `--<prefix>-position-1-2` /
|
|
32
|
+
* `--<prefix>-global-always-white` — both valid).
|
|
33
|
+
*/
|
|
34
|
+
function buildCssVar(prefix, namespace, name) {
|
|
35
|
+
return cssVar(`--${prefix}-${kebabCase(namespace)}-${cssSafeSegment(name)}`);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build a `tokenRef → 'var(--<prefix>-<ns>-<name>)'` resolver — the callback
|
|
39
|
+
* `resolveColorExpression` consumes to turn `token('ns/name')` refs into CSS var
|
|
40
|
+
* references. Splits a ref on its FIRST slash into namespace + name; a ref with
|
|
41
|
+
* no usable slash passes through unchanged (already a literal).
|
|
42
|
+
*
|
|
43
|
+
* The single source of truth shared by the config render-spec bake and codegen
|
|
44
|
+
* (`tokenValue.ts`, `prepareCss.ts`), so config-baked and codegen-emitted CSS
|
|
45
|
+
* stay byte-identical. The name segment uses the `@yahoo/uds-create-utils` `safeTokenName`
|
|
46
|
+
* transform (dots→`_`, slashes→`-`) — NOT `cssSafeSegment` (which also
|
|
47
|
+
* kebab-cases) — so multi-segment paths like `spectrum/carbon/0` resolve to a
|
|
48
|
+
* valid `--<prefix>-spectrum-carbon-0`.
|
|
49
|
+
*/
|
|
50
|
+
function makeTokenRefToCss(prefix) {
|
|
51
|
+
return (ref) => {
|
|
52
|
+
const slashIdx = ref.indexOf("/");
|
|
53
|
+
if (slashIdx <= 0 || slashIdx >= ref.length - 1) return ref;
|
|
54
|
+
const namespace = kebabCase(ref.slice(0, slashIdx));
|
|
55
|
+
const name = ref.slice(slashIdx + 1).replace(/\./g, "_").replace(/\//g, "-");
|
|
56
|
+
return prefix ? `var(--${prefix}-${namespace}-${name})` : `var(--${namespace}-${name})`;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build a composite style's CSS class name: `<prefix>-<name>-<variant>`.
|
|
61
|
+
* Both name/variant segments are sanitized so subpath variants like
|
|
62
|
+
* `ui5/emphasized` emit `.yos-text-variant-ui5-emphasized` instead of an
|
|
63
|
+
* invalid `.text-variant-ui5/emphasized` (which the browser splits at `/`).
|
|
64
|
+
*
|
|
65
|
+
* The `prefix` namespaces the class the same way it namespaces CSS
|
|
66
|
+
* variables and component classes (`componentClassNames`) — an empty
|
|
67
|
+
* prefix yields the bare, unprefixed form.
|
|
68
|
+
*/
|
|
69
|
+
function buildCompositeClassName(prefix, name, variant) {
|
|
70
|
+
const body = `${cssSafeSegment(name)}-${cssSafeSegment(variant)}`;
|
|
71
|
+
return cssClassName(prefix ? `${prefix}-${body}` : body);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build the marker custom-property name a composite group writes (and
|
|
75
|
+
* its container style queries read): `--<prefix>-composite-<kebab-name>`.
|
|
76
|
+
* Single source of truth — the setter emission and `@container style(...)`
|
|
77
|
+
* query both consume this so they stay in lockstep.
|
|
78
|
+
*/
|
|
79
|
+
function buildCompositeMarkerVarName(prefix, name) {
|
|
80
|
+
return cssVar(`--${prefix}-composite-${kebabCase(name)}`);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Token names that aren't valid CSS identifiers (`2xl`, `3xs`) get an
|
|
84
|
+
* underscore prefix so they survive in CSS contexts. Dots are mapped
|
|
85
|
+
* to `_` and slashes to `-` — `1.5` would otherwise produce a class
|
|
86
|
+
* string the browser splits at the dot (`class="text-1.5"` parses as
|
|
87
|
+
* `.text-1` and `.5`), and a subpath token like `1/2` would emit
|
|
88
|
+
* `text-1/2` which the browser treats as `.text-1` followed by
|
|
89
|
+
* `/2`. Mirrors `safeTokenName` from `@yahoo/uds-create-utils`.
|
|
90
|
+
*/
|
|
91
|
+
function toCssSafeName(name) {
|
|
92
|
+
return cssClassName(cssSafeSegment(/^[0-9]/.test(name) ? `_${name}` : name));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Filter undefined fields out of a partial object literal so optional
|
|
96
|
+
* authored properties don't show up as `key: undefined` in `toJSON()`
|
|
97
|
+
* output. Mirrors the pattern used by `@yahoo/uds-create-config` `defineX` builders.
|
|
98
|
+
*/
|
|
99
|
+
function compact(input) {
|
|
100
|
+
const out = {};
|
|
101
|
+
for (const [key, value] of Object.entries(input)) if (value !== void 0) out[key] = value;
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { buildCompositeClassName, buildCompositeMarkerVarName, buildCssVar, compact, cssSafeSegment, kebabCase, makeTokenRefToCss, toCssSafeName };
|