zyzz 0.0.19 → 0.0.21
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/README.md +9 -9
- package/dist/Config.d.ts +1 -0
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js.map +1 -1
- package/dist/Style.d.ts +7 -0
- package/dist/Style.d.ts.map +1 -1
- package/dist/Style.js +1 -5
- package/dist/Style.js.map +1 -1
- package/dist/Vars.d.ts +22 -15
- package/dist/Vars.d.ts.map +1 -1
- package/dist/Vars.js +26 -0
- package/dist/Vars.js.map +1 -1
- package/dist/cli/index.js +5 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/compiler/Graph.d.ts +3 -0
- package/dist/compiler/Graph.d.ts.map +1 -1
- package/dist/compiler/Graph.js +44 -37
- package/dist/compiler/Graph.js.map +1 -1
- package/dist/compiler/Source.d.ts +4 -0
- package/dist/compiler/Source.d.ts.map +1 -1
- package/dist/compiler/Source.js +66 -6
- package/dist/compiler/Source.js.map +1 -1
- package/dist/compiler/Transform.d.ts +4 -1
- package/dist/compiler/Transform.d.ts.map +1 -1
- package/dist/compiler/Transform.js +32 -46
- package/dist/compiler/Transform.js.map +1 -1
- package/dist/compiler/internal/Catalogs.d.ts.map +1 -1
- package/dist/compiler/internal/Catalogs.js +6 -1
- package/dist/compiler/internal/Catalogs.js.map +1 -1
- package/dist/compiler/internal/Compositions.d.ts.map +1 -1
- package/dist/compiler/internal/Compositions.js +5 -0
- package/dist/compiler/internal/Compositions.js.map +1 -1
- package/dist/compiler/internal/Configurations.d.ts.map +1 -1
- package/dist/compiler/internal/Configurations.js +5 -1
- package/dist/compiler/internal/Configurations.js.map +1 -1
- package/dist/compiler/internal/Contract.d.ts +4 -1
- package/dist/compiler/internal/Contract.d.ts.map +1 -1
- package/dist/compiler/internal/Contract.js +73 -138
- package/dist/compiler/internal/Contract.js.map +1 -1
- package/dist/compiler/internal/Contributions.d.ts.map +1 -1
- package/dist/compiler/internal/Contributions.js +1 -3
- package/dist/compiler/internal/Contributions.js.map +1 -1
- package/dist/compiler/internal/Dynamic.d.ts +1 -1
- package/dist/compiler/internal/Dynamic.d.ts.map +1 -1
- package/dist/compiler/internal/Dynamic.js +5 -5
- package/dist/compiler/internal/Dynamic.js.map +1 -1
- package/dist/compiler/internal/Names.d.ts +5 -0
- package/dist/compiler/internal/Names.d.ts.map +1 -0
- package/dist/compiler/internal/Names.js +37 -0
- package/dist/compiler/internal/Names.js.map +1 -0
- package/dist/compiler/internal/Selectors.d.ts +1 -1
- package/dist/compiler/internal/Selectors.d.ts.map +1 -1
- package/dist/compiler/internal/Selectors.js +5 -2
- package/dist/compiler/internal/Selectors.js.map +1 -1
- package/dist/compiler/internal/Stylesheets.js +2 -2
- package/dist/compiler/internal/Stylesheets.js.map +1 -1
- package/dist/compiler/internal/Themes.d.ts.map +1 -1
- package/dist/compiler/internal/Themes.js +85 -24
- package/dist/compiler/internal/Themes.js.map +1 -1
- package/dist/compiler/internal/Vars.d.ts +2 -0
- package/dist/compiler/internal/Vars.d.ts.map +1 -1
- package/dist/compiler/internal/Vars.js +7 -1
- package/dist/compiler/internal/Vars.js.map +1 -1
- package/dist/default.d.ts +11 -15
- package/dist/default.d.ts.map +1 -1
- package/dist/default.js +13 -14
- package/dist/default.js.map +2 -2
- package/dist/default.js.zyzz.json +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/Authoring.d.ts.map +1 -1
- package/dist/internal/Authoring.js +8 -3
- package/dist/internal/Authoring.js.map +1 -1
- package/dist/internal/Binding.d.ts +4 -0
- package/dist/internal/Binding.d.ts.map +1 -1
- package/dist/internal/Binding.js +2 -0
- package/dist/internal/Binding.js.map +1 -1
- package/dist/internal/Configuration.d.ts +2 -2
- package/dist/internal/Configuration.d.ts.map +1 -1
- package/dist/internal/Configuration.js +4 -2
- package/dist/internal/Configuration.js.map +1 -1
- package/dist/internal/Identity.d.ts +3 -3
- package/dist/internal/Identity.d.ts.map +1 -1
- package/dist/internal/Identity.js +11 -9
- package/dist/internal/Identity.js.map +1 -1
- package/dist/internal/Theme.js +2 -2
- package/dist/internal/Theme.js.map +1 -1
- package/dist/internal/Token.d.ts +16 -3
- package/dist/internal/Token.d.ts.map +1 -1
- package/dist/internal/Token.js +11 -2
- package/dist/internal/Token.js.map +1 -1
- package/dist/internal/VariableSets.d.ts.map +1 -1
- package/dist/internal/VariableSets.js +19 -2
- package/dist/internal/VariableSets.js.map +1 -1
- package/dist/node/Host.d.ts +2 -0
- package/dist/node/Host.d.ts.map +1 -1
- package/dist/node/Host.js +9 -0
- package/dist/node/Host.js.map +1 -1
- package/dist/react-native/StyleSheet.js +2 -0
- package/dist/react-native/StyleSheet.js.map +1 -1
- package/dist/runtime/Composition.d.ts +1 -1
- package/dist/runtime/ConditionalRecipe.d.ts +1 -1
- package/dist/runtime/PayloadRecipe.d.ts +1 -1
- package/dist/runtime/Recipe.d.ts +1 -1
- package/dist/styleFunction.d.ts +1 -1
- package/dist/styleFunction.d.ts.map +1 -1
- package/dist/styleFunction.js.map +1 -1
- package/dist/variable.js +1 -1
- package/dist/variable.js.map +1 -1
- package/dist/variants.d.ts +14 -6
- package/dist/variants.d.ts.map +1 -1
- package/dist/variants.js.map +1 -1
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +111 -42
- package/dist/vite/index.js.map +1 -1
- package/dist/web/Css.d.ts +7 -2
- package/dist/web/Css.d.ts.map +1 -1
- package/dist/web/Css.js +46 -39
- package/dist/web/Css.js.map +1 -1
- package/dist/web/internal/ClassName.d.ts +13 -2
- package/dist/web/internal/ClassName.d.ts.map +1 -1
- package/dist/web/internal/ClassName.js +17 -30
- package/dist/web/internal/ClassName.js.map +1 -1
- package/dist/web/internal/Themes.d.ts +3 -0
- package/dist/web/internal/Themes.d.ts.map +1 -1
- package/dist/web/internal/Themes.js +52 -24
- package/dist/web/internal/Themes.js.map +1 -1
- package/package.json +1 -1
- package/src/Config.ts +5 -0
- package/src/Style.ts +4 -1
- package/src/Vars.ts +88 -29
- package/src/cli/index.ts +5 -0
- package/src/compiler/Graph.ts +60 -46
- package/src/compiler/Source.ts +86 -5
- package/src/compiler/Transform.ts +42 -60
- package/src/compiler/internal/Catalogs.ts +9 -1
- package/src/compiler/internal/Compositions.ts +7 -0
- package/src/compiler/internal/Configurations.ts +5 -1
- package/src/compiler/internal/Contract.ts +104 -239
- package/src/compiler/internal/Contributions.ts +1 -5
- package/src/compiler/internal/Dynamic.ts +14 -9
- package/src/compiler/internal/Names.ts +48 -0
- package/src/compiler/internal/Selectors.ts +6 -1
- package/src/compiler/internal/Stylesheets.ts +2 -2
- package/src/compiler/internal/Themes.ts +115 -35
- package/src/compiler/internal/Vars.ts +9 -1
- package/src/default.ts +17 -20
- package/src/index.ts +15 -0
- package/src/internal/Authoring.ts +9 -3
- package/src/internal/Binding.ts +5 -0
- package/src/internal/Configuration.ts +7 -4
- package/src/internal/Identity.ts +14 -12
- package/src/internal/Theme.ts +2 -2
- package/src/internal/Token.ts +52 -12
- package/src/internal/VariableSets.ts +26 -2
- package/src/node/Host.ts +22 -0
- package/src/react-native/StyleSheet.ts +6 -0
- package/src/styleFunction.ts +1 -3
- package/src/variable.ts +1 -1
- package/src/variants.ts +38 -16
- package/src/vite/index.ts +137 -51
- package/src/web/Css.ts +83 -49
- package/src/web/internal/ClassName.ts +31 -36
- package/src/web/internal/Themes.ts +79 -29
package/src/internal/Token.ts
CHANGED
|
@@ -262,6 +262,11 @@ export function acceptsReference(
|
|
|
262
262
|
if (property.startsWith('--')) return true
|
|
263
263
|
function check(value: Value): boolean {
|
|
264
264
|
if (is(value)) return acceptsReference(value, property)
|
|
265
|
+
if (isExpression(value))
|
|
266
|
+
return Binding.accepts(
|
|
267
|
+
value.group === 'color' ? 'color' : 'length',
|
|
268
|
+
property,
|
|
269
|
+
)
|
|
265
270
|
if (typeof value === 'object') return Object.values(value).every(check)
|
|
266
271
|
if (typeof value === 'number') {
|
|
267
272
|
const rule = Literal.rule(property)
|
|
@@ -328,6 +333,7 @@ export function acceptsReference(
|
|
|
328
333
|
export function bind<tokens extends Theme.Tokens>(
|
|
329
334
|
original: Theme.Definition<tokens>,
|
|
330
335
|
contract: Contract,
|
|
336
|
+
cssName?: string,
|
|
331
337
|
): Theme.Definition<tokens> {
|
|
332
338
|
type Tree = { [key: string]: Reference | Tree }
|
|
333
339
|
|
|
@@ -366,7 +372,14 @@ export function bind<tokens extends Theme.Tokens>(
|
|
|
366
372
|
vars: variables(tokens),
|
|
367
373
|
},
|
|
368
374
|
definition,
|
|
369
|
-
{
|
|
375
|
+
{
|
|
376
|
+
value: Object.freeze({
|
|
377
|
+
...metadata,
|
|
378
|
+
...(cssName !== undefined ? { cssName } : {}),
|
|
379
|
+
contract,
|
|
380
|
+
values,
|
|
381
|
+
}),
|
|
382
|
+
},
|
|
370
383
|
),
|
|
371
384
|
) as Theme.Definition<tokens>
|
|
372
385
|
}
|
|
@@ -378,6 +391,8 @@ export const complete = Symbol('zyzz.contract.complete')
|
|
|
378
391
|
export type Contract = {
|
|
379
392
|
/** Whether values belong to independent variables rather than fixed theme categories. */
|
|
380
393
|
readonly variableSet?: boolean | undefined
|
|
394
|
+
/** Custom-property spelling retained by older packed producers. */
|
|
395
|
+
readonly variableNaming?: 'legacy' | 'hashed' | undefined
|
|
381
396
|
/** Configuration-local category-to-property mappings. */
|
|
382
397
|
readonly mappings?: VariableSets.Mappings | false | undefined
|
|
383
398
|
/** Web emission mode retained by configuration-bound theme handles. */
|
|
@@ -403,6 +418,18 @@ export type Expression = {
|
|
|
403
418
|
readonly parts: readonly (string | Reference | Binding.Reference)[]
|
|
404
419
|
}
|
|
405
420
|
|
|
421
|
+
/** A composed variable value with an explicit scalar domain. */
|
|
422
|
+
export type Composition<
|
|
423
|
+
group extends 'color' | 'spacing' = 'color' | 'spacing',
|
|
424
|
+
> = {
|
|
425
|
+
/** Structured expression discriminator. */
|
|
426
|
+
readonly [expression]: true
|
|
427
|
+
/** Domain retained by variable references and compatible overrides. */
|
|
428
|
+
readonly group: group
|
|
429
|
+
/** CSS text and references to portable variable values. */
|
|
430
|
+
readonly parts: readonly (string | Reference)[]
|
|
431
|
+
}
|
|
432
|
+
|
|
406
433
|
/** Identifies structured web expressions independently of literal CSS text. */
|
|
407
434
|
export const expression = Symbol('zyzz.expression')
|
|
408
435
|
|
|
@@ -503,6 +530,8 @@ export function is(value: unknown): value is Reference {
|
|
|
503
530
|
|
|
504
531
|
/** Immutable theme data carried directly by each definition. */
|
|
505
532
|
export type Metadata = {
|
|
533
|
+
/** Authored scope name, independent of private graph ownership. */
|
|
534
|
+
readonly cssName?: string | undefined
|
|
506
535
|
/** Original segments for typography paths containing query punctuation. */
|
|
507
536
|
readonly paths?: Readonly<Record<string, readonly string[]>> | undefined
|
|
508
537
|
readonly queries?: Query.Metadata | undefined
|
|
@@ -558,17 +587,27 @@ type Paths<tree, property extends keyof Literal.Properties = never> = [
|
|
|
558
587
|
> extends Value
|
|
559
588
|
? [property] extends [never]
|
|
560
589
|
? PathKey<key>
|
|
561
|
-
: VariableSets.Scalar<
|
|
562
|
-
|
|
563
|
-
>
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
590
|
+
: Literal.Color extends VariableSets.Scalar<NonNullable<tree[key]>>
|
|
591
|
+
? property extends Properties<'color'>
|
|
592
|
+
? PathKey<key>
|
|
593
|
+
: never
|
|
594
|
+
: Literal.Length extends VariableSets.Scalar<
|
|
595
|
+
NonNullable<tree[key]>
|
|
596
|
+
>
|
|
597
|
+
? Binding.Property<'length', property> extends never
|
|
598
|
+
? never
|
|
599
|
+
: PathKey<key>
|
|
600
|
+
: VariableSets.Scalar<
|
|
601
|
+
NonNullable<tree[key]>
|
|
602
|
+
> extends Literal.Properties[property] &
|
|
603
|
+
ValueSyntax.Checked<
|
|
604
|
+
Record<
|
|
605
|
+
property,
|
|
606
|
+
VariableSets.Scalar<NonNullable<tree[key]>>
|
|
607
|
+
>
|
|
608
|
+
>[property]
|
|
609
|
+
? PathKey<key>
|
|
610
|
+
: never
|
|
572
611
|
: `${key}.${Paths<NonNullable<tree[key]>, property>}`
|
|
573
612
|
}[Extract<keyof tree, number | string>]
|
|
574
613
|
|
|
@@ -794,6 +833,7 @@ export type Value =
|
|
|
794
833
|
| number
|
|
795
834
|
| string
|
|
796
835
|
| Reference
|
|
836
|
+
| Composition
|
|
797
837
|
| { readonly dark: Value; readonly light: Value }
|
|
798
838
|
| Conditions
|
|
799
839
|
|
|
@@ -33,7 +33,7 @@ export function theme(
|
|
|
33
33
|
get: () => {
|
|
34
34
|
const identity = metadata.contract[Token.identity]
|
|
35
35
|
return identity
|
|
36
|
-
? `
|
|
36
|
+
? `z-theme-${identity.startsWith('id-') ? identity.slice(3) : Identity.name(identity)}`
|
|
37
37
|
: original.className
|
|
38
38
|
},
|
|
39
39
|
enumerable: true,
|
|
@@ -75,6 +75,7 @@ export function build(
|
|
|
75
75
|
typeof input === 'string' ||
|
|
76
76
|
typeof input === 'number' ||
|
|
77
77
|
Token.is(input) ||
|
|
78
|
+
Token.isExpression(input) ||
|
|
78
79
|
(path.length > 0 &&
|
|
79
80
|
input &&
|
|
80
81
|
typeof input === 'object' &&
|
|
@@ -244,6 +245,17 @@ function read(
|
|
|
244
245
|
active = new Set<object>(),
|
|
245
246
|
): Token.Value {
|
|
246
247
|
if (Token.is(input)) return input
|
|
248
|
+
if (Token.isExpression(input)) {
|
|
249
|
+
if (
|
|
250
|
+
!('group' in input) ||
|
|
251
|
+
(input.group !== 'color' && input.group !== 'spacing')
|
|
252
|
+
)
|
|
253
|
+
throw new Vars.InvalidError(path, 'Expected a composed variable value.')
|
|
254
|
+
return Vars.compose(
|
|
255
|
+
input.group,
|
|
256
|
+
input.parts as readonly (string | Token.Reference)[],
|
|
257
|
+
)
|
|
258
|
+
}
|
|
247
259
|
if (typeof input === 'number' && Number.isFinite(input)) return input
|
|
248
260
|
if (typeof input === 'string' && input.trim() && !/[;{}]/.test(input))
|
|
249
261
|
return input
|
|
@@ -307,7 +319,7 @@ function read(
|
|
|
307
319
|
|
|
308
320
|
/** Infers the shared declaration domain after following defaults and references. */
|
|
309
321
|
export function domain(value: Token.Value): Token.Group {
|
|
310
|
-
if (Token.is(value)) return value.group
|
|
322
|
+
if (Token.is(value) || Token.isExpression(value)) return value.group
|
|
311
323
|
if (typeof value === 'object')
|
|
312
324
|
return 'default' in value ? domain(value.default) : 'color'
|
|
313
325
|
if (
|
|
@@ -383,6 +395,7 @@ export function merge(
|
|
|
383
395
|
typeof entry !== 'object' ||
|
|
384
396
|
Array.isArray(entry) ||
|
|
385
397
|
Token.is(entry) ||
|
|
398
|
+
Token.isExpression(entry) ||
|
|
386
399
|
'default' in entry ||
|
|
387
400
|
('light' in entry && 'dark' in entry) ||
|
|
388
401
|
(Object.keys(entry).length <= 2 &&
|
|
@@ -424,6 +437,17 @@ export function rebind(
|
|
|
424
437
|
value: visit(value.path),
|
|
425
438
|
})
|
|
426
439
|
}
|
|
440
|
+
if (Token.isExpression(value))
|
|
441
|
+
return Vars.compose(
|
|
442
|
+
value.group,
|
|
443
|
+
value.parts.map((part) => {
|
|
444
|
+
if (typeof part === 'string') return part
|
|
445
|
+
const reference = resolve(part)
|
|
446
|
+
if (!Token.is(reference))
|
|
447
|
+
throw new Vars.InvalidError([], 'Expected a variable reference.')
|
|
448
|
+
return reference
|
|
449
|
+
}),
|
|
450
|
+
)
|
|
427
451
|
if (typeof value !== 'object') return value
|
|
428
452
|
|
|
429
453
|
return Object.freeze(
|
package/src/node/Host.ts
CHANGED
|
@@ -17,6 +17,7 @@ import * as Snapshot from './internal/Snapshot.js'
|
|
|
17
17
|
import * as Syntax from '../compiler/internal/Syntax.js'
|
|
18
18
|
import * as Source from '../compiler/Source.js'
|
|
19
19
|
import * as Transform from '../compiler/Transform.js'
|
|
20
|
+
import * as ThemeRules from '../web/internal/Themes.js'
|
|
20
21
|
|
|
21
22
|
/** A successful publication; paths are relative to the output directory. */
|
|
22
23
|
export type Build = {
|
|
@@ -49,6 +50,14 @@ export async function create(options: create.Options): Promise<Runtime> {
|
|
|
49
50
|
targets: { ...options.css?.targets },
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
const externals = [...(options.external ?? [])]
|
|
54
|
+
if (
|
|
55
|
+
externals.some((pattern) => !pattern || pattern.slice(0, -1).includes('*'))
|
|
56
|
+
)
|
|
57
|
+
throw new Error(
|
|
58
|
+
'External imports require exact names or a trailing * prefix.',
|
|
59
|
+
)
|
|
60
|
+
|
|
52
61
|
const native = options.native
|
|
53
62
|
? Object.freeze({
|
|
54
63
|
...options.native,
|
|
@@ -404,6 +413,15 @@ export async function create(options: create.Options): Promise<Runtime> {
|
|
|
404
413
|
(!specifier.startsWith('#') && specifier.includes('#'))
|
|
405
414
|
)
|
|
406
415
|
continue
|
|
416
|
+
if (
|
|
417
|
+
externals.some((pattern) =>
|
|
418
|
+
pattern.endsWith('*')
|
|
419
|
+
? specifier.startsWith(pattern.slice(0, -1))
|
|
420
|
+
: specifier === pattern,
|
|
421
|
+
)
|
|
422
|
+
)
|
|
423
|
+
continue
|
|
424
|
+
|
|
407
425
|
try {
|
|
408
426
|
if (specifier.startsWith('.')) {
|
|
409
427
|
const target = Relative.resolve({ moduleId, modules, specifier })
|
|
@@ -441,6 +459,8 @@ export async function create(options: create.Options): Promise<Runtime> {
|
|
|
441
459
|
}
|
|
442
460
|
|
|
443
461
|
const graph = compiler.compile({
|
|
462
|
+
[ThemeRules.shared]:
|
|
463
|
+
options.modules === false && !native ? 'all' : undefined,
|
|
444
464
|
[Syntax.cache]: snapshot.programs(modules),
|
|
445
465
|
compiler: options.compiler,
|
|
446
466
|
native,
|
|
@@ -951,6 +971,8 @@ export declare namespace create {
|
|
|
951
971
|
readonly targets?: Readonly<LightningCss.Targets> | undefined
|
|
952
972
|
}
|
|
953
973
|
| undefined
|
|
974
|
+
/** Imports left for downstream tooling. Matches exact names or prefixes ending in *. */
|
|
975
|
+
readonly external?: readonly string[] | undefined
|
|
954
976
|
/** Native context captured at creation. Emits modules and maps without CSS or web initialization. */
|
|
955
977
|
readonly native?: Graph.compile.Options['native']
|
|
956
978
|
/** Output directory exclusively locked until close; may be nested under root. Defaults to `dist`. */
|
|
@@ -785,6 +785,12 @@ function resolve(
|
|
|
785
785
|
resolved = resolved.value
|
|
786
786
|
continue
|
|
787
787
|
}
|
|
788
|
+
if (Token.isExpression(resolved))
|
|
789
|
+
fail(
|
|
790
|
+
'unsupported_feature',
|
|
791
|
+
'Composed variables require a web target.',
|
|
792
|
+
path,
|
|
793
|
+
)
|
|
788
794
|
if ('default' in resolved)
|
|
789
795
|
fail(
|
|
790
796
|
'unsupported_feature',
|
package/src/styleFunction.ts
CHANGED
|
@@ -114,9 +114,7 @@ export declare namespace style {
|
|
|
114
114
|
/** Compiled and supplied class names. */
|
|
115
115
|
readonly className: string
|
|
116
116
|
/** Supplied inline styling overrides when present. */
|
|
117
|
-
readonly style?:
|
|
118
|
-
| Readonly<Record<string, string | number | undefined>>
|
|
119
|
-
| undefined
|
|
117
|
+
readonly style?: Readonly<Record<string, string | number | undefined>>
|
|
120
118
|
}
|
|
121
119
|
|
|
122
120
|
/** Callable definition; source rewriting supplies its implementation. */
|
package/src/variable.ts
CHANGED
|
@@ -38,7 +38,7 @@ export function variable(
|
|
|
38
38
|
): unknown {
|
|
39
39
|
const id = typeof kind === 'object' ? kind.id : options?.id
|
|
40
40
|
return Variable.create({
|
|
41
|
-
name: `--z
|
|
41
|
+
name: `--z-${Identity.requireId(id, 'variable').slice(3)}`,
|
|
42
42
|
type: typeof kind === 'string' ? kind : '*',
|
|
43
43
|
variable: true,
|
|
44
44
|
})
|
package/src/variants.ts
CHANGED
|
@@ -61,32 +61,54 @@ type CheckedChoice<
|
|
|
61
61
|
: never)
|
|
62
62
|
: CheckedStyles<style, tokens, layers, mappings>
|
|
63
63
|
|
|
64
|
-
type SuggestedStyles<
|
|
65
|
-
|
|
64
|
+
type SuggestedStyles<
|
|
65
|
+
tokens extends Theme.Tokens,
|
|
66
|
+
styles = Record<string, unknown>,
|
|
67
|
+
> = Completion.Properties<tokens, styles> & Readonly<Record<string, unknown>>
|
|
66
68
|
|
|
67
69
|
/** Editor hints remain independent of declaration and selection validation. */
|
|
68
|
-
type Suggestions<
|
|
69
|
-
|
|
70
|
+
type Suggestions<
|
|
71
|
+
tokens extends Theme.Tokens,
|
|
72
|
+
definition = Record<string, unknown>,
|
|
73
|
+
> = {
|
|
74
|
+
readonly base?:
|
|
75
|
+
| SuggestedStyles<
|
|
76
|
+
tokens,
|
|
77
|
+
definition extends { base: infer styles }
|
|
78
|
+
? styles
|
|
79
|
+
: Record<string, unknown>
|
|
80
|
+
>
|
|
81
|
+
| undefined
|
|
70
82
|
readonly compoundVariants?:
|
|
71
83
|
| readonly {
|
|
72
84
|
readonly style: SuggestedStyles<tokens>
|
|
73
85
|
readonly when: unknown
|
|
74
86
|
}[]
|
|
75
87
|
| undefined
|
|
76
|
-
readonly variants?:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
readonly variants?: definition extends { variants: infer axes }
|
|
89
|
+
? {
|
|
90
|
+
readonly [axis in keyof axes]: {
|
|
91
|
+
readonly [choice in keyof axes[axis]]: axes[axis][choice] extends (
|
|
92
|
+
...args: never[]
|
|
93
|
+
) => unknown
|
|
94
|
+
? (...args: never[]) => SuggestedStyles<tokens>
|
|
95
|
+
: SuggestedStyles<tokens, axes[axis][choice]>
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
:
|
|
99
|
+
| Readonly<
|
|
81
100
|
Record<
|
|
82
101
|
string,
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
Readonly<
|
|
103
|
+
Record<
|
|
104
|
+
string,
|
|
105
|
+
| SuggestedStyles<tokens>
|
|
106
|
+
| ((...args: never[]) => SuggestedStyles<tokens>)
|
|
107
|
+
>
|
|
108
|
+
>
|
|
85
109
|
>
|
|
86
110
|
>
|
|
87
|
-
|
|
88
|
-
>
|
|
89
|
-
| undefined
|
|
111
|
+
| undefined
|
|
90
112
|
}
|
|
91
113
|
|
|
92
114
|
type Keys<value> = value extends unknown ? keyof value : never
|
|
@@ -201,7 +223,7 @@ type Checked<
|
|
|
201
223
|
export function variants<const definition extends Record<string, unknown>>(
|
|
202
224
|
definition: definition &
|
|
203
225
|
NoInfer<Checked<definition, {}, never, {}>> &
|
|
204
|
-
Suggestions<{}
|
|
226
|
+
Suggestions<{}, NoInfer<definition>>,
|
|
205
227
|
options: style.DefinitionOptions = {},
|
|
206
228
|
): variants.ReturnType<definition> {
|
|
207
229
|
return Authoring.variants(
|
|
@@ -221,7 +243,7 @@ export declare namespace variants {
|
|
|
221
243
|
> = <const definition extends Record<string, unknown>>(
|
|
222
244
|
definition: definition &
|
|
223
245
|
NoInfer<Checked<definition, tokens, layers, mappings>> &
|
|
224
|
-
Suggestions<tokens
|
|
246
|
+
Suggestions<tokens, NoInfer<definition>>,
|
|
225
247
|
options?: style.DefinitionOptions,
|
|
226
248
|
) => ReturnType<definition, output>
|
|
227
249
|
|