@cscfi/csc-ui 4.0.0-alpha.2 → 4.0.0-alpha.20
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/dist/csc-ui.js +10192 -7248
- package/dist/custom-elements.json +2278 -257
- package/dist/docs/c-alert/usage.md +24 -0
- package/dist/docs/c-autocomplete/usage.md +152 -0
- package/dist/docs/c-button-group/usage.md +14 -1
- package/dist/docs/c-checkbox/usage.md +53 -0
- package/dist/docs/c-main/usage.md +21 -1
- package/dist/docs/c-menu/usage.md +15 -0
- package/dist/docs/c-menu-item/usage.md +6 -0
- package/dist/docs/c-option-value/usage.md +1 -0
- package/dist/docs/c-popover/usage.md +33 -0
- package/dist/docs/c-progress-bar/usage.md +23 -0
- package/dist/docs/c-progress-circle/usage.md +25 -0
- package/dist/docs/c-radio/usage.md +45 -0
- package/dist/docs/c-radio-group/usage.md +67 -0
- package/dist/docs/c-select/usage.md +127 -0
- package/dist/docs/c-side-navigation/usage.md +21 -0
- package/dist/docs/c-spinner/usage.md +21 -0
- package/dist/docs/c-switch/usage.md +36 -0
- package/dist/docs/c-tab-buttons/usage.md +7 -0
- package/dist/docs/c-table/usage.md +14 -0
- package/dist/docs/c-toolbar/usage.md +17 -0
- package/dist/docs/c-tooltip/usage.md +30 -0
- package/dist/docs/c-tree-select/usage.md +156 -0
- package/dist/styles/css/tailwind-theme.css +32 -0
- package/dist/styles/css/tokens.css +707 -197
- package/dist/vscode.css-custom-data.json +286 -19
- package/dist/vscode.html-custom-data.json +334 -51
- package/dist/web-types.json +1200 -190
- package/dist-types/components/c-alert/CAlert.vue.d.ts +18 -4
- package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +118 -18
- package/dist-types/components/c-button/CButton.vue.d.ts +1 -1
- package/dist-types/components/c-button-group/CButtonGroup.vue.d.ts +1 -1
- package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +3 -3
- package/dist-types/components/c-data-table/CDataTable.vue.d.ts +6 -2
- package/dist-types/components/c-dropdown/CDropdown.vue.d.ts +48 -5
- package/dist-types/components/c-icon/CIcon.vue.d.ts +1 -1
- package/dist-types/components/c-icon-button/CIconButton.vue.d.ts +1 -1
- package/dist-types/components/c-input/CInput.vue.d.ts +6 -2
- package/dist-types/components/c-login-button/CLoginButton.vue.d.ts +4 -2
- package/dist-types/components/c-main/CMain.vue.d.ts +9 -2
- package/dist-types/components/c-menu/CMenu.vue.d.ts +14 -4
- package/dist-types/components/c-menu-item/CMenuItem.vue.d.ts +30 -3
- package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +1 -1
- package/dist-types/components/c-pagination/CPagination.vue.d.ts +1 -1
- package/dist-types/components/c-popover/CPopover.vue.d.ts +43 -0
- package/dist-types/components/c-progress-circle/CProgressCircle.vue.d.ts +32 -0
- package/dist-types/components/c-radio/CRadio.vue.d.ts +7 -11
- package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +9 -47
- package/dist-types/components/c-select/CSelect.vue.d.ts +115 -24
- package/dist-types/components/c-side-navigation/CSideNavigation.vue.d.ts +1 -1
- package/dist-types/components/c-spinner/CSpinner.vue.d.ts +1 -1
- package/dist-types/components/c-switch/CSwitch.vue.d.ts +1 -1
- package/dist-types/components/c-table/CTable.vue.d.ts +11 -1
- package/dist-types/components/c-table/injectTableStyles.d.ts +1 -0
- package/dist-types/components/c-tag/CTag.vue.d.ts +8 -1
- package/dist-types/components/c-text-field/CTextField.vue.d.ts +15 -4
- package/dist-types/components/c-toolbar/CToolbar.vue.d.ts +10 -1
- package/dist-types/components/c-tooltip/CTooltip.vue.d.ts +49 -0
- package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +261 -0
- package/dist-types/index.d.ts +14 -2
- package/dist-types/shared/FieldMessage.vue.d.ts +21 -0
- package/dist-types/shared/PanelHeadingRow.vue.d.ts +13 -0
- package/dist-types/shared/SelectionIndicator.vue.d.ts +21 -0
- package/dist-types/shared/appDefaults.d.ts +75 -0
- package/dist-types/shared/defineElement.d.ts +1 -0
- package/dist-types/shared/lightDismiss.d.ts +35 -0
- package/dist-types/shared/modalStack.d.ts +4 -3
- package/dist-types/shared/optionLabel.d.ts +18 -0
- package/dist-types/shared/pageLock.d.ts +26 -0
- package/dist-types/shared/peekCap.d.ts +35 -0
- package/dist-types/shared/popoverChain.d.ts +65 -0
- package/dist-types/shared/positionArea.d.ts +13 -0
- package/dist-types/shared/selectAll.d.ts +29 -0
- package/dist-types/shared/splitMatches.d.ts +18 -0
- package/dist-types/shared/useAnchoredPanel.d.ts +98 -0
- package/dist-types/shared/useDesignatedTrigger.d.ts +40 -0
- package/dist-types/shared/useHostStates.d.ts +25 -0
- package/dist-types/shared/useNarrowViewport.d.ts +19 -0
- package/dist-types/shared/useScrollStrip.d.ts +39 -0
- package/dist-types/shared/useStatusAnnouncer.d.ts +33 -0
- package/dist-types/shared/visualViewport.d.ts +51 -0
- package/dist-types/tag-name-map.d.ts +440 -51
- package/dist-types/theme/chart-data.d.ts +51 -0
- package/dist-types/theme/ramp.d.ts +38 -0
- package/dist-types/theme/themeMode.d.ts +51 -0
- package/dist-types/types.d.ts +13 -0
- package/package.json +19 -8
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED by scripts/generate-chart-data.mjs from
|
|
3
|
+
* tokens/semantic/{light,dark}.json — do not edit.
|
|
4
|
+
* Regenerate with `pnpm run chart:generate`; `pnpm run lint:chart` fails
|
|
5
|
+
* the build when this file is stale.
|
|
6
|
+
*
|
|
7
|
+
* The chart tokens (ADR-0030) as importable data (ADR-0040): the twelve
|
|
8
|
+
* series slots and the chart anatomy roles per theme mode. Values are the
|
|
9
|
+
* frozen, validated set — they never follow a consumer's `--c-chart-*`
|
|
10
|
+
* overrides. Pair with `themeMode(el)` to pick the mode in effect where the
|
|
11
|
+
* chart sits, or `observeThemeMode()` to follow it.
|
|
12
|
+
*/
|
|
13
|
+
import type { ThemeMode } from './themeMode';
|
|
14
|
+
/** The twelve series slots in slot order (`chart-1` … `chart-12`). */
|
|
15
|
+
export type ChartSlots = readonly [
|
|
16
|
+
string,
|
|
17
|
+
string,
|
|
18
|
+
string,
|
|
19
|
+
string,
|
|
20
|
+
string,
|
|
21
|
+
string,
|
|
22
|
+
string,
|
|
23
|
+
string,
|
|
24
|
+
string,
|
|
25
|
+
string,
|
|
26
|
+
string,
|
|
27
|
+
string
|
|
28
|
+
];
|
|
29
|
+
/** The chart anatomy roles: plot background, gridlines/axes, tick labels. */
|
|
30
|
+
export interface ChartAnatomy {
|
|
31
|
+
readonly surface: string;
|
|
32
|
+
readonly grid: string;
|
|
33
|
+
readonly axis: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Series slots per theme mode as `oklch(L C H)` strings — the palette's own
|
|
37
|
+
* colour space, ready for CSS, SVG and canvas `fillStyle`, and the exact
|
|
38
|
+
* string the `--c-chart-*` variable holds (ADR-0041). Each round-trips to
|
|
39
|
+
* the `#rrggbb` in `chartSlotsHex`.
|
|
40
|
+
*/
|
|
41
|
+
export declare const chartSlots: Readonly<Record<ThemeMode, ChartSlots>>;
|
|
42
|
+
/**
|
|
43
|
+
* Series slots per theme mode as `#rrggbb` — for chart libraries that do
|
|
44
|
+
* their own colour maths in sRGB (ECharts, Chart.js) and cannot parse
|
|
45
|
+
* `oklch()`. Same colours and order as `chartSlots`.
|
|
46
|
+
*/
|
|
47
|
+
export declare const chartSlotsHex: Readonly<Record<ThemeMode, ChartSlots>>;
|
|
48
|
+
/** Chart anatomy roles per theme mode as `oklch(L C H)` strings. */
|
|
49
|
+
export declare const chartAnatomy: Readonly<Record<ThemeMode, ChartAnatomy>>;
|
|
50
|
+
/** Chart anatomy roles per theme mode as `#rrggbb`. */
|
|
51
|
+
export declare const chartAnatomyHex: Readonly<Record<ThemeMode, ChartAnatomy>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Type surface for the plain-JS shared ramp core (ramp.js). Authored by hand
|
|
2
|
+
// because the core is JS (so the Node build script can import it without a TS
|
|
3
|
+
// loader) while consumers and the runtime API need types.
|
|
4
|
+
|
|
5
|
+
/** One of the chromatic brand/status families a consumer may re-seed. */
|
|
6
|
+
export type Family =
|
|
7
|
+
| 'primary'
|
|
8
|
+
| 'secondary'
|
|
9
|
+
| 'accent'
|
|
10
|
+
| 'success'
|
|
11
|
+
| 'info'
|
|
12
|
+
| 'warning'
|
|
13
|
+
| 'error'
|
|
14
|
+
| 'link';
|
|
15
|
+
|
|
16
|
+
/** Built-in brand seed (step-500) per family. */
|
|
17
|
+
export declare const DEFAULT_SEEDS: Record<Family, string>;
|
|
18
|
+
|
|
19
|
+
/** The chromatic families, in canonical order. */
|
|
20
|
+
export declare const FAMILIES: readonly Family[];
|
|
21
|
+
|
|
22
|
+
/** Ramp steps, in ascending order (`[50, 100, …, 950]`). */
|
|
23
|
+
export declare const STEPS: readonly number[];
|
|
24
|
+
|
|
25
|
+
/** Generate a full 50–950 ramp from a single step-500 seed. */
|
|
26
|
+
export declare function ramp(seedHex: string): Record<string, string>;
|
|
27
|
+
|
|
28
|
+
/** The `--c-<family>-*` custom-property map (steps + `-rgb`) for one seed. */
|
|
29
|
+
export declare function familyVars(
|
|
30
|
+
family: Family,
|
|
31
|
+
seedHex: string,
|
|
32
|
+
): Record<string, string>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The CSS value the library emits for a colour: a hex becomes `oklch(L C H)`
|
|
36
|
+
* at a precision that round-trips exactly; non-hex values pass through.
|
|
37
|
+
*/
|
|
38
|
+
export declare function cssColor(value: string): string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** The light-or-dark state that selects which palette the semantic tokens resolve to. */
|
|
2
|
+
export type ThemeMode = 'dark' | 'light';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the theme mode in effect for an element, mirroring the cascade in
|
|
5
|
+
* `tokens.css`: the nearest enclosing **mode scope** wins (an ancestor-or-self
|
|
6
|
+
* carrying `data-theme="light"` or `"dark"`, ADR-0053), an **inverting scope**
|
|
7
|
+
* (`data-theme-invert`, ADR-0054) flips whatever it sits in; otherwise the OS
|
|
8
|
+
* preference; light where neither is available (server rendering, no
|
|
9
|
+
* `matchMedia`). Any other `data-theme` value is inert, exactly as in CSS.
|
|
10
|
+
*
|
|
11
|
+
* The answer comes from the cascade itself — `--c-mode`, which every mode block
|
|
12
|
+
* declares — rather than from walking the DOM. That is the only way to resolve
|
|
13
|
+
* an inverting scope without re-implementing the style query, it cannot drift
|
|
14
|
+
* from the CSS, and unlike `closest()` it reads correctly for an element INSIDE
|
|
15
|
+
* a shadow root, since custom properties inherit across the boundary. The DOM
|
|
16
|
+
* walk remains as the fallback for when `tokens.css` has not been loaded: a
|
|
17
|
+
* detached node, a server-rendered pass, or a consumer who ships only the
|
|
18
|
+
* Tailwind theme export.
|
|
19
|
+
*
|
|
20
|
+
* Pass the element whose mode you need — a chart inside a dark panel on an
|
|
21
|
+
* otherwise light page resolves `dark` only if you ask about the chart.
|
|
22
|
+
* `observeThemeMode()` keeps that answer current.
|
|
23
|
+
*
|
|
24
|
+
* @param root the element to resolve for — defaults to `<html>`
|
|
25
|
+
*/
|
|
26
|
+
export declare function themeMode(root?: Element | null): ThemeMode;
|
|
27
|
+
/**
|
|
28
|
+
* Watch the theme mode in effect for an element and report every change.
|
|
29
|
+
*
|
|
30
|
+
* Calls `onChange` once synchronously with the current mode, then again
|
|
31
|
+
* whenever it actually changes — so wiring a chart up is the one call, with no
|
|
32
|
+
* separate initial render. Covers both paths that can change the answer: a
|
|
33
|
+
* `data-theme` or `data-theme-invert` attribute mutating anywhere in the
|
|
34
|
+
* document (the element's own **mode scope** or any ancestor's, which is why a
|
|
35
|
+
* `documentElement`-only observer is not enough), and the OS preference
|
|
36
|
+
* flipping while no scope pins a mode.
|
|
37
|
+
*
|
|
38
|
+
* Re-parenting `target` is not observed; re-subscribe if you move it. That
|
|
39
|
+
* matters more than it used to: an **inverting scope** resolves against where
|
|
40
|
+
* it sits, so moving one between a light and a dark region changes its mode,
|
|
41
|
+
* where moving a pinned scope never did.
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* const stop = observeThemeMode(chartEl, (mode) => {
|
|
45
|
+
* chart.setOption({ color: chartSlotsHex[mode] });
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @returns a disposer that detaches both listeners
|
|
50
|
+
*/
|
|
51
|
+
export declare function observeThemeMode(target: Element, onChange: (mode: ThemeMode) => void): () => void;
|
package/dist-types/types.d.ts
CHANGED
|
@@ -6,6 +6,19 @@
|
|
|
6
6
|
*
|
|
7
7
|
* import type { CSelectItem } from '@cscfi/csc-ui';
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Field height of the form controls built on `c-input`. `default` is the 44px
|
|
11
|
+
* field; `small` is the 36px field. Owned here because the value passes from
|
|
12
|
+
* the wrapping control (`c-select`) into `c-input`.
|
|
13
|
+
*/
|
|
14
|
+
export type CFieldSize = 'default' | 'small';
|
|
15
|
+
/**
|
|
16
|
+
* Preferred placement of a floating panel relative to its anchor, shared by
|
|
17
|
+
* the anchor-positioned overlay components (`c-menu`, `c-tooltip`,
|
|
18
|
+
* `c-popover`). The side names the panel's position; `-start`/`-end` align
|
|
19
|
+
* the panel's edge with the anchor's on the cross axis.
|
|
20
|
+
*/
|
|
21
|
+
export type CPlacement = 'bottom-end' | 'bottom-start' | 'bottom' | 'left-end' | 'left-start' | 'left' | 'right-end' | 'right-start' | 'right' | 'top-end' | 'top-start' | 'top';
|
|
9
22
|
/**
|
|
10
23
|
* A selectable item for the value-selection components (`c-select`,
|
|
11
24
|
* `c-autocomplete`) when options are supplied via the `items` prop instead of
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cscfi/csc-ui",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.20",
|
|
4
4
|
"description": "Vue 3-based replacement for @cscfi/csc-ui — same custom element tag names, Vue v-model contract.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/csc-ui.js",
|
|
@@ -33,8 +33,9 @@
|
|
|
33
33
|
"@eslint/js": "^9.28.0",
|
|
34
34
|
"@stylistic/eslint-plugin": "^5.7.0",
|
|
35
35
|
"@tailwindcss/vite": "^4.3.1",
|
|
36
|
-
"@types/node": "^
|
|
36
|
+
"@types/node": "^24.0.0",
|
|
37
37
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
38
|
+
"@vitest/browser-playwright": "5.0.0",
|
|
38
39
|
"custom-element-jet-brains-integration": "^1.7.0",
|
|
39
40
|
"custom-element-vs-code-integration": "^1.5.0",
|
|
40
41
|
"eslint": "^9.28.0",
|
|
@@ -44,31 +45,41 @@
|
|
|
44
45
|
"eslint-plugin-prettier": "^5.5.6",
|
|
45
46
|
"eslint-plugin-vue": "^10.9.2",
|
|
46
47
|
"globals": "^17.7.0",
|
|
48
|
+
"playwright": "1.60.0",
|
|
47
49
|
"prettier": "^3.8.5",
|
|
48
50
|
"style-dictionary": "^3.9.0",
|
|
49
51
|
"tailwindcss": "^4.3.1",
|
|
50
52
|
"typescript": "^6.0.3",
|
|
51
53
|
"typescript-eslint": "^8.62.0",
|
|
52
54
|
"vite": "^8.1.0",
|
|
55
|
+
"vitest": "5.0.0",
|
|
53
56
|
"vue-tsc": "^3.3.5"
|
|
54
57
|
},
|
|
55
58
|
"license": "MIT",
|
|
56
59
|
"repository": "CSCfi/ui",
|
|
57
60
|
"homepage": "https://design-system.csc.fi",
|
|
58
61
|
"scripts": {
|
|
59
|
-
"build": "pnpm run style-dictionary:build && pnpm run docs:tag-map && vite build &&
|
|
62
|
+
"build": "pnpm run style-dictionary:build && pnpm run chart:generate && pnpm run docs:tag-map && vite build && pnpm run build:types && pnpm run docs:manifest:strict",
|
|
60
63
|
"docs:manifest": "node scripts/analyzer/index.mjs",
|
|
61
64
|
"docs:tag-map": "node scripts/analyzer/index.mjs --tag-map",
|
|
62
65
|
"docs:manifest:strict": "node scripts/analyzer/index.mjs --strict",
|
|
63
66
|
"docs:seed": "node scripts/seed-descriptions.mjs",
|
|
64
|
-
"build:types": "vue-tsc -p tsconfig.build.json",
|
|
65
|
-
"build:watch": "pnpm run style-dictionary:build &&
|
|
66
|
-
"dev": "pnpm run style-dictionary:build &&
|
|
67
|
+
"build:types": "vue-tsc -p tsconfig.build.json && node scripts/copy-declarations.mjs",
|
|
68
|
+
"build:watch": "pnpm run style-dictionary:build && pnpm run chart:generate && pnpm run build:types && vite build --watch",
|
|
69
|
+
"dev": "pnpm run style-dictionary:build && pnpm run chart:generate && pnpm run build:types && vite build --watch",
|
|
67
70
|
"lint:a11y": "node scripts/check-host-attr-fallthrough.mjs",
|
|
68
71
|
"lint:contrast": "node scripts/audit-contrast.mjs",
|
|
69
72
|
"lint:ramp": "node scripts/check-ramp-parity.mjs",
|
|
70
|
-
"lint:tokens": "node scripts/check-palette-utilities.mjs",
|
|
73
|
+
"lint:tokens": "node scripts/check-palette-utilities.mjs --strict",
|
|
71
74
|
"style-dictionary:build": "style-dictionary build --config ./style-dictionary.config.cjs",
|
|
72
|
-
"type-check": "vue-tsc --build --force"
|
|
75
|
+
"type-check": "vue-tsc --build --force",
|
|
76
|
+
"chart:generate": "node scripts/generate-chart-data.mjs",
|
|
77
|
+
"lint:chart": "node scripts/check-chart-parity.mjs",
|
|
78
|
+
"lint": "pnpm run lint:tokens && pnpm run lint:a11y && pnpm run lint:ramp && pnpm run lint:chart",
|
|
79
|
+
"test": "pnpm run style-dictionary:build && vitest run",
|
|
80
|
+
"test:watch": "vitest",
|
|
81
|
+
"test:browser": "vitest run --project browser",
|
|
82
|
+
"test:node": "vitest run --project node",
|
|
83
|
+
"test:update": "pnpm run style-dictionary:build && vitest run --project browser --update"
|
|
73
84
|
}
|
|
74
85
|
}
|