@greese/ui 1.0.0 → 1.2.0

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 (210) hide show
  1. package/README.md +19 -14
  2. package/dist/_maps.scss +1 -1
  3. package/dist/_tokens-base.scss +30 -6
  4. package/dist/_tokens.scss +31 -2
  5. package/dist/_utilities-table.scss +1615 -0
  6. package/dist/clipboard.d.ts +18 -0
  7. package/dist/clipboard.js +62 -0
  8. package/dist/css/Button.css +2 -2
  9. package/dist/css/Carousel.css +145 -47
  10. package/dist/css/Checkbox.css +2 -2
  11. package/dist/css/Chip.css +38 -8
  12. package/dist/css/ChoiceGroup.css +42 -1
  13. package/dist/css/Collapsible.css +1 -0
  14. package/dist/css/ColorPicker.css +84 -0
  15. package/dist/css/Combobox.css +2 -2
  16. package/dist/css/Dialog.css +24 -22
  17. package/dist/css/EditableField.css +219 -0
  18. package/dist/css/Input.css +11 -2
  19. package/dist/css/Menu.css +9 -0
  20. package/dist/css/NumberField.css +53 -8
  21. package/dist/css/NumberStepper.css +9 -0
  22. package/dist/css/OtpField.css +1 -1
  23. package/dist/css/PageTransition.css +12 -0
  24. package/dist/css/Radio.css +2 -2
  25. package/dist/css/ScrollCarousel.css +225 -0
  26. package/dist/css/SegmentedControl.css +2 -2
  27. package/dist/css/Select.css +3 -2
  28. package/dist/css/Slider.css +45 -5
  29. package/dist/css/Switch.css +6 -6
  30. package/dist/css/Text.css +14 -14
  31. package/dist/css/Textarea.css +1 -1
  32. package/dist/css/core.css +36 -6
  33. package/dist/css/resets.css +162 -0
  34. package/dist/css.d.ts +2 -0
  35. package/dist/css.js +2 -0
  36. package/dist/greese.css +990 -138
  37. package/dist/index.d.ts +2 -1
  38. package/dist/index.js +2 -1
  39. package/dist/scss/components/_Accordion.scss +2 -0
  40. package/dist/scss/components/_ActionSelect.scss +2 -0
  41. package/dist/scss/components/_Alert.scss +2 -0
  42. package/dist/scss/components/_AppBar.scss +2 -0
  43. package/dist/scss/components/_AspectRatio.scss +2 -0
  44. package/dist/scss/components/_AutoLayout.scss +2 -0
  45. package/dist/scss/components/_Avatar.scss +2 -0
  46. package/dist/scss/components/_Badge.scss +2 -0
  47. package/dist/scss/components/_Box.scss +2 -0
  48. package/dist/scss/components/_Breadcrumbs.scss +2 -0
  49. package/dist/scss/components/_Button.scss +2 -0
  50. package/dist/scss/components/_ButtonGroup.scss +2 -0
  51. package/dist/scss/components/_Card.scss +2 -0
  52. package/dist/scss/components/_Carousel.scss +2 -0
  53. package/dist/scss/components/_Center.scss +2 -0
  54. package/dist/scss/components/_ChatBubble.scss +2 -0
  55. package/dist/scss/components/_Checkbox.scss +2 -0
  56. package/dist/scss/components/_Chip.scss +2 -0
  57. package/dist/scss/components/_ChoiceGroup.scss +2 -0
  58. package/dist/scss/components/_Code.scss +2 -0
  59. package/dist/scss/components/_Collapsible.scss +2 -0
  60. package/dist/scss/components/_ColorPicker.scss +2 -0
  61. package/dist/scss/components/_Combobox.scss +2 -0
  62. package/dist/scss/components/_Container.scss +2 -0
  63. package/dist/scss/components/_Countdown.scss +2 -0
  64. package/dist/scss/components/_DateField.scss +2 -0
  65. package/dist/scss/components/_Dialog.scss +2 -0
  66. package/dist/scss/components/_Diff.scss +2 -0
  67. package/dist/scss/components/_Divider.scss +2 -0
  68. package/dist/scss/components/_Dock.scss +2 -0
  69. package/dist/scss/components/_EditableField.scss +2 -0
  70. package/dist/scss/components/_Field.scss +2 -0
  71. package/dist/scss/components/_Fieldset.scss +2 -0
  72. package/dist/scss/components/_FileInput.scss +2 -0
  73. package/dist/scss/components/_Footer.scss +2 -0
  74. package/dist/scss/components/_Grid.scss +2 -0
  75. package/dist/scss/components/_Header.scss +2 -0
  76. package/dist/scss/components/_Heading.scss +2 -0
  77. package/dist/scss/components/_Icon.scss +2 -0
  78. package/dist/scss/components/_IconButton.scss +2 -0
  79. package/dist/scss/components/_Image.scss +2 -0
  80. package/dist/scss/components/_Indicator.scss +2 -0
  81. package/dist/scss/components/_Input.scss +2 -0
  82. package/dist/scss/components/_Key.scss +2 -0
  83. package/dist/scss/components/_Link.scss +2 -0
  84. package/dist/scss/components/_List.scss +2 -0
  85. package/dist/scss/components/_Media.scss +2 -0
  86. package/dist/scss/components/_Menu.scss +2 -0
  87. package/dist/scss/components/_Motion.scss +2 -0
  88. package/dist/scss/components/_NumberField.scss +2 -0
  89. package/dist/scss/components/_NumberStepper.scss +2 -0
  90. package/dist/scss/components/_OtpField.scss +2 -0
  91. package/dist/scss/components/_PageTransition.scss +2 -0
  92. package/dist/scss/components/_Pagination.scss +2 -0
  93. package/dist/scss/components/_Popover.scss +2 -0
  94. package/dist/scss/components/_Progress.scss +2 -0
  95. package/dist/scss/components/_RadialProgress.scss +2 -0
  96. package/dist/scss/components/_Radio.scss +2 -0
  97. package/dist/scss/components/_Rating.scss +2 -0
  98. package/dist/scss/components/_ScrollCarousel.scss +2 -0
  99. package/dist/scss/components/_ScrollSpy.scss +2 -0
  100. package/dist/scss/components/_SegmentedControl.scss +2 -0
  101. package/dist/scss/components/_Select.scss +2 -0
  102. package/dist/scss/components/_Sidebar.scss +2 -0
  103. package/dist/scss/components/_Skeleton.scss +2 -0
  104. package/dist/scss/components/_Slider.scss +2 -0
  105. package/dist/scss/components/_Spacer.scss +2 -0
  106. package/dist/scss/components/_SpeedDial.scss +2 -0
  107. package/dist/scss/components/_Spinner.scss +2 -0
  108. package/dist/scss/components/_Stack.scss +2 -0
  109. package/dist/scss/components/_Stat.scss +2 -0
  110. package/dist/scss/components/_Status.scss +2 -0
  111. package/dist/scss/components/_Steps.scss +2 -0
  112. package/dist/scss/components/_Swap.scss +2 -0
  113. package/dist/scss/components/_Switch.scss +2 -0
  114. package/dist/scss/components/_Table.scss +2 -0
  115. package/dist/scss/components/_Tabs.scss +2 -0
  116. package/dist/scss/components/_Text.scss +2 -0
  117. package/dist/scss/components/_TextRotate.scss +2 -0
  118. package/dist/scss/components/_Textarea.scss +2 -0
  119. package/dist/scss/components/_ThemeProvider.scss +2 -0
  120. package/dist/scss/components/_Tile.scss +2 -0
  121. package/dist/scss/components/_Toast.scss +2 -0
  122. package/dist/scss/components/_ToggleButton.scss +2 -0
  123. package/dist/scss/components/_Tooltip.scss +2 -0
  124. package/dist/scss/components/_Type.scss +2 -0
  125. package/dist/scss/components/_Visibility.scss +2 -0
  126. package/dist/scss/components/_VisuallyHidden.scss +2 -0
  127. package/dist/shapes.d.ts +12 -1
  128. package/dist/shapes.js +11 -10
  129. package/dist/style-manifest.json +18837 -132
  130. package/dist/theme.js +6 -1
  131. package/dist/themeFiles/index.d.ts +9 -0
  132. package/dist/themeFiles/index.js +9 -0
  133. package/dist/themeFiles/scssModule.d.ts +100 -0
  134. package/dist/themeFiles/scssModule.js +384 -0
  135. package/dist/themeFiles/spec.d.ts +198 -0
  136. package/dist/themeFiles/spec.js +877 -0
  137. package/dist/tokens.css +30 -1
  138. package/dist/typography.js +1 -1
  139. package/dist/utilities.css +435 -0
  140. package/dist/utilities.d.ts +8 -0
  141. package/dist/utilities.js +75 -0
  142. package/package.json +20 -1
  143. package/src/components/AutoLayout/AutoLayout.scss +2 -26
  144. package/src/components/Carousel/Carousel.scss +122 -126
  145. package/src/components/Checkbox/Checkbox.scss +2 -2
  146. package/src/components/Chip/Chip.scss +63 -8
  147. package/src/components/ChoiceGroup/ChoiceGroup.scss +19 -1
  148. package/src/components/Collapsible/Collapsible.scss +3 -0
  149. package/src/components/ColorPicker/ColorPicker.scss +95 -0
  150. package/src/components/Combobox/Combobox.scss +4 -2
  151. package/src/components/Dialog/Dialog.scss +24 -7
  152. package/src/components/EditableField/EditableField.scss +275 -0
  153. package/src/components/Grid/Grid.scss +2 -70
  154. package/src/components/Input/Input.scss +29 -0
  155. package/src/components/Menu/Menu.scss +18 -0
  156. package/src/components/NumberField/NumberField.scss +56 -9
  157. package/src/components/NumberStepper/NumberStepper.scss +13 -0
  158. package/src/components/PageTransition/PageTransition.scss +29 -0
  159. package/src/components/Radio/Radio.scss +2 -2
  160. package/src/components/ScrollCarousel/ScrollCarousel.scss +142 -0
  161. package/src/components/Select/Select.scss +4 -0
  162. package/src/components/Slider/Slider.scss +51 -6
  163. package/src/components/Stack/Stack.scss +2 -48
  164. package/src/components/Switch/Switch.scss +9 -6
  165. package/src/components/Text/Text.scss +5 -2
  166. package/src/styles/_breakpoint-vars.scss +17 -11
  167. package/src/styles/_controls.scss +2 -2
  168. package/src/styles/_core.scss +1 -0
  169. package/src/styles/_kit.scss +483 -56
  170. package/src/styles/_layout-props.scss +197 -0
  171. package/src/styles/_manifest.scss +55 -25
  172. package/src/styles/_mixins.scss +53 -15
  173. package/src/styles/_slides.scss +112 -0
  174. package/src/styles/_utilities.scss +104 -0
  175. package/src/styles/breakpoints.test.ts +21 -1
  176. package/src/styles/entryPoints.test.ts +25 -2
  177. package/src/styles/index.scss +3 -1
  178. package/src/styles/kit.test.ts +171 -1
  179. package/src/styles/public/_breakpoints.scss +43 -0
  180. package/src/styles/public/_slides.scss +3 -0
  181. package/src/styles/public/_utilities.scss +3 -0
  182. package/src/styles/resets.scss +7 -0
  183. package/src/styles/utilities.test.ts +39 -0
  184. package/themes/bevel.css +187 -187
  185. package/themes/bevel.scss +960 -958
  186. package/themes/candy.css +87 -0
  187. package/themes/candy.scss +32 -0
  188. package/themes/extrude.css +42 -42
  189. package/themes/folio.css +200 -200
  190. package/themes/folio.scss +880 -878
  191. package/themes/forest.css +87 -0
  192. package/themes/forest.scss +32 -0
  193. package/themes/grape.css +87 -0
  194. package/themes/grape.scss +32 -0
  195. package/themes/greese.css +36 -0
  196. package/themes/greese.scss +21 -0
  197. package/themes/mono.css +87 -0
  198. package/themes/mono.scss +32 -0
  199. package/themes/ocean.css +87 -0
  200. package/themes/ocean.scss +32 -0
  201. package/themes/outline.css +18 -18
  202. package/themes/pebble.css +8 -8
  203. package/themes/ridge.css +188 -188
  204. package/themes/ridge.scss +820 -818
  205. package/themes/soft.css +11 -11
  206. package/themes/sunset.css +87 -0
  207. package/themes/sunset.scss +32 -0
  208. package/themes/ticket.css +180 -180
  209. package/themes/ticket.scss +881 -879
  210. package/themes/tilt.css +25 -25
