@app-studio/components 0.10.21 → 0.10.23

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 (112) hide show
  1. package/dist/index.d.ts +230 -73
  2. package/dist/native/components/Background/Background/Background.view.js +7 -2
  3. package/dist/native/components/Background/Background/Background.view.js.map +1 -1
  4. package/dist/native/components/Button/Button/Button.props.d.ts +1 -0
  5. package/dist/native/components/Button/Button/Button.style.d.ts +14 -0
  6. package/dist/native/components/Button/Button/Button.style.js +19 -5
  7. package/dist/native/components/Button/Button/Button.style.js.map +1 -1
  8. package/dist/native/components/Button/Button/Button.type.d.ts +9 -0
  9. package/dist/native/components/Button/Button/Button.type.js +3 -0
  10. package/dist/native/components/Button/Button/Button.type.js.map +1 -0
  11. package/dist/native/components/Button/Button/Button.view.js +15 -7
  12. package/dist/native/components/Button/Button/Button.view.js.map +1 -1
  13. package/dist/native/components/Button/Button/Button.view.native.js +8 -3
  14. package/dist/native/components/Button/Button/Button.view.native.js.map +1 -1
  15. package/dist/native/components/Button/Button.js +12 -1
  16. package/dist/native/components/Button/Button.js.map +1 -1
  17. package/dist/native/components/Drawer/Drawer/Drawer.type.d.ts +3 -0
  18. package/dist/native/components/Drawer/Drawer/Drawer.type.js +2 -0
  19. package/dist/native/components/Drawer/Drawer/Drawer.type.js.map +1 -0
  20. package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.type.d.ts +8 -0
  21. package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.type.js +2 -0
  22. package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.type.js.map +1 -0
  23. package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.type.d.ts +2 -1
  24. package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.type.d.ts +19 -0
  25. package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.type.js +2 -0
  26. package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.type.js.map +1 -0
  27. package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.view.js +3 -2
  28. package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.view.js.map +1 -1
  29. package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.view.native.js +2 -2
  30. package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.type.d.ts +12 -0
  31. package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.type.js +2 -0
  32. package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.type.js.map +1 -0
  33. package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.view.js +5 -2
  34. package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.view.js.map +1 -1
  35. package/dist/native/components/Form/Label/Label/Label.props.d.ts +1 -1
  36. package/dist/native/components/Form/Password/Password/Password.type.d.ts +10 -0
  37. package/dist/native/components/Form/Password/Password/Password.type.js +2 -0
  38. package/dist/native/components/Form/Password/Password/Password.type.js.map +1 -0
  39. package/dist/native/components/Form/Password/Password.js +22 -3
  40. package/dist/native/components/Form/Password/Password.js.map +1 -1
  41. package/dist/native/components/Form/Radio/Radio/Radio.type.d.ts +8 -0
  42. package/dist/native/components/Form/Radio/Radio/Radio.type.js +2 -0
  43. package/dist/native/components/Form/Radio/Radio/Radio.type.js.map +1 -0
  44. package/dist/native/components/Form/Radio/RadioGroup/RadioGroup.type.d.ts +7 -0
  45. package/dist/native/components/Form/Radio/RadioGroup/RadioGroup.type.js +2 -0
  46. package/dist/native/components/Form/Radio/RadioGroup/RadioGroup.type.js.map +1 -0
  47. package/dist/native/components/Form/Select/Select/Select.props.d.ts +2 -2
  48. package/dist/native/components/Form/Select/Select/Select.type.d.ts +19 -0
  49. package/dist/native/components/Form/Select/Select/Select.type.js +2 -0
  50. package/dist/native/components/Form/Select/Select/Select.type.js.map +1 -0
  51. package/dist/native/components/Form/Select/Select/Select.view.js +15 -30
  52. package/dist/native/components/Form/Select/Select/Select.view.js.map +1 -1
  53. package/dist/native/components/Form/Selector/Selector/Selector.type.d.ts +19 -0
  54. package/dist/native/components/Form/Selector/Selector/Selector.type.js +2 -0
  55. package/dist/native/components/Form/Selector/Selector/Selector.type.js.map +1 -0
  56. package/dist/native/components/Form/Switch/Switch/Switch.type.d.ts +7 -0
  57. package/dist/native/components/Form/Switch/Switch/Switch.type.js +2 -0
  58. package/dist/native/components/Form/Switch/Switch/Switch.type.js.map +1 -0
  59. package/dist/native/components/Form/TagInput/TagInput/TagInput.view.js +6 -1
  60. package/dist/native/components/Form/TagInput/TagInput/TagInput.view.js.map +1 -1
  61. package/dist/native/components/Form/TextField/TextField/TextField.type.d.ts +12 -0
  62. package/dist/native/components/Form/TextField/TextField/TextField.type.js +2 -0
  63. package/dist/native/components/Form/TextField/TextField/TextField.type.js.map +1 -0
  64. package/dist/native/components/Form/TextField/TextField/TextField.view.js +4 -1
  65. package/dist/native/components/Form/TextField/TextField/TextField.view.js.map +1 -1
  66. package/dist/native/components/Input/FieldContainer/FieldContainer.js +1 -1
  67. package/dist/native/components/Input/FieldContainer/FieldContainer.js.map +1 -1
  68. package/dist/native/components/Input/FieldContent/FieldContent.js +13 -1
  69. package/dist/native/components/Input/FieldContent/FieldContent.js.map +1 -1
  70. package/dist/native/components/Input/FieldWrapper/FieldWrapper.js +1 -1
  71. package/dist/native/components/Input/FieldWrapper/FieldWrapper.js.map +1 -1
  72. package/dist/native/components/Input/fieldSizes.d.ts +33 -0
  73. package/dist/native/components/Input/fieldSizes.js +37 -0
  74. package/dist/native/components/Input/fieldSizes.js.map +1 -0
  75. package/dist/native/components/Link/Link/Link.props.d.ts +5 -3
  76. package/dist/native/components/Link/Link/Link.type.d.ts +7 -0
  77. package/dist/native/components/Link/Link/Link.type.js +2 -0
  78. package/dist/native/components/Link/Link/Link.type.js.map +1 -0
  79. package/dist/native/components/Link/Link/Link.view.js +40 -25
  80. package/dist/native/components/Link/Link/Link.view.js.map +1 -1
  81. package/dist/native/components/Link/Link/Link.view.native.js +4 -3
  82. package/dist/native/components/Link/Link/Link.view.native.js.map +1 -1
  83. package/dist/native/components/Link/Link.js +1 -5
  84. package/dist/native/components/Link/Link.js.map +1 -1
  85. package/dist/native/components/Loader/Loader/Loader.type.d.ts +4 -0
  86. package/dist/native/components/Loader/Loader/Loader.type.js +2 -0
  87. package/dist/native/components/Loader/Loader/Loader.type.js.map +1 -0
  88. package/dist/native/components/Modal/Modal/Modal.type.d.ts +4 -0
  89. package/dist/native/components/Modal/Modal/Modal.type.js +2 -0
  90. package/dist/native/components/Modal/Modal/Modal.type.js.map +1 -0
  91. package/dist/native/components/Router/Router.match.js +1 -1
  92. package/dist/native/components/Router/Router.match.js.map +1 -1
  93. package/dist/native/components/Router/index.d.ts +1 -1
  94. package/dist/native/components/Slider/Slider/Slider.state.js +7 -4
  95. package/dist/native/components/Slider/Slider/Slider.state.js.map +1 -1
  96. package/dist/native/components/Tabs/Tabs/Tabs.type.d.ts +53 -0
  97. package/dist/native/components/Tabs/Tabs/Tabs.type.js +2 -0
  98. package/dist/native/components/Tabs/Tabs/Tabs.type.js.map +1 -0
  99. package/dist/native/components/Toast/Toast/Toast.view.js +3 -3
  100. package/dist/native/components/Toast/Toast/Toast.view.js.map +1 -1
  101. package/dist/native/pages/designSystem.page.js +12 -10
  102. package/dist/native/pages/designSystem.page.js.map +1 -1
  103. package/dist/web.cjs.js +7 -7
  104. package/dist/web.cjs.js.map +1 -1
  105. package/dist/web.esm.js +4706 -4695
  106. package/dist/web.esm.js.map +1 -1
  107. package/dist/web.umd.js +7 -7
  108. package/dist/web.umd.js.map +1 -1
  109. package/docs/design-system/llm-design-system.md +41 -9
  110. package/docs/design-system/theming.md +38 -0
  111. package/docs/getting-started/introduction.md +74 -4
  112. package/package.json +1 -1
