@sybilion/uilib 1.6.0 → 1.6.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 (44) hide show
  1. package/README.md +1 -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.styl.js +1 -1
  8. package/dist/esm/src/components/ui/Checkbox/Checkbox.styl.js +1 -1
  9. package/dist/esm/src/components/ui/Chip/Chip.styl.js +1 -1
  10. package/dist/esm/src/components/ui/DatePicker/DatePicker.styl.js +1 -1
  11. package/dist/esm/src/components/ui/Dialog/Dialog.styl.js +1 -1
  12. package/dist/esm/src/components/ui/DropdownMenu/DropdownMenu.styl.js +1 -1
  13. package/dist/esm/src/components/ui/FileChip/FileChip.styl.js +1 -1
  14. package/dist/esm/src/components/ui/Input/Input.styl.js +1 -1
  15. package/dist/esm/src/components/ui/LegacyPlatformLink/LegacyPlatformLink.styl.js +1 -1
  16. package/dist/esm/src/components/ui/Notifications/Notifications.styl.js +1 -1
  17. package/dist/esm/src/components/ui/RadioGroup/RadioGroup.styl.js +1 -1
  18. package/dist/esm/src/components/ui/Select/Select.styl.js +1 -1
  19. package/dist/esm/src/components/ui/Sheet/Sheet.styl.js +1 -1
  20. package/dist/esm/src/components/ui/Sidebar/SidebarGroupAction/SidebarGroupAction.styl.js +1 -1
  21. package/dist/esm/src/components/ui/Sidebar/SidebarMenuAction/SidebarMenuAction.styl.js +1 -1
  22. package/dist/esm/src/components/ui/Sidebar/SidebarMenuButton/SidebarMenuButton.styl.js +1 -1
  23. package/dist/esm/src/components/ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.styl.js +1 -1
  24. package/dist/esm/src/components/ui/Sidebar/SidebarRail/SidebarRail.styl.js +1 -1
  25. package/dist/esm/src/components/ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.styl.js +1 -1
  26. package/dist/esm/src/components/ui/Slider/Slider.styl.js +1 -1
  27. package/dist/esm/src/components/ui/SupplyChainMap/SupplyChainMap.styl.js +1 -1
  28. package/dist/esm/src/components/ui/SupplyChainMap/use-map-base-renderer.js +2 -2
  29. package/dist/esm/src/components/ui/Switch/Switch.styl.js +1 -1
  30. package/dist/esm/src/components/ui/Tabs/Tabs.styl.js +1 -1
  31. package/dist/esm/src/components/ui/Toggle/Toggle.styl.js +1 -1
  32. package/dist/esm/src/components/ui/ToggleGroup/ToggleGroup.styl.js +1 -1
  33. package/dist/esm/src/components/ui/WorkspaceAppSwitcher/WorkspaceAppSwitcher.styl.js +1 -1
  34. package/dist/esm/src/components/widgets/DriverMap/DriverIcon/DriverIcon.styl.js +1 -1
  35. package/dist/esm/types/src/docs/config/vite.config.d.ts +2 -0
  36. package/dist/esm/types/tests/buttonStyles.test.d.ts +1 -0
  37. package/dist/esm/types/tests/focusOutline.test.d.ts +1 -0
  38. package/package.json +6 -26
  39. package/src/components/ui/Button/Button.styl +118 -104
  40. package/src/components/ui/SupplyChainMap/use-map-base-renderer.ts +2 -1
  41. package/src/docs/config/vite.config.ts +253 -0
  42. package/src/lib/theme.styl +3 -1
  43. package/assets/index.html +0 -18
  44. 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
