@sybilion/uilib 1.6.0 → 1.7.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.
Files changed (67) hide show
  1. package/README.md +2 -1
  2. package/assets/base.css +3 -4
  3. package/assets/globals.css +1 -1
  4. package/dist/esm/src/components/ui/AnalysesSelector/AnalysesSelector.styl.js +1 -1
  5. package/dist/esm/src/components/ui/AppHeader/AppHeader.styl.js +1 -1
  6. package/dist/esm/src/components/ui/Breadcrumb/Breadcrumb.styl.js +1 -1
  7. package/dist/esm/src/components/ui/Button/Button.js +2 -2
  8. package/dist/esm/src/components/ui/Button/Button.styl.js +2 -2
  9. package/dist/esm/src/components/ui/Checkbox/Checkbox.styl.js +1 -1
  10. package/dist/esm/src/components/ui/Chip/Chip.styl.js +1 -1
  11. package/dist/esm/src/components/ui/DatePicker/DatePicker.styl.js +1 -1
  12. package/dist/esm/src/components/ui/Dialog/Dialog.styl.js +1 -1
  13. package/dist/esm/src/components/ui/DropdownMenu/DropdownMenu.styl.js +1 -1
  14. package/dist/esm/src/components/ui/FileChip/FileChip.styl.js +1 -1
  15. package/dist/esm/src/components/ui/Input/Input.js +3 -3
  16. package/dist/esm/src/components/ui/Input/Input.styl.js +2 -2
  17. package/dist/esm/src/components/ui/LegacyPlatformLink/LegacyPlatformLink.styl.js +1 -1
  18. package/dist/esm/src/components/ui/Notifications/Notifications.styl.js +1 -1
  19. package/dist/esm/src/components/ui/RadioGroup/RadioGroup.styl.js +1 -1
  20. package/dist/esm/src/components/ui/Select/Select.js +5 -5
  21. package/dist/esm/src/components/ui/Select/Select.styl.js +2 -2
  22. package/dist/esm/src/components/ui/Sheet/Sheet.styl.js +1 -1
  23. package/dist/esm/src/components/ui/Sidebar/SidebarGroupAction/SidebarGroupAction.styl.js +1 -1
  24. package/dist/esm/src/components/ui/Sidebar/SidebarMenuAction/SidebarMenuAction.styl.js +1 -1
  25. package/dist/esm/src/components/ui/Sidebar/SidebarMenuButton/SidebarMenuButton.styl.js +1 -1
  26. package/dist/esm/src/components/ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.styl.js +1 -1
  27. package/dist/esm/src/components/ui/Sidebar/SidebarRail/SidebarRail.styl.js +1 -1
  28. package/dist/esm/src/components/ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.styl.js +1 -1
  29. package/dist/esm/src/components/ui/Slider/Slider.styl.js +1 -1
  30. package/dist/esm/src/components/ui/SupplyChainMap/SupplyChainMap.styl.js +1 -1
  31. package/dist/esm/src/components/ui/SupplyChainMap/use-map-base-renderer.js +2 -2
  32. package/dist/esm/src/components/ui/Switch/Switch.styl.js +1 -1
  33. package/dist/esm/src/components/ui/Tabs/Tabs.styl.js +1 -1
  34. package/dist/esm/src/components/ui/Toggle/Toggle.styl.js +1 -1
  35. package/dist/esm/src/components/ui/ToggleGroup/ToggleGroup.styl.js +1 -1
  36. package/dist/esm/src/components/ui/WorkspaceAppSwitcher/WorkspaceAppSwitcher.styl.js +1 -1
  37. package/dist/esm/src/components/widgets/DriverMap/DriverIcon/DriverIcon.styl.js +1 -1
  38. package/dist/esm/types/src/components/ui/Button/Button.d.ts +1 -1
  39. package/dist/esm/types/src/components/ui/Button/Button.types.d.ts +2 -0
  40. package/dist/esm/types/src/components/ui/Input/Input.d.ts +2 -0
  41. package/dist/esm/types/src/components/ui/Input/Input.types.d.ts +4 -0
  42. package/dist/esm/types/src/components/ui/Select/Select.d.ts +1 -1
  43. package/dist/esm/types/src/components/ui/Select/Select.types.d.ts +2 -0
  44. package/dist/esm/types/src/docs/config/vite.config.d.ts +2 -0
  45. package/dist/esm/types/tests/buttonStyles.test.d.ts +1 -0
  46. package/dist/esm/types/tests/focusOutline.test.d.ts +1 -0
  47. package/package.json +28 -37
  48. package/src/components/ui/Button/Button.styl +122 -104
  49. package/src/components/ui/Button/Button.styl.d.ts +1 -0
  50. package/src/components/ui/Button/Button.tsx +2 -0
  51. package/src/components/ui/Button/Button.types.ts +2 -0
  52. package/src/components/ui/Input/Input.styl +4 -0
  53. package/src/components/ui/Input/Input.styl.d.ts +1 -0
  54. package/src/components/ui/Input/Input.tsx +34 -20
  55. package/src/components/ui/Input/Input.types.ts +4 -0
  56. package/src/components/ui/Select/Select.styl +4 -0
  57. package/src/components/ui/Select/Select.styl.d.ts +1 -0
  58. package/src/components/ui/Select/Select.tsx +5 -0
  59. package/src/components/ui/Select/Select.types.ts +2 -0
  60. package/src/components/ui/SupplyChainMap/use-map-base-renderer.ts +2 -1
  61. package/src/docs/config/vite.config.ts +253 -0
  62. package/src/docs/pages/ButtonPage.tsx +33 -1
  63. package/src/docs/pages/InputPage.tsx +31 -1
  64. package/src/docs/pages/SelectPage.tsx +34 -1
  65. package/src/lib/theme.styl +3 -1
  66. package/assets/index.html +0 -18
  67. package/src/docs/config/webpack.config.js +0 -275
