@scalepad/ui 0.1.1 → 0.2.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/README.md +264 -28
- package/package.json +150 -36
- package/scripts/verify-consumption.mjs +275 -0
- package/src/ThemeProvider.tsx +52 -4
- package/src/components/Anchor/Anchor.css.ts +1 -1
- package/src/components/ColorInput/ColorInput.figma.tsx +32 -0
- package/src/components/ColorInput/ColorInput.tsx +94 -0
- package/src/components/ColorInput/index.ts +6 -0
- package/src/components/IconButton/IconButton.tsx +51 -0
- package/src/components/Select/Select.css.ts +8 -3
- package/src/components/Select/Select.tsx +11 -1
- package/src/components/SubNavigation/SubNavigation.css.ts +20 -0
- package/src/index.ts +8 -0
- package/src/mantine.ts +2 -0
- package/src/theme/themeContract.css.ts +27 -3
- package/src/tokens/color-types.ts +28 -5
- package/src/tokens/colors.ts +52 -10
- package/src/tokens/index.ts +6 -2
- package/src/tokens/semantic-colors.ts +177 -73
- package/src/tokens/semantic-tokens-css.ts +34 -12
- package/src/tokens/shadows.ts +30 -6
- package/src/tokens/text-styles.ts +31 -2
- package/src/vite.d.ts +37 -0
- package/src/vite.js +120 -0
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Text-style variants synced from the LM Design System Figma file
|
|
3
|
+
* (https://www.figma.com/design/VCLfybgU3OaUUPrQdBaVmP/LM-Design-System).
|
|
4
|
+
*
|
|
5
|
+
* Source of truth lives in Figma; edit this file by hand to mirror Figma
|
|
6
|
+
* changes. The Figma MCP is the canonical way to fetch the latest values —
|
|
7
|
+
* use `get_design_context` on the relevant text-style node before changing
|
|
8
|
+
* sizes / weights / line-heights / letter-spacing.
|
|
4
9
|
*/
|
|
5
10
|
|
|
6
11
|
import { rem } from '@mantine/core';
|
|
@@ -73,6 +78,27 @@ export const textStyleVariants = {
|
|
|
73
78
|
lineHeight: rem('21px'),
|
|
74
79
|
letterSpacing: 0,
|
|
75
80
|
},
|
|
81
|
+
body2: {
|
|
82
|
+
fontFamily: undefined,
|
|
83
|
+
fontWeight: 400,
|
|
84
|
+
fontSize: rem('16px'),
|
|
85
|
+
lineHeight: rem('23px'),
|
|
86
|
+
letterSpacing: 0,
|
|
87
|
+
},
|
|
88
|
+
'body2.strong': {
|
|
89
|
+
fontFamily: undefined,
|
|
90
|
+
fontWeight: 500,
|
|
91
|
+
fontSize: rem('16px'),
|
|
92
|
+
lineHeight: rem('23px'),
|
|
93
|
+
letterSpacing: 0,
|
|
94
|
+
},
|
|
95
|
+
'body2.stronger': {
|
|
96
|
+
fontFamily: undefined,
|
|
97
|
+
fontWeight: 600,
|
|
98
|
+
fontSize: rem('16px'),
|
|
99
|
+
lineHeight: rem('23px'),
|
|
100
|
+
letterSpacing: 0,
|
|
101
|
+
},
|
|
76
102
|
caption1: {
|
|
77
103
|
fontFamily: undefined,
|
|
78
104
|
fontWeight: 400,
|
|
@@ -166,6 +192,9 @@ export type BodyVariant =
|
|
|
166
192
|
| 'body1'
|
|
167
193
|
| 'body1.strong'
|
|
168
194
|
| 'body1.stronger'
|
|
195
|
+
| 'body2'
|
|
196
|
+
| 'body2.strong'
|
|
197
|
+
| 'body2.stronger'
|
|
169
198
|
| 'caption1'
|
|
170
199
|
| 'caption1.strong'
|
|
171
200
|
| 'caption1.stronger'
|
package/src/vite.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Hand-authored type declarations for the `@scalepad/ui/vite` preset.
|
|
2
|
+
// The runtime implementation lives at `./vite.js` (plain JS, not TS — see the
|
|
3
|
+
// note at the top of that file for why this file isn't authored as `.ts`).
|
|
4
|
+
|
|
5
|
+
import type { VanillaExtractPluginOptions } from '@vanilla-extract/vite-plugin';
|
|
6
|
+
import type { Plugin } from 'vite';
|
|
7
|
+
|
|
8
|
+
export interface ScalepadUiViteOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Options forwarded to `@vanilla-extract/vite-plugin`. Leave undefined to
|
|
11
|
+
* use the plugin's defaults, which work for `@scalepad/ui` out of the box.
|
|
12
|
+
*/
|
|
13
|
+
vanillaExtract?: VanillaExtractPluginOptions;
|
|
14
|
+
/**
|
|
15
|
+
* Extra packages to add to `optimizeDeps.include`. Use this when your app
|
|
16
|
+
* pulls in additional CommonJS deps through `@scalepad/ui` that Vite's
|
|
17
|
+
* scanner misses because the package is excluded from pre-bundling.
|
|
18
|
+
*/
|
|
19
|
+
optimizeDepsInclude?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Override the default `optimizeDeps.include` list entirely. Most consumers
|
|
22
|
+
* should use `optimizeDepsInclude` to *extend* the defaults rather than
|
|
23
|
+
* replace them.
|
|
24
|
+
*/
|
|
25
|
+
optimizeDepsIncludeOverride?: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The default `optimizeDeps.include` list shipped with the preset. Exported
|
|
30
|
+
* so consumers can compose with it if they need full control over Vite's
|
|
31
|
+
* pre-bundling.
|
|
32
|
+
*/
|
|
33
|
+
export const SCALEPAD_UI_OPTIMIZE_DEPS_INCLUDE: readonly string[];
|
|
34
|
+
|
|
35
|
+
export function scalepadUi(options?: ScalepadUiViteOptions): Plugin[];
|
|
36
|
+
|
|
37
|
+
export default scalepadUi;
|
package/src/vite.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite preset for `@scalepad/ui`.
|
|
3
|
+
*
|
|
4
|
+
* @scalepad/ui ships as TypeScript + vanilla-extract source. Three things must
|
|
5
|
+
* be wired into a consumer's Vite config for it to load cleanly:
|
|
6
|
+
*
|
|
7
|
+
* 1. The vanilla-extract Vite plugin, so every `.css.ts` file the package
|
|
8
|
+
* ships under `node_modules/@scalepad/ui/src/**` is compiled at build
|
|
9
|
+
* time.
|
|
10
|
+
* 2. A pair of `optimizeDeps` overrides:
|
|
11
|
+
* - `exclude: ['@scalepad/ui']` so Vite's esbuild pre-bundling step
|
|
12
|
+
* doesn't try to ingest `.css.ts` files (esbuild can't handle them
|
|
13
|
+
* on its own and the failure mode is opaque).
|
|
14
|
+
* - `include: [...]` for the CommonJS transitive deps Vite's scanner
|
|
15
|
+
* stops walking through once the package is excluded from
|
|
16
|
+
* pre-bundling.
|
|
17
|
+
* 3. A narrowly-scoped Rollup `onLog` filter that suppresses the
|
|
18
|
+
* `MISSING_EXPORT` / `IMPORT_IS_UNDEFINED` warning emitted from
|
|
19
|
+
* `@mantine/schedule`'s `rrule` import (Rollup uses the former in
|
|
20
|
+
* current versions and the latter in older ones for the same root
|
|
21
|
+
* cause). The warning is a static-analysis false positive: the Mantine
|
|
22
|
+
* source does
|
|
23
|
+
*
|
|
24
|
+
* const RRule = "default" in rruleAll ? rruleAll.default.RRule : rruleAll.RRule;
|
|
25
|
+
*
|
|
26
|
+
* which is explicitly defensive about both module shapes. Under rrule's
|
|
27
|
+
* ESM build the `default` branch is dead code (Rollup tree-shakes it
|
|
28
|
+
* away); only `rruleAll.RRule` runs and it resolves correctly. Rollup
|
|
29
|
+
* still flags the dead branch at scan time, producing a noisy warning on
|
|
30
|
+
* every build. The filter is scoped to (importer is `@mantine/schedule`
|
|
31
|
+
* + message mentions `rrule`) so unrelated missing-export / undefined-
|
|
32
|
+
* import warnings still surface.
|
|
33
|
+
*
|
|
34
|
+
* This preset wraps all three into a single plugin so consumers can do:
|
|
35
|
+
*
|
|
36
|
+
* import { scalepadUi } from '@scalepad/ui/vite';
|
|
37
|
+
*
|
|
38
|
+
* export default defineConfig({
|
|
39
|
+
* plugins: [react(), scalepadUi()],
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* The `@vanilla-extract/vite-plugin` ships as a runtime dependency of
|
|
43
|
+
* `@scalepad/ui`, so consumers don't need to install it themselves.
|
|
44
|
+
*
|
|
45
|
+
* NOTE: this file is intentionally authored as plain `.js` with a sibling
|
|
46
|
+
* `.d.ts`, NOT as `.ts`. Vite consumers import it from their `vite.config.ts`,
|
|
47
|
+
* which Vite transpiles via esbuild and then evaluates through Node's runtime.
|
|
48
|
+
* Node 22+ refuses to strip TypeScript types from files inside `node_modules`
|
|
49
|
+
* (`ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING`), so the runtime artifact
|
|
50
|
+
* MUST be `.js`. Every other file in this package goes through the consumer's
|
|
51
|
+
* bundler instead of Node directly and can stay as `.ts`.
|
|
52
|
+
*/
|
|
53
|
+
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The default `optimizeDeps.include` list. These are the CommonJS / mixed
|
|
57
|
+
* deps that `@scalepad/ui` reaches through transitively, which Vite's
|
|
58
|
+
* scanner can't discover on its own once `@scalepad/ui` is excluded from
|
|
59
|
+
* pre-bundling.
|
|
60
|
+
*
|
|
61
|
+
* Exported so consumers can compose with it if they need full control.
|
|
62
|
+
*/
|
|
63
|
+
export const SCALEPAD_UI_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
64
|
+
'@mantine/dates',
|
|
65
|
+
'@mantine/schedule',
|
|
66
|
+
'@tiptap/react',
|
|
67
|
+
'dayjs',
|
|
68
|
+
'fast-deep-equal',
|
|
69
|
+
'prop-types',
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* True iff `log` is the known-noisy rrule / @mantine/schedule warning
|
|
74
|
+
* described in the file header. Rollup emits this under more than one code
|
|
75
|
+
* depending on which static-analysis pass catches it first — `MISSING_EXPORT`
|
|
76
|
+
* ("default" is not exported by …) and `IMPORT_IS_UNDEFINED` (Import
|
|
77
|
+
* `default` will always be undefined …) are both seen in the wild for the
|
|
78
|
+
* exact same import. We match by (importer is @mantine/schedule + message
|
|
79
|
+
* mentions rrule), which is tight enough that unrelated missing-export
|
|
80
|
+
* warnings still surface but loose enough to survive Rollup version drift.
|
|
81
|
+
*/
|
|
82
|
+
function isRruleScheduleDeadBranchWarning(log) {
|
|
83
|
+
if (!log) return false;
|
|
84
|
+
const importer = log.id ?? log.loc?.file ?? '';
|
|
85
|
+
const message = log.message ?? '';
|
|
86
|
+
return importer.includes('@mantine/schedule') && /\brrule\b/.test(message);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function scalepadUi(options = {}) {
|
|
90
|
+
const includeFromOptions = options.optimizeDepsIncludeOverride ?? [
|
|
91
|
+
...SCALEPAD_UI_OPTIMIZE_DEPS_INCLUDE,
|
|
92
|
+
...(options.optimizeDepsInclude ?? []),
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const presetPlugin = {
|
|
96
|
+
name: '@scalepad/ui/vite-preset',
|
|
97
|
+
config: () => ({
|
|
98
|
+
optimizeDeps: {
|
|
99
|
+
exclude: ['@scalepad/ui'],
|
|
100
|
+
include: includeFromOptions,
|
|
101
|
+
},
|
|
102
|
+
}),
|
|
103
|
+
// Rollup plugin hook (Rollup 4+, used by Vite 5+). Returning `false`
|
|
104
|
+
// suppresses the log without clobbering the consumer's own `onwarn` or
|
|
105
|
+
// any other plugin's `onLog` — Rollup chains every plugin's handler.
|
|
106
|
+
onLog(level, log) {
|
|
107
|
+
if (level === 'warn' && isRruleScheduleDeadBranchWarning(log)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const veResult = vanillaExtractPlugin(options.vanillaExtract);
|
|
115
|
+
const vePlugins = Array.isArray(veResult) ? veResult : [veResult];
|
|
116
|
+
|
|
117
|
+
return [...vePlugins, presetPlugin];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export default scalepadUi;
|