@tenphi/tasty 0.14.2 → 0.15.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/docs/runtime.md CHANGED
@@ -74,6 +74,86 @@ For predefined style prop lists (`FLOW_STYLES`, `POSITION_STYLES`, `DIMENSION_ST
74
74
 
75
75
  ---
76
76
 
77
+ ## Mod Props
78
+
79
+ Use `modProps` to expose modifier keys as direct component props instead of requiring the `mods` object:
80
+
81
+ ```jsx
82
+ // Before: mods object
83
+ <Button mods={{ isLoading: true, size: 'large' }}>Submit</Button>
84
+
85
+ // After: mod props
86
+ <Button isLoading size="large">Submit</Button>
87
+ ```
88
+
89
+ ### Array form
90
+
91
+ List modifier key names. Types default to `ModValue` (`boolean | string | number | undefined | null`):
92
+
93
+ ```jsx
94
+ const Button = tasty({
95
+ modProps: ['isLoading', 'isSelected'] as const,
96
+ styles: {
97
+ fill: { '': '#surface', isLoading: '#surface.5' },
98
+ border: { '': '1bw solid #outline', isSelected: '2bw solid #primary' },
99
+ },
100
+ });
101
+
102
+ <Button isLoading isSelected>Submit</Button>
103
+ // Renders: <button data-is-loading="" data-is-selected="">Submit</button>
104
+ ```
105
+
106
+ ### Object form (typed)
107
+
108
+ Map modifier names to type descriptors for precise TypeScript types:
109
+
110
+ ```tsx
111
+ const Button = tasty({
112
+ modProps: {
113
+ isLoading: Boolean, // isLoading?: boolean
114
+ isSelected: Boolean, // isSelected?: boolean
115
+ size: ['small', 'medium', 'large'] as const, // size?: 'small' | 'medium' | 'large'
116
+ },
117
+ styles: {
118
+ padding: { '': '2x 4x', 'size=small': '1x 2x', 'size=large': '3x 6x' },
119
+ fill: { '': '#surface', isLoading: '#surface.5' },
120
+ },
121
+ });
122
+
123
+ <Button isLoading size="large">Submit</Button>
124
+ // Renders: <button data-is-loading="" data-size="large">Submit</button>
125
+ ```
126
+
127
+ Available type descriptors:
128
+
129
+ | Descriptor | TypeScript type | Example |
130
+ |---|---|---|
131
+ | `Boolean` | `boolean` | `isLoading: Boolean` |
132
+ | `String` | `string` | `label: String` |
133
+ | `Number` | `number` | `count: Number` |
134
+ | `['a', 'b'] as const` | `'a' \| 'b'` | `size: ['sm', 'md', 'lg'] as const` |
135
+
136
+ ### Merge with `mods`
137
+
138
+ Mod props and the `mods` object can be used together. Mod props take precedence:
139
+
140
+ ```jsx
141
+ <Button mods={{ isLoading: false, extra: true }} isLoading>
142
+ // isLoading=true wins (from mod prop), extra=true preserved from mods
143
+ ```
144
+
145
+ ### When to use `modProps` vs `mods`
146
+
147
+ | Use case | Recommendation |
148
+ |---|---|
149
+ | Component has a fixed set of known modifiers | `modProps` — cleaner API, better TypeScript autocomplete |
150
+ | Component needs arbitrary/dynamic modifiers | `mods` — open-ended `Record<string, ModValue>` |
151
+ | Both fixed and dynamic | Combine: `modProps` for known keys, `mods` for ad-hoc |
152
+
153
+ For architecture guidance on when to use modifiers vs `styleProps`, see [Methodology — modProps and mods](methodology.md#modprops-and-mods).
154
+
155
+ ---
156
+
77
157
  ## Variants
78
158
 
79
159
  Define named style variations. Only CSS for variants actually used at runtime is injected:
package/docs/styles.md CHANGED
@@ -146,37 +146,39 @@ Individual props `marginTop`, `marginRight`, `marginBottom`, `marginLeft`, `marg
146
146
 
147
147
  ### `width`
148
148
 
149
- Element width with min/max control.
149
+ Element width with min/max control. One, two, or three values set `min-width`, `width`, and `max-width` together.
150
150
 
151
- **Syntax:** `[value]` | `[min max]` | `[min value max]` | `[modifier value]`
151
+ **Positional syntax:**
152
152
 
153
- **Modifiers:** `min`, `max`, `fixed`
153
+ | Value | min-width | width | max-width |
154
+ |-------|-----------|-------|-----------|
155
+ | `"10x"` | initial | `10x` | initial |
156
+ | `"1x 10x"` | `1x` | auto | `10x` |
157
+ | `"1x 5x 10x"` | `1x` | `5x` | `10x` |
158
+ | `"0 100% 800px"` | `0` | `100%` | `800px` |
159
+ | `"initial 100% 1400px"` | initial | `100%` | `1400px` |
160
+
161
+ **Modifier syntax:**
162
+
163
+ | Value | min-width | width | max-width |
164
+ |-------|-----------|-------|-----------|
165
+ | `"min 2x"` | `2x` | auto | initial |
166
+ | `"max 100%"` | initial | auto | `100%` |
167
+ | `"fixed 200px"` | `200px` | `200px` | `200px` |
154
168
 
155
169
  **Keywords:** `stretch`, `max-content`, `min-content`, `fit-content`
156
170
 
157
171
  | Value | Effect |
158
172
  |-------|--------|
159
- | `"10x"` | Width `10x`, min `initial`, max `initial` |
160
- | `"1x 10x"` | Width `auto`, min `1x`, max `10x` |
161
- | `"1x 5x 10x"` | Min `1x`, width `5x`, max `10x` |
162
- | `"min 2x"` | Min-width `2x`, width `auto`, max `initial` |
163
- | `"max 100%"` | Max-width `100%`, width `auto`, min `initial` |
164
- | `"fixed 200px"` | Min, width, and max all set to `200px` |
165
173
  | `"stretch"` | Fill available space (cross-browser) |
166
- | `true` | Width `auto`, min `initial`, max `initial` |
174
+ | `true` | Reset to `auto` / `initial` / `initial` |
167
175
  | Number | Converted to `px` |
168
176
 
169
177
  Separate `minWidth` and `maxWidth` props are supported and override values from the `width` syntax.
170
178
 
171
179
  ### `height`
172
180
 
173
- Element height. Same syntax and modifiers as `width`.
174
-
175
- **Syntax:** `[value]` | `[min max]` | `[min value max]` | `[modifier value]`
176
-
177
- **Modifiers:** `min`, `max`, `fixed`
178
-
179
- **Keywords:** `max-content`, `min-content`, `fit-content`
181
+ Element height. Same syntax, modifiers, and positional patterns as `width`.
180
182
 
181
183
  Separate `minHeight` and `maxHeight` props are supported and override values from the `height` syntax.
182
184
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenphi/tasty",
3
- "version": "0.14.2",
3
+ "version": "0.15.1",
4
4
  "description": "A design-system-integrated styling system and DSL for concise, state-aware UI styling",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",