@@ -0,0 +1,253 @@
1
+ import react from '@vitejs/plugin-react-swc';
2
+ import { createHash } from 'crypto';
3
+ import { copyFileSync, existsSync, readFileSync, writeFileSync } from 'fs';
4
+ import { basename, resolve as pathResolve, relative } from 'path';
5
+ import postcssPresetEnv from 'postcss-preset-env';
6
+ import { type Plugin, defineConfig, loadEnv } from 'vite';
7
+ import svgr from 'vite-plugin-svgr';
8
+
9
+ import pkg from '../../../package.json';
10
+ import paths from './paths';
11
+
12
+ /** Favicon rasterization has no CSS context; currentColor in logo.svg renders black. */
13
+ const faviconLogoSvgPath = pathResolve(paths.assets, 'logo-favicon.svg');
14
+ const themeStyl = pathResolve(paths.src, 'theme.styl');
15
+
16
+ /** GitHub Pages project sites live at /<repo>/; set PUBLIC_PATH=/repo-name/ for production deploy. */
17
+ function normalizePublicPath(raw: string | undefined) {
18
+ const v = (raw && String(raw).trim()) || '/';
19
+ if (v === '/') {
20
+ return '/';
21
+ }
22
+ const withLeading = v.startsWith('/') ? v : `/${v}`;
23
+ return withLeading.endsWith('/') ? withLeading : `${withLeading}/`;
24
+ }
25
+
26
+ function routerBasenameFromPublicPath(publicPath: string) {
27
+ if (publicPath === '/') {
28
+ return '';
29
+ }
30
+ return publicPath.replace(/\/$/, '');
31
+ }
32
+
33
+ const STYL_MODULE_QUERY = '?.module.styl';
34
+
35
+ /**
36
+ * Every `.styl` file is a CSS module (no `.module.styl` suffix), but Vite only
37
+ * treats `*.module.*` ids as modules. Tag resolved `.styl` imports with a query
38
+ * ending in `.module.styl` so Vite's CSS-modules check matches while the id
39
+ * still points at the real file (HMR and file reads use the path before `?`).
40
+ */
41
+ function stylusModules(): Plugin {
42
+ return {
43
+ name: 'uilib:stylus-modules',
44
+ enforce: 'pre',
45
+ async resolveId(source, importer, options) {
46
+ if (!importer || !/\.styl$/.test(source)) return null;
47
+ const resolved = await this.resolve(source, importer, {
48
+ ...options,
49
+ skipSelf: true,
50
+ });
51
+ if (!resolved || resolved.external || resolved.id.includes('?')) {
52
+ return resolved;
53
+ }
54
+ return { ...resolved, id: `${resolved.id}${STYL_MODULE_QUERY}` };
55
+ },
56
+ };
57
+ }
58
+
59
+ /** `import text from './AGENT.md'` → file contents as a string (webpack `asset/source`). */
60
+ function rawMarkdown(): Plugin {
61
+ return {
62
+ name: 'uilib:raw-md',
63
+ enforce: 'pre',
64
+ load(id) {
65
+ if (!id.endsWith('.md')) return null;
66
+ return `export default ${JSON.stringify(readFileSync(id, 'utf8'))};`;
67
+ },
68
+ };
69
+ }
70
+
71
+ /** `[name]__[local]___[hash:base64:5]`, as css-loader produced it under webpack. */
72
+ function scopedName(local: string, filename: string) {
73
+ const file = filename.split('?')[0];
74
+ const name = basename(file).replace(/\.[^.]+$/, '');
75
+ const hash = createHash('md5')
76
+ .update(`${relative(paths.src, file)}\0${local}`)
77
+ .digest('base64url')
78
+ .slice(0, 5);
79
+ return `${name}__${local}___${hash}`;
80
+ }
81
+
82
+ /**
83
+ * Keep `Foo.styl.d.ts` class typings in sync (what css-modules-typescript-loader
84
+ * did under webpack). Rewrites only when the set of class names changed, so
85
+ * files formatted by prettier are left alone.
86
+ */
87
+ function writeStylTypings(cssFileName: string, json: Record<string, string>) {
88
+ const dts = `${cssFileName.split('?')[0]}.d.ts`;
89
+ const keys = Object.keys(json).sort();
90
+ const existing = existsSync(dts)
91
+ ? [...readFileSync(dts, 'utf8').matchAll(/^\s+'?([^':\s]+)'?: string;$/gm)]
92
+ .map(m => m[1])
93
+ .sort()
94
+ : null;
95
+ if (existing && existing.join('\n') === keys.join('\n')) return;
96
+ writeFileSync(
97
+ dts,
98
+ [
99
+ '// This file is automatically generated.',
100
+ '// Please do not change this file!',
101
+ 'interface CssExports {',
102
+ ...keys.map(k => ` '${k}': string;`),
103
+ '}',
104
+ 'export const cssExports: CssExports;',
105
+ 'export default cssExports;',
106
+ '',
107
+ ].join('\n'),
108
+ );
109
+ }
110
+
111
+ /** Build only: rasterize favicons + web manifest and inject their tags. */
112
+ function favicons(base: string): Plugin {
113
+ const prefix = 'favicons/';
114
+ let response: {
115
+ images: { name: string; contents: Buffer }[];
116
+ files: { name: string; contents: string }[];
117
+ html: string[];
118
+ } | null = null;
119
+
120
+ return {
121
+ name: 'uilib:favicons',
122
+ apply: 'build',
123
+ async buildStart() {
124
+ if (!existsSync(faviconLogoSvgPath)) return;
125
+ const { favicons: generate } = await import('favicons');
126
+ response = await generate(faviconLogoSvgPath, {
127
+ path: `${base}${prefix}`,
128
+ appName: 'Sybilion Design System',
129
+ developerName: 'Sybilion',
130
+ developerURL: null,
131
+ background: '#fff',
132
+ theme_color: '#1a1a1a',
133
+ display: 'standalone',
134
+ icons: {
135
+ android: true,
136
+ appleIcon: true,
137
+ appleStartup: false,
138
+ favicons: true,
139
+ windows: true,
140
+ yandex: false,
141
+ },
142
+ });
143
+ },
144
+ generateBundle() {
145
+ if (!response) return;
146
+ for (const { name, contents } of [
147
+ ...response.images,
148
+ ...response.files,
149
+ ]) {
150
+ this.emitFile({
151
+ type: 'asset',
152
+ fileName: `${prefix}${name}`,
153
+ source: contents,
154
+ });
155
+ }
156
+ },
157
+ transformIndexHtml(html) {
158
+ if (!response) return html;
159
+ return html.replace('</head>', `${response.html.join('')}</head>`);
160
+ },
161
+ };
162
+ }
163
+
164
+ /** GitHub Pages serves 404.html for missing paths; same shell as index.html so SPA routes work. */
165
+ function spaFallback404(): Plugin {
166
+ let outDir = '';
167
+ return {
168
+ name: 'uilib:spa-404',
169
+ apply: 'build',
170
+ configResolved(config) {
171
+ outDir = config.build.outDir;
172
+ },
173
+ closeBundle() {
174
+ copyFileSync(
175
+ pathResolve(outDir, 'index.html'),
176
+ pathResolve(outDir, '404.html'),
177
+ );
178
+ },
179
+ };
180
+ }
181
+
182
+ export default defineConfig(({ mode }) => {
183
+ const isDev = mode === 'development';
184
+ const env = loadEnv(mode, process.cwd(), '');
185
+ const publicPath = normalizePublicPath(env.PUBLIC_PATH);
186
+
187
+ const alias: Record<string, string> = {
188
+ '#uilib': paths.src,
189
+ uilib: paths.src,
190
+ 'docs/components': `${paths.docs}/components`,
191
+ };
192
+ if (existsSync(themeStyl)) {
193
+ alias.theme = themeStyl;
194
+ }
195
+
196
+ return {
197
+ base: publicPath,
198
+ publicDir: paths.assets,
199
+
200
+ resolve: { alias },
201
+
202
+ define: {
203
+ isDEV: JSON.stringify(isDev),
204
+ VERSION: JSON.stringify(pkg.version),
205
+ DOCS_ROUTER_BASENAME: JSON.stringify(
206
+ routerBasenameFromPublicPath(publicPath),
207
+ ),
208
+ },
209
+
210
+ css: {
211
+ modules: {
212
+ generateScopedName: scopedName,
213
+ getJSON: isDev ? writeStylTypings : undefined,
214
+ },
215
+ preprocessorOptions: {
216
+ // `@import 'lib/theme.styl'` resolves against src/ (webpack resolve.modules).
217
+ // Vite looks options up by file extension, so `.styl` reads `styl`.
218
+ styl: { paths: [paths.src, paths.docs] },
219
+ },
220
+ postcss: {
221
+ // Autoprefixer is on by default in postcss-preset-env.
222
+ plugins: [postcssPresetEnv({ stage: 3 })],
223
+ },
224
+ },
225
+
226
+ plugins: [
227
+ stylusModules(),
228
+ rawMarkdown(),
229
+ svgr({
230
+ include: '**/*.svg',
231
+ // Rendered as <img>/background: keep the default URL import.
232
+ exclude: '**/components/ui/WorldMap/map.svg',
233
+ svgrOptions: { icon: true },
234
+ }),
235
+ react(),
236
+ favicons(publicPath),
237
+ spaFallback404(),
238
+ ],
239
+
240
+ server: {
241
+ port: Number(env.PORT) || 8181,
242
+ },
243
+
244
+ build: {
245
+ outDir: paths.build,
246
+ emptyOutDir: true,
247
+ sourcemap: false,
248
+ // Internal docs site: the main bundle and lazy pages (icons, pdfjs, xlsx)
249
+ // are large by design; keep the warning for real regressions only.
250
+ chunkSizeWarningLimit: 1500,
251
+ },
252
+ };
253
+ });
@@ -25,7 +25,7 @@ export default function ButtonPage() {
25
25
  <AppPageHeader
26
26
  breadcrumbs={[{ label: 'Button' }]}
27
27
  title="Button"
28
- subheader="Variants, sizes, icon mode, and disabled state."
28
+ subheader="Variants, sizes, icon mode, round, and disabled state."
29
29
  actions={<DocsHeaderActions />}
30
30
  />
31
31
  <DocsGuidance source={ButtonGuidance} />
@@ -119,6 +119,38 @@ export default function ButtonPage() {
119
119
  ))}