@@ -0,0 +1,198 @@
1
+ /**
2
+ * A theme as data: plain JSON, the file Theme Studio (or any other tool)
3
+ * reads and writes. `specToLayout()` turns it into a folder of SCSS modules
4
+ * that use the SCSS kit (`pkg:@greese/ui/scss/kit`), to keep in your source
5
+ * and edit a part at a time; `specToScss()` into one file. Either compiles
6
+ * exactly like a theme written by hand. Pure: Node and the browser both use
7
+ * it (`@greese/ui/theme-files`).
8
+ */
9
+ import { type ShapeDef, type ShapeSize } from '../shapes.ts';
10
+ /** One value for both schemes, or a light/dark pair. */
11
+ export type SchemeValue = string | {
12
+ light: string;
13
+ dark: string;
14
+ };
15
+ /** CSS declarations: `{ 'font-weight': '700' }`. */
16
+ export type Declarations = Record<string, string>;
17
+ export interface MotionSpec {
18
+ /** An effect that ends at rest, kebab-case: `fade-up`, or one of the theme's own. */
19
+ enter?: string;
20
+ /** Your own `@keyframes` name, instead of a preset. */
21
+ keyframes?: string;
22
+ /** An overlay exit, kebab-case: `fade-out`, `scale-out`, or one of the theme's own. */
23
+ exit?: string;
24
+ duration?: string;
25
+ delay?: string;
26
+ ease?: string;
27
+ distance?: string;
28
+ /** Transition speeds for this component: `{ fast: '80ms' }`. */
29
+ durations?: Record<string, string>;
30
+ /** Transition curves for this component: `{ standard: 'linear' }`. */
31
+ easings?: Record<string, string>;
32
+ }
33
+ export interface ComponentSpec {
34
+ /** Declarations on the component's root class. */
35
+ styles?: Declarations;
36
+ /** Component variables and tokens, without `--greese-`: `{ 'button-tone': '…' }`. */
37
+ vars?: Record<string, SchemeValue>;
38
+ /** Declarations per modifier: `{ outline: { 'border-width': '2px' } }`. */
39
+ modifiers?: Record<string, Declarations>;
40
+ /** Declarations per part: `{ icon: { opacity: '0.8' } }`. */
41
+ parts?: Record<string, Declarations>;
42
+ /**
43
+ * The SCSS of this component and what it contains (ADR 0021): leading `@use`
44
+ * lines, then a body written inside `.greese-<Name>` (`&`, nesting, mixins,
45
+ * the kit). The Studio starts it from the library's own SCSS for the family;
46
+ * it is stored only once edited, and then applies in full, inside this
47
+ * component only.
48
+ */
49
+ scss?: string;
50
+ motion?: MotionSpec;
51
+ /** One of the theme's shapes (`shapes`), by name: its outline, border and motion. */
52
+ shape?: string;
53
+ }
54
+ /**
55
+ * An effect's keyframes, as greese.js takes them and the theme's JSON holds
56
+ * them: a list of frames, or property → values.
57
+ */
58
+ export type ThemeKeyframes = ReadonlyArray<Record<string, unknown>> | Record<string, unknown>;
59
+ /**
60
+ * An effect the theme defines: its keyframes (greese.js's), and how long it
61
+ * runs. A tool that knows greese.js's types narrows `K` to its `Keyframes`.
62
+ */
63
+ export interface EffectSpec<K extends ThemeKeyframes = ThemeKeyframes> {
64
+ keyframes: K;
65
+ /** Seconds. Without one, the effect takes the instance's, else 0.5. */
66
+ duration?: number;
67
+ }
68
+ /**
69
+ * A selector rule for page transitions (ADR 0029; the kit's
70
+ * `page-transitions()`): `'still'` keeps the elements in place, or their own
71
+ * `enter` (an entrance) and `exit` (an exit) by kebab-case name or `none`,
72
+ * `duration` (a token or a time), `delay` and `ease`. What it leaves out
73
+ * follows the theme's page roles.
74
+ */
75
+ export type PageRuleSpec = 'still' | Partial<Record<'enter' | 'exit' | 'duration' | 'delay' | 'ease', string>>;
76
+ /** What a page rule can set. */
77
+ export declare const PAGE_RULE_KEYS: readonly ["enter", "exit", "duration", "delay", "ease"];
78
+ export interface ThemeSpec<K extends ThemeKeyframes = ThemeKeyframes> {
79
+ /**
80
+ * Scope to `data-greese-theme="<name>"` (a complete theme, as
81
+ * `createTheme`). Empty: change the page's defaults.
82
+ */
83
+ name?: string;
84
+ /** Token overrides by group, kebab-case: `{ color: { accent: … }, radius: { md: '12px' } }`. */
85
+ tokens?: Record<string, Record<string, SchemeValue>>;
86
+ /**
87
+ * The breakpoints the stylesheet is built with, key to min-width in px:
88
+ * every key (the five built-in ones stay; added ones are new), smallest
89
+ * first. Absent means the defaults. Setting them makes the studio build the
90
+ * whole stylesheet, since the media queries are fixed in it.
91
+ */
92
+ breakpoints?: Record<string, number>;
93
+ /**
94
+ * The type system by variant, then `base` or a breakpoint, then property:
95
+ * `{ h1: { base: { size: '2rem' }, lg: { size: '4rem' } } }`.
96
+ */
97
+ typography?: Record<string, Record<string, Record<string, string>>>;
98
+ /** Tunes every `greese` prop entrance: duration, delay, ease, distance. */
99
+ motionDefaults?: Record<string, string>;
100
+ /** Parts of a page with page-transition motion of their own, by selector. */
101
+ pageRules?: Record<string, PageRuleSpec>;
102
+ /**
103
+ * Effects by camelCase name. A built-in's name retunes it (a preset's
104
+ * `@keyframes` are overridden in the theme's CSS, and every effect is
105
+ * defined for the runtime); any other name adds a new effect.
106
+ */
107
+ effects?: Record<string, EffectSpec<K>>;
108
+ /** Overrides by component name: `{ Button: { … } }`. */
109
+ components?: Record<string, ComponentSpec>;
110
+ /**
111
+ * Shapes by kebab-case name (ADR 0024): each is a `greese-shape-<name>`
112
+ * class for any element, and components take one with `shape`.
113
+ */
114
+ shapes?: Record<string, ShapeDef>;
115
+ }
116
+ export declare const emptySpec: () => ThemeSpec;
117
+ /** The breakpoints in effect, smallest first: the theme's, else the defaults. */
118
+ export declare const breakpointsOf: (spec: ThemeSpec) => Array<[string, number]>;
119
+ /** The theme's own breakpoints, if they differ from the defaults. */
120
+ export declare const customBreakpoints: (spec: ThemeSpec) => Array<[string, number]> | undefined;
121
+ /** Problems that would make the generated SCSS unsafe or invalid. */
122
+ export declare const validateSpec: (spec: ThemeSpec) => string[];
123
+ /**
124
+ * A token the theme adds: its group exists but the system has no token of
125
+ * that name. (A group that doesn't exist stays an override, so the kit
126
+ * reports it.)
127
+ */
128
+ export declare const isCustomToken: (group: string, key: string) => boolean;
129
+ /** The line that builds the stylesheet (or just its settings) with these breakpoints. */
130
+ export declare const stylesheetScss: (breakpoints: Array<[string, number]>, entry?: "stylesheet" | "config") => string;
131
+ /**
132
+ * The theme as SCSS for the kit. Output is stable (sorted components) so the
133
+ * file diffs cleanly in version control.
134
+ */
135
+ export declare const specToScss: (spec: ThemeSpec, source?: string,
136
+ /** How the stylesheet is brought in: whole (the output), or just its settings. */
137
+ entry?: "stylesheet" | "config") => string;
138
+ /** Where a line of the generated theme came from: a component's SCSS box, and its line there. */
139
+ export interface LineOrigin {
140
+ component: string;
141
+ line: number;
142
+ }
143
+ /**
144
+ * `specToScss`, and which component's SCSS each line of it came from, so a
145
+ * Sass error in the generated file points back at the box and line you wrote.
146
+ */
147
+ export declare const specToScssWithLines: (spec: ThemeSpec, source?: string, entry?: "stylesheet" | "config") => {
148
+ scss: string;
149
+ origin: (line: number) => LineOrigin | undefined;
150
+ };
151
+ /**
152
+ * The theme's shapes (ADR 0024): their parameters registered, a
153
+ * `greese-shape-<name>` class for each, and the components that take one.
154
+ * Written by @greese/ui/shapes, the same code the Studio's editor previews
155
+ * with; each selector goes through the kit's `themed()`, which scopes it to
156
+ * the theme (`scope`, a Sass expression for its name) and, for a component,
157
+ * guards it for the shape layer, so `.greese-reset-shape` and `reset(shape)`
158
+ * reach shapes too.
159
+ */
160
+ export declare const shapesScss: (spec: ThemeSpec, scope?: string, size?: ShapeSize) => string;
161
+ /**
162
+ * The first line of every file `specToLayout()` writes. A tool that rewrites
163
+ * the layout leaves a file alone once this line is gone: whoever deleted it
164
+ * maintains that file by hand now.
165
+ */
166
+ export declare const LAYOUT_MARK = "// greese-theme: generated";
167
+ /**
168
+ * The theme as a folder of SCSS modules, by path inside the folder. Each file
169
+ * is a Sass module that writes its own CSS when it is loaded, so a component,
170
+ * a token group or the motion can be edited, reviewed and replaced alone;
171
+ * `main.scss` loads them and is the file to compile. The theme's CSS is the
172
+ * same as `specToScss()`'s.
173
+ *
174
+ * Every setting has its place, written out even when the theme leaves it
175
+ * alone: each token group's file and the type system's list every default,
176
+ * commented, so a change is an uncomment; `_settings.scss` holds the
177
+ * breakpoints, and builds greese ui's stylesheet and utility classes with them
178
+ * whenever they differ from the library's.
179
+ *
180
+ * main.scss the entry: only `@use` lines
181
+ * _settings.scss breakpoints, `$library`, `$utilities` and `$theme`
182
+ * _library.scss greese ui's stylesheet, built here when `$library`
183
+ * _resets.scss theme layers taken back from components, first
184
+ * tokens/_index.scss one `tokens()` call per group, then the type system
185
+ * tokens/_<group>.scss a group's values (`$tokens`) and new tokens (`$extend`)
186
+ * tokens/_typography.scss
187
+ * motion/_index.scss effects, motion roles and page transitions
188
+ * components/_<name>.scss one component each, its own imports and helpers
189
+ * shapes/_index.scss the shapes, their sizes and what takes them
190
+ * utilities/_index.scss greese ui's utility classes when `$utilities`, and yours
191
+ *
192
+ * `options.components` names component modules of your own
193
+ * (`components/_hero.scss`) for `main.scss` to load too, so a tool that
194
+ * rewrites the layout keeps loading the files it no longer writes.
195
+ */
196
+ export declare const specToLayout: (spec: ThemeSpec, source?: string, options?: {
197
+ components?: string[];
198
+ }) => Record<string, string>;