@@ -17,15 +17,21 @@ is the **physics**.
17
17
 
18
18
  ---
19
19
 
20
- ## 0. TL;DR — the five rules that make a config coherent
20
+ ## 0. TL;DR — the six rules that make a config coherent
21
21
 
22
22
  1. **Stay vs adapt is decided by the value's *form*.**
23
23
  - **Raw hex** (`"#2563eb"`) → **constant** in both modes. Use for brand identity.
24
24
  - **`color-*` token** (`"color-black"`) → **flips** automatically. Use for structural neutrals.
25
+ - Corollary: **never branch on the mode to pick a color** (`isDark ? a : b`).
26
+ Both branches already flip, so a ternary double-inverts — or freezes if the
27
+ signal doesn't track the toggle. If you feel the need to branch, you picked
28
+ the wrong token form.
25
29
  2. **Brand colors are FILLS, not foreground.** `theme-primary` paints a
26
30
  background and pairs with `theme-onPrimary` ink. **Never** use `theme-primary`
27
31
  as the text/border color of something sitting directly on a surface — for a
28
- black/white brand it collides with the surface and vanishes.
32
+ black/white brand it collides with the surface and vanishes. And never compute
33
+ the ink with luminance math — read `theme-onPrimary`; it's the
34
+ contrast-validated slot.
29
35
  3. **Surface-contrasting foreground uses neutrals.** Body text, borders,