120
120
  </div>
121
121
  </section>
122
+ <section>
123
+ <h3 style={{ marginBottom: '1rem' }}>Round</h3>
124
+ <p
125
+ style={{
126
+ marginBottom: '0.75rem',
127
+ color: 'var(--muted-foreground)',
128
+ }}
129
+ >
130
+ Pass <code>round</code> for pill corners (
131
+ <code>border-radius: 100px</code>).
132
+ </p>
133
+ <div
134
+ style={{
135
+ display: 'flex',
136
+ flexWrap: 'wrap',
137
+ gap: '0.75rem',
138
+ alignItems: 'center',
139
+ }}
140
+ >
141
+ {SIZES.map(s => (
142
+ <Button key={s} type="button" variant="default" size={s} round>
143
+ Round {s}
144
+ </Button>
145
+ ))}
146
+ <Button type="button" variant="outline" round>
147
+ Outline
148
+ </Button>
149
+ <Button type="button" variant="outline" icon round aria-label="Add">
150
+ <Plus size={20} />
151
+ </Button>
152
+ </div>
153
+ </section>
122
154
  <section>
123
155
  <h3 style={{ marginBottom: '1rem' }}>Disabled</h3>
124
156
  <div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.75rem' }}>
@@ -15,7 +15,7 @@ export default function InputPage() {
15
15
  <AppPageHeader
16
16
  breadcrumbs={[{ label: 'Input' }]}
17
17
  title="Input"
18
- subheader="Variants, sizes, textarea, placeholder, and disabled state."
18
+ subheader="Variants, sizes, textarea, round, placeholder, and disabled state."
19
19
  actions={<DocsHeaderActions />}
20
20
  />
21
21
  <DocsGuidance source={InputGuidance} />
@@ -114,6 +114,36 @@ export default function InputPage() {
114
114
  </table>
115
115
  </div>
116
116
  </section>
117
+ <section>
118
+ <h3 style={{ marginBottom: '1rem' }}>Round</h3>
119
+ <p
120
+ style={{
121
+ marginBottom: '0.75rem',
122
+ color: 'var(--muted-foreground)',
123
+ }}
124
+ >
125
+ Pass <code>round</code> for pill corners (
126
+ <code>border-radius: 100px</code>).
127
+ </p>
128
+ <div
129
+ style={{
130
+ display: 'flex',
131
+ flexWrap: 'wrap',
132
+ gap: '0.75rem',
133
+ alignItems: 'center',
134
+ }}
135
+ >
136
+ {SIZES.map(s => (
137
+ <Input
138
+ key={s}
139
+ size={s}
140
+ round
141
+ placeholder={`Round ${s}`}
142
+ style={{ width: 200 }}
143
+ />
144
+ ))}
145
+ </div>
146
+ </section>
117
147
  <section>
118
148
  <h3 style={{ marginBottom: '1rem' }}>Disabled</h3>
119
149
  <div
@@ -28,6 +28,7 @@ function DemoSelect({
28
28
  placeholder,
29
29
  defaultValue,
30
30
  darker = false,
31
+ round = false,
31
32
  }: {
32
33
  variant: (typeof VARIANTS)[number];
33
34
  size: (typeof SIZES)[number];
@@ -35,6 +36,7 @@ function DemoSelect({
35
36
  placeholder?: string;
36
37
  defaultValue?: string;
37
38
  darker?: boolean;
39
+ round?: boolean;
38
40
  }) {
39
41
  return (
40
42
  <Select defaultValue={defaultValue}>
@@ -43,6 +45,7 @@ function DemoSelect({
43
45
  size={size}
44
46
  disabled={disabled}
45
47
  darker={darker}
48
+ round={round}
46
49
  style={{ width: 200 }}
47
50
  >
48
51
  <SelectValue placeholder={placeholder ?? 'Pick fruit'} />
@@ -64,7 +67,7 @@ export default function SelectPage() {
64
67
  <AppPageHeader
65
68
  breadcrumbs={[{ label: 'Select' }]}
66
69
  title="Select"
67
- subheader="Variants, sizes, placeholder, darker trigger, disabled, and searchable."
70
+ subheader="Variants, sizes, placeholder, darker trigger, round, disabled, and searchable."
68
71
  actions={<DocsHeaderActions />}
69
72
  />
70
73
  <DocsGuidance source={selectGuidance} />
@@ -191,6 +194,36 @@ export default function SelectPage() {
191
194
  ))}
192
195
  </div>
193
196
  </section>
197
+ <section>
198
+ <h3 style={{ marginBottom: '1rem' }}>Round</h3>
199
+ <p
200
+ style={{
201
+ marginBottom: '0.75rem',
202
+ color: 'var(--muted-foreground)',
203
+ }}
204
+ >
205
+ Pass <code>round</code> on <code>SelectTrigger</code> for pill
206
+ corners (<code>border-radius: 100px</code>).
207
+ </p>
208
+ <div
209
+ style={{
210
+ display: 'flex',
211
+ flexWrap: 'wrap',
212
+ gap: '0.75rem',
213
+ alignItems: 'center',
214
+ }}
215
+ >
216
+ {SIZES.map(s => (
217
+ <DemoSelect
218
+ key={s}
219
+ variant="default"
220
+ size={s}
221
+ defaultValue="apple"
222
+ round
223
+ />
224
+ ))}
225
+ </div>
226
+ </section>
194
227
  <section>
195
228
  <h3 style={{ marginBottom: '1rem' }}>Searchable</h3>
196
229
  <p
@@ -21,8 +21,10 @@ focus-outline-style()
21
21
  outline var(--focus-outline-width, 2px) solid var(--focus-outline-color, var(--ring))
22
22
  outline-offset var(--focus-outline-offset, 2px)
23
23
 
24
+ // Not excluded: [aria-disabled]. Such an element stays in the tab order (that is
25
+ // why it is not `disabled`, e.g. a busy button), so focus must still be visible.
24
26
  focus-outline-target()
25
- &:not(:disabled):not([aria-disabled='true']):not([data-disabled])
27
+ &:not(:disabled):not([data-disabled])
26
28
  focus-outline-style()
27
29
 
28
30
  focus-outline()
package/assets/index.html DELETED
@@ -1,18 +0,0 @@
1
- <!doctype html>
2
- <html lang="<%= htmlWebpackPlugin.options.lang %>">
3
- <head>
4
- <base href="<%= htmlWebpackPlugin.options.baseUrl %>" />
5
- <title>UILIB</title>
6
- <meta charset="UTF-8" />
7
- <meta
8
- name="viewport"
9
- content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
10
- />
11
- <meta http-equiv="X-UA-Compatible" content="ie=edge" />
12
- <link rel="stylesheet" href="assets/globals.css" />
13
- </head>
14
- <body>
15
- <div id="app-root"></div>
16
- <div id="app-modal"></div>
17
- </body>
18
- </html>