zyzz 0.0.2 → 0.0.3

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 (44) hide show
  1. package/dist/Config.d.ts +1 -1
  2. package/dist/Config.d.ts.map +1 -1
  3. package/dist/Config.js.map +1 -1
  4. package/dist/Style.d.ts +5 -2
  5. package/dist/Style.d.ts.map +1 -1
  6. package/dist/Style.js +43 -2
  7. package/dist/Style.js.map +1 -1
  8. package/dist/Theme.d.ts +12 -9
  9. package/dist/Theme.d.ts.map +1 -1
  10. package/dist/Theme.js +20 -4
  11. package/dist/Theme.js.map +1 -1
  12. package/dist/compiler/Source.d.ts +2 -0
  13. package/dist/compiler/Source.d.ts.map +1 -1
  14. package/dist/compiler/Source.js +22 -0
  15. package/dist/compiler/Source.js.map +1 -1
  16. package/dist/compiler/Transform.d.ts.map +1 -1
  17. package/dist/compiler/Transform.js +2 -0
  18. package/dist/compiler/Transform.js.map +1 -1
  19. package/dist/compiler/internal/Contract.d.ts.map +1 -1
  20. package/dist/compiler/internal/Contract.js +10 -3
  21. package/dist/compiler/internal/Contract.js.map +1 -1
  22. package/dist/default.d.ts +1218 -1
  23. package/dist/default.d.ts.map +1 -1
  24. package/dist/default.js +304 -0
  25. package/dist/default.js.map +2 -2
  26. package/dist/default.js.zyzz.json +1 -1
  27. package/dist/internal/Shorthands.d.ts +1 -1
  28. package/dist/internal/Shorthands.d.ts.map +1 -1
  29. package/dist/internal/Shorthands.js +1 -0
  30. package/dist/internal/Shorthands.js.map +1 -1
  31. package/dist/internal/Typography.d.ts +23 -0
  32. package/dist/internal/Typography.d.ts.map +1 -0
  33. package/dist/internal/Typography.js +18 -0
  34. package/dist/internal/Typography.js.map +1 -0
  35. package/package.json +1 -1
  36. package/src/Config.ts +1 -0
  37. package/src/Style.ts +91 -27
  38. package/src/Theme.ts +106 -35
  39. package/src/compiler/Source.ts +29 -0
  40. package/src/compiler/Transform.ts +6 -0
  41. package/src/compiler/internal/Contract.ts +19 -5
  42. package/src/default.ts +694 -1
  43. package/src/internal/Shorthands.ts +2 -0
  44. package/src/internal/Typography.ts +51 -0
@@ -34,6 +34,7 @@ export function read(value: unknown): Map {
34
34
  'style',
35
35
  'theme',
36
36
  'themes',
37
+ 'typography',
37
38
  'script',
38
39
  'variants',
39
40
  '__proto__',
@@ -98,6 +99,7 @@ export type Validated<mappings extends Map> = {
98
99
  | 'style'
99
100
  | 'theme'
100
101
  | 'themes'
102
+ | 'typography'
101
103
  | 'script'
102
104
  | 'variants'
103
105
  | '__proto__'
@@ -0,0 +1,51 @@
1
+ /** Describes nested typography sets and their property-aware token paths. @module */
2
+ import type * as Literal from './Literal.js'
3
+ import * as Token from './Token.js'
4
+
5
+ /** Resolves the scalar fields owned by one dotted set path. */
6
+ export function fields(
7
+ theme: object | undefined,
8
+ name: unknown,
9
+ ): readonly Property[] {
10
+ const data =
11
+ theme &&
12
+ (Object.getOwnPropertyDescriptor(theme, Token.definition)?.value as
13
+ | Token.Metadata
14
+ | undefined)
15
+ if (!data || typeof name !== 'string') return []
16
+
17
+ return properties.filter((property) =>
18
+ Object.hasOwn(data.values, `typography.${name}.${property}`),
19
+ )
20
+ }
21
+
22
+ /** Names of sets containing at least one typography declaration. */
23
+ export type Names<tokens> = tokens extends { typography: infer tree }
24
+ ? Paths<tree>
25
+ : never
26
+
27
+ type Paths<tree> = string extends keyof tree
28
+ ? string
29
+ : {
30
+ [key in Exclude<Extract<keyof tree, string | number>, Property>]:
31
+ | (Extract<keyof tree[key], Property> extends never ? never : `${key}`)
32
+ | `${key}.${Paths<tree[key]>}`
33
+ }[Exclude<Extract<keyof tree, string | number>, Property>]
34
+
35
+ /** Scalar properties applied by a typography set. */
36
+ export const properties = [
37
+ 'fontFamily',
38
+ 'fontSize',
39
+ 'fontWeight',
40
+ 'letterSpacing',
41
+ 'lineHeight',
42
+ ] as const
43
+
44
+ /** Property domain retained by each field in a set. */
45
+ export type Property = (typeof properties)[number]
46
+
47
+ /** A set may supply any of the five typography properties. */
48
+ export type Set = Pick<Literal.Properties, Property>
49
+
50
+ /** Nested names may contain sets and additional named variants. */
51
+ export type Sets = { readonly [name: string]: Set | Sets }