30
36
  dividers, helper text → `theme-text` / `theme-muted` / `theme-border` (or the
31
37
  `color-*` neutrals). These flip with the surface, so they stay readable on any
@@ -33,12 +39,22 @@ is the **physics**.
33
39
  4. **`primary` and `onPrimary` must use the *same form*.** Both hex, or both
34
40
  `color-*`. That keeps the fill and its ink flipping together (or staying
35
41
  together) so the label never disappears.
36
- 5. **Never put a token into a raw inline `style={{}}` or a gradient string.** The
37
- resolver only runs on component **props**. Tokens in raw CSS silently break
38
- (fine for hex, invisible for `color-*`). This rule is about *consuming* configs;
39
- you don't hit it while authoring one, but it's why neutrals must be tokens.
40
-
41
- Everything below is an expansion of these five rules.
42
+ 5. **Know where tokens resolve — and where they silently die.** The resolver runs
43
+ on component **props**, *including string props*: `border={`1px solid
44
+ ${token}`}`, gradient and `boxShadow` strings all get embedded tokens
45
+ rewritten to `var(--…)`. Tokens die in exactly three places: **raw React
46
+ `style={{}}` objects** (bypass the resolver), **JS pre-resolution** through
47
+ static/light-only maps (the result freezes to the light value), and
48
+ **malformed tokens built by concatenation** (rule 6). This rule is about
49
+ *consuming* configs; it's also why neutrals must be tokens.
50
+ 6. **Alpha is a token suffix, never blind concatenation.** `theme-primary-100` =
51
+ 10 %, `color-blue-500-200` = 20 % (alpha 0–1000). Never append a second
52
+ suffix to an already-suffixed token (`color-gray-50-900-100` resolves against
53
+ a CSS variable that doesn't exist), and never concatenate onto a value of
54
+ unknown form (`${palette[0]}15` breaks the day the value is a token instead
55
+ of hex — route mixed-form values through a helper).
56
+
57
+ Everything below is an expansion of these six rules.
42
58
 
43
59
  ---
44
60
 
@@ -330,6 +346,7 @@ Run through every item — these map 1:1 to the failure modes this system has hi
330
346
  - [ ] `onPrimary` contrasts `primary` ≥ 4.5:1.
331
347
  - [ ] `primary` reads ≥ 3:1 on **both** white and black.
332
348
  - [ ] **No `color-*` shade outside `50…900`.** No `920/950/960`.
349
+ - [ ] **`tokens.colors[].value` entries are hex** — they get embedded into gradients/charts where a token would break downstream.
333
350
  - [ ] **No brand slot used as body ink**; body uses `text` / `muted`.
334
351
  - [ ] **No `theme-primary` used as foreground-on-surface for a monochrome brand** (use `theme-text` / `theme-secondary`).
335
352
  - [ ] Every font in `typography` is listed in `metadata.googleFontLinks`; the stack ends in a system fallback.
@@ -341,6 +358,8 @@ Run through every item — these map 1:1 to the failure modes this system has hi
341
358
 
342
359
  ## 9. Anti-patterns (do NOT do these)
343
360
 
361
+ Authoring a config:
362
+
344
363
  | ❌ Anti-pattern | Why it breaks | ✅ Instead |
345
364
  |----------------|---------------|-----------|
346
365
  | `"text": "#111111"` | Frozen dark ink → invisible on dark canvas | `"text": "color-black"` |
@@ -349,8 +368,21 @@ Run through every item — these map 1:1 to the failure modes this system has hi
349
368
  | `primary` hex + `onPrimary` `"color-white"` | Mismatched forms → label flips off the fill | Same form for both |
350
369
  | `theme-primary` as outline/link color on a **black** brand | Collides with the surface, vanishes | `theme-text` or `theme-secondary` |
351
370
  | Writing a separate `<brand>.dark.json` | Unnecessary; dark is derived | One config, adaptive tokens |
352
- | Adding `appearance === 'dark' ? … : …` anywhere | The system flips for you via tokens | Use the right token form |
353
371
  | `color-gray-950` | Invalid shade | `color-gray-900` |
372
+ | `tokens.colors[].value` holding a token | Palette values get embedded in gradients/charts | Hex only in `tokens.colors[].value` |
373
+
374
+ Consuming a config (component/page code) — each of these is a real production
375
+ failure we have hit:
376
+
377
+ | ❌ Anti-pattern | Why it breaks | ✅ Instead |
378
+ |----------------|---------------|-----------|
379
+ | `isDark ? 'color-gray-900' : 'color-gray-50'` | Both tokens already flip → the ternary double-inverts and picks the wrong one in dark | The single adaptive token |
380
+ | Branching colors on a signal that isn't the toggle (`identity.theme`, cached mode) | The branch freezes; the section desyncs from the rest of the page when the user toggles | Adaptive tokens; mode flags only for behavior (e.g. `reversed`) |
381
+ | Token inside raw `style={{ boxShadow: '… color-black-150' }}` | Raw `style` bypasses the resolver → declaration silently dropped | Move to the app-studio prop (`boxShadow={…}`) |
382
+ | Pre-resolving in JS (`normalizeToHex(theme.canvas)`) and rendering the result | Static maps are light-only → value frozen to light mode | Pass the token as a prop; `getColor` only for non-app-studio consumers (charts, canvas, svg) |
383
+ | `${palette[0]}15`, `hex + '80'`, `token + '-900'` on unknown-form values | Valid for only one form; double suffixes resolve to nonexistent variables — silent transparent | Single alpha suffix on a known token; a form-aware helper for mixed values |
384
+ | Luminance math / hardcoded `color-white` for button ink | Discards the contrast-validated `onPrimary`; NaNs on token input | `color="theme-onPrimary"` on a `theme-primary` fill |
385
+ | "Fixing" `border={`1px solid ${borderColor}`}` by pre-resolving it | Token-bearing **string props are valid** — the resolver rewrites them to `var(--…)` | Leave it (or use the `borderWidth`/`borderStyle`/`borderColor` prop triple) |
354
386
 
355
387
  ---
356
388
 
@@ -187,6 +187,44 @@ function Snippet() {
187
187
  }
188
188
  ```
189
189
 
190
+ ### 3.5 Where tokens resolve — and where they silently die
191
+
192
+ The resolver runs on **app-studio component props — including string props**.
193
+ `processStyleProperty` scans any string prop value for tokens and rewrites each
194
+ to `var(--…)`, so all of these are valid and flip per mode:
195
+
196
+ ```tsx
197
+ <View borderColor="theme-border" /> // plain prop
198
+ <View border={`1px solid ${borderColor}`} /> // token inside a shorthand string — VALID
199
+ <View background={`linear-gradient(90deg, ${palette0}, transparent)`} /> // token inside a gradient string — VALID
200
+ <View boxShadow={`0 10px 25px -5px color-black-300`} /> // token inside a shadow string — VALID
201
+ ```
202
+
203
+ Tokens die in exactly **three** places:
204
+
205
+ 1. **Raw React `style={{}}` objects** (and any CSS emitted outside app-studio
206
+ props — `className` CSS, `<style>` strings, iframe-injected CSS). These
207
+ bypass the resolver; the token is invalid CSS and the whole declaration is
208
+ silently dropped. Symptom: missing shadow/background/border, no error.
209
+ 2. **JS pre-resolution.** Resolving a token to a hex in JS (a static token→hex
210
+ map, a `normalizeToHex`-style helper, `getColorHex` cached at module scope)
211
+ produces the **light** value and freezes it — the rendered color never flips.
212
+ Pass the token through as a prop instead; call `useTheme().getColor` only for
213
+ non-app-studio consumers (charts, canvas, svg attributes), inside the
214
+ component so it tracks the live mode.
215
+ 3. **Malformed tokens from concatenation.** A second alpha suffix on an
216
+ already-suffixed token (`color-gray-50-900` + `-100` → `color-gray-50-900-100`)
217
+ resolves against a CSS variable that does not exist; a suffix concatenated
218
+ onto a value of unknown form (`${palette[0]}15`) is valid for hex and broken
219
+ for tokens. Append a **single** alpha suffix to a **known** token; route
220
+ mixed-form values through a form-aware helper.
221
+
222
+ Corollary — the mode-branching trap: never pick a color with
223
+ `isDark ? tokenA : tokenB`. Both tokens already flip, so the ternary
224
+ double-inverts (or freezes, if the branching signal doesn't track the toggle).
225
+ Mode flags are for *behavior* (e.g. a Button's `reversed`), never for choosing
226
+ a color value.
227
+
190
228
  ---
191
229
 
192
230
  ## 4. Token reference
@@ -44,20 +44,90 @@ compatibility matrix, Reanimated wiring, and Metro/typecheck configuration.
44
44
 
45
45
  ## Quick Start
46
46
 
47
+ Wrap your app in `ThemeProvider` — it defines the CSS variables that every
48
+ `color-*` and `theme-*` token resolves against. Without it, tokens fall back to
49
+ undefined variables and components render uncoloured.
50
+
47
51
  ```jsx
48
52
  import React from 'react';
53
+ import { ThemeProvider, Vertical } from 'app-studio';
49
54
  import { Button, Text } from '@app-studio/components';
50
55
 
51
56
  function App() {
52
57
  return (
53
- <div>
54
- <Text>Hello, world!</Text>
55
- <Button onClick={() => alert('Clicked!')}>Click me</Button>
56
- </div>
58
+ <ThemeProvider>
59
+ <Vertical gap={12} padding={24}>
60
+ <Text>Hello, world!</Text>
61
+ <Button onClick={() => console.log('Clicked!')}>Click me</Button>
62
+ </Vertical>
63
+ </ThemeProvider>
57
64
  );
58
65
  }
59
66
  ```
60
67
 
68
+ ### Baseline document styles
69
+
70
+ This library styles **components, not the document**. It ships no CSS reset, so
71
+ the page keeps the browser's defaults until you set them yourself. On a fresh
72
+ project that shows up immediately as:
73
+
74
+ - body text in the browser's serif font, because nothing sets a `font-family`;
75
+ - an 8px `body` margin, which makes any `100vh` shell overflow by 16px and
76
+ produces a scrollbar you did not ask for;
77
+ - blue underlined `<a>` elements, including router links wrapping components.
78
+
79
+ A dozen lines are enough, and none of it competes with the design system:
80
+
81
+ ```css
82
+ *,
83
+ *::before,
84
+ *::after {
85
+ box-sizing: border-box;
86
+ }
87
+
88
+ html,
89
+ body {
90
+ margin: 0;
91
+ padding: 0;
92
+ }
93
+
94
+ body {
95
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
96
+ -webkit-font-smoothing: antialiased;
97
+ }
98
+
99
+ a {
100
+ color: inherit;
101
+ text-decoration: none;
102
+ }
103
+ ```
104
+
105
+ Keep it to resets. Colours, spacing and typography should still come from the
106
+ theme so they stay adaptive to light/dark mode.
107
+
108
+ ### Control sizes line up
109
+
110
+ Form controls of the same `size` render at the same height, so they can sit in a
111
+ row without extra alignment work. At `md` — the default — `TextField`, `Select`
112
+ and `Button` are all exactly 40px:
113
+
114
+ ```jsx
115
+ <Horizontal gap={10} alignItems="center">
116
+ <TextField name="search" placeholder="Search…" />
117
+ <Select name="status" placeholder="Any status" options={options} />
118
+ <Button variant="outline">Filter</Button>
119
+ </Horizontal>
120
+ ```
121
+
122
+ The scale is `xs` 24, `sm` 32, `md` 40, `lg` 48, `xl` 56, and it is shared: it
123
+ lives in `Input/fieldSizes` and is applied by the field shell, so `TextField`,
124
+ `Password`, `Select`, `DatePicker`, `TagInput` and `Button` all render exactly
125
+ their declared height at every size — including bordered variants, which used to
126
+ come out 2px taller.
127
+
128
+ `ComboBox` is the exception: it takes no `size` prop
129
+ (`Omit<InputProps, 'size'>`) and always renders at 40px, matching `md`.
130
+
61
131
  ## Component Categories
62
132
 
63
133
  The library includes components in the following categories:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-studio/components",
3
- "version": "0.10.21",
3
+ "version": "0.10.23",
4
4
  "main": "dist/web.cjs.js",
5
5
  "module": "dist/web.esm.js",
6
6
  "react-native": "dist/native/components/index.js",