+ });
@@ -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>
@@ -1,275 +0,0 @@
1
- import ReactRefreshPlugin from '@pmmmwh/react-refresh-webpack-plugin';
2
- import { CleanWebpackPlugin } from 'clean-webpack-plugin';
3
- import CopyWebpackPlugin from 'copy-webpack-plugin';
4
- import { config as loadEnv } from 'dotenv';
5
- import { existsSync } from 'fs';
6
- import HtmlWebpackPlugin from 'html-webpack-plugin';
7
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
8
- import { createRequire } from 'module';
9
- import { resolve as pathResolve } from 'path';
10
- import webpack from 'webpack';
11
-
12
- import paths from './paths.ts';
13
-
14
- const require = createRequire(import.meta.url);
15
-
16
- loadEnv({ path: pathResolve(process.cwd(), '.env') });
17
-
18
- const FaviconWebpackPlugin = require('favicons-webpack-plugin');
19
-
20
- const pkg = require('../../../package.json');
21
-
22
- const themeStyl = pathResolve(paths.src, 'theme.styl');
23
- const logoSvgPath = pathResolve(paths.assets, 'logo.svg');
24
- /** Favicon rasterization has no CSS context; currentColor in logo.svg renders black. */
25
- const faviconLogoSvgPath = pathResolve(paths.assets, 'logo-favicon.svg');
26
-
27
- /** GitHub Pages project sites live at /<repo>/; set PUBLIC_PATH=/repo-name/ for production deploy. */
28
- function normalizePublicPath(raw) {
29
- const v = (raw && String(raw).trim()) || '/';
30
- if (v === '/') {
31
- return '/';
32
- }
33
- const withLeading = v.startsWith('/') ? v : `/${v}`;
34
- return withLeading.endsWith('/') ? withLeading : `${withLeading}/`;
35
- }
36
-
37
- function routerBasenameFromPublicPath(publicPath) {
38
- if (publicPath === '/') {
39
- return '';
40
- }
41
- return publicPath.replace(/\/$/, '');
42
- }
43
-
44
- export default (env, argv) => {
45
- const isDev = argv.mode === 'development';
46
- const publicPath = normalizePublicPath(process.env.PUBLIC_PATH);
47
- const docsRouterBasename = routerBasenameFromPublicPath(publicPath);
48
- const alias = {
49
- '#uilib': paths.src,
50
- uilib: paths.src,
51
- 'docs/components': `${paths.docs}/components`,
52
- };
53
- if (existsSync(themeStyl)) {
54
- alias.theme = themeStyl;
55
- }
56
-
57
- const docsHtmlMinify = isDev
58
- ? false
59
- : {
60
- removeComments: true,
61
- collapseWhitespace: true,
62
- removeRedundantAttributes: true,
63
- useShortDoctype: true,
64
- removeEmptyAttributes: true,
65
- removeStyleLinkTypeAttributes: true,
66
- keepClosingSlash: true,
67
- minifyJS: true,
68
- minifyCSS: true,
69
- minifyURLs: true,
70
- };
71
-
72
- const docsHtmlPluginBase = {
73
- lang: 'en',
74
- baseUrl: publicPath,
75
- template: `${paths.assets}/index.html`,
76
- minify: docsHtmlMinify,
77
- };
78
-
79
- const config = {
80
- entry: [paths.docs],
81
- output: {
82
- path: paths.build,
83
- publicPath,
84
- },
85
-
86
- resolve: {
87
- modules: [paths.src, paths.docs, 'node_modules'],
88
- extensions: ['.js', '.ts', '.tsx', '.styl', '.md'],
89
- alias,
90
- },
91
-
92
- optimization: {
93
- moduleIds: 'named',
94
- minimize: false,
95
- },
96
-
97
- module: {
98
- rules: [
99
- {
100
- test: /\.tsx?$/,
101
- loader: 'babel-loader',
102
- include: [paths.src, paths.docs],
103
- options: {
104
- plugins: [isDev && require.resolve('react-refresh/babel')].filter(
105
- Boolean,
106
- ),
107
- },
108
- },
109
- {
110
- test: /\.md$/,
111
- include: [paths.src],
112
- type: 'asset/source',
113
- },
114
- {
115
- test: /\.css$/,
116
- use: ['style-loader', 'css-loader'],
117
- },
118
- {
119
- test: /\.styl$/,
120
- use: [
121
- 'style-loader',
122
- { loader: 'css-modules-typescript-loader' },
123
- {
124
- loader: 'css-loader',
125
- options: {
126
- modules: {
127
- localIdentName: '[name]__[local]___[hash:base64:5]',
128
- },
129
- },
130
- },
131
- {
132
- loader: 'postcss-loader',
133
- options: {
134
- postcssOptions: {
135
- ident: 'postcss',
136
- plugins: [
137
- ['postcss-preset-env', { stage: 3, autoprefixer: true }],
138
- ],
139
- },
140
- },
141
- },
142
- {
143
- loader: 'stylus-loader',
144
- },
145
- ],
146
- },
147
- {
148
- test: /\.svg$/i,
149
- oneOf: [
150
- {
151
- resourceQuery: /url/i,
152
- type: 'asset/resource',
153
- },
154
- {
155
- include: /components[/\\]ui[/\\]WorldMap[/\\]map\.svg$/,
156
- type: 'asset/resource',
157
- },
158
- {
159
- issuer: /\.[jt]sx?$/,
160
- use: [
161
- {
162
- loader: '@svgr/webpack',
163
- options: {
164
- icon: true,
165
- ext: 'tsx',
166
- typescript: true,
167
- exportType: 'default',
168
- },
169
- },
170
- ],
171
- },
172
- {
173
- type: 'asset/resource',
174
- },
175
- ],
176
- },
177
- {
178
- test: /\.(woff|woff2|eot|ttf)$/,
179
- use: {
180
- loader: 'file-loader',
181
- options: {
182
- name: 'static/[name].[ext]',
183
- outputPath: 'images/',
184
- },
185
- },
186
- },
187
- {
188
- test: /\.(png|jpe?g|gif|webp)$/,
189
- type: 'asset/resource',
190
- },
191
- ],
192
- },
193
-
194
- plugins: [
195
- isDev && new ReactRefreshPlugin(),
196
- new CleanWebpackPlugin(),
197
- new webpack.ProvidePlugin({
198
- React: 'react',
199
- }),
200
- new webpack.DefinePlugin({
201
- isDEV: JSON.stringify(isDev),
202
- VERSION: JSON.stringify(pkg.version),
203
- DOCS_ROUTER_BASENAME: JSON.stringify(docsRouterBasename),
204
- }),
205
- new CopyWebpackPlugin({
206
- patterns: [
207
- {
208
- from: `${paths.assets}/*.css`,
209
- to: paths.build,
210
- },
211
- {
212
- from: `${paths.assets}/fonts`,
213
- to: `${paths.build}/assets/fonts`,
214
- noErrorOnMissing: true,
215
- },
216
- {
217
- from: logoSvgPath,
218
- to: paths.build,
219
- noErrorOnMissing: true,
220
- },
221
- {
222
- from: logoSvgPath,
223
- to: `${paths.assets}/logo.svg`,
224
- noErrorOnMissing: true,
225
- },
226
- ],
227
- }),
228
-
229
- new HtmlWebpackPlugin({
230
- ...docsHtmlPluginBase,
231
- filename: 'index.html',
232
- }),
233
- /** GitHub Pages serves this for missing paths; same shell as index.html so SPA routes work. */
234
- new HtmlWebpackPlugin({
235
- ...docsHtmlPluginBase,
236
- filename: '404.html',
237
- }),
238
- existsSync(faviconLogoSvgPath) &&
239
- new FaviconWebpackPlugin({
240
- logo: faviconLogoSvgPath,
241
- mode: 'webapp',
242
- devMode: 'webapp',
243
- favicons: {
244
- appName: 'Sybilion Design System',
245
- developerName: 'Sybilion',
246
- developerURL: null,
247
- background: '#fff',
248
- theme_color: '#1a1a1a',
249
- display: 'standalone',
250
- icons: { coast: false, yandex: false },
251
- },
252
- }),
253
- new MiniCssExtractPlugin({
254
- filename: isDev ? '[name].css' : '[name].[hash].css',
255
- chunkFilename: isDev ? '[id].css' : '[id].[hash].css',
256
- }),
257
- ].filter(Boolean),
258
- };
259
-
260
- if (isDev) {
261
- Object.assign(config, {
262
- devtool: 'source-map',
263
- devServer: {
264
- hot: true,
265
- port: process.env.PORT || 8181,
266
- historyApiFallback: true,
267
- ...(publicPath !== '/' && {
268
- devMiddleware: { publicPath },
269
- }),
270
- },
271
- });
272
- }
273
-
274
- return config;
275
- };