@simpleplatform/ui-kit 0.2.1 → 0.4.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.
@@ -9,7 +9,7 @@ const STATUS_BADGE_STYLES = `
9
9
  [part="base"] {
10
10
  align-items: center;
11
11
  background: var(--simple-color-surface-sunken);
12
- border: 1px solid var(--simple-color-border-default);
12
+ border: none;
13
13
  border-radius: var(--simple-radius-round);
14
14
  box-sizing: border-box;
15
15
  color: var(--simple-color-text-secondary);
@@ -18,33 +18,29 @@ const STATUS_BADGE_STYLES = `
18
18
  font-weight: var(--simple-font-weight-medium);
19
19
  line-height: var(--simple-line-height-tight);
20
20
  max-width: 100%;
21
- min-height: var(--simple-control-height-sm);
21
+ min-height: 1.25rem;
22
22
  overflow-wrap: anywhere;
23
- padding: 0 var(--simple-space-2);
23
+ padding: 0.125rem 0.625rem;
24
24
  }
25
25
 
26
26
  [part="base"][data-tone="info"] {
27
- background: var(--simple-color-status-info-background);
28
- border-color: var(--simple-color-status-info);
29
- color: var(--simple-color-status-info-foreground);
27
+ background: color-mix(in srgb, var(--simple-color-status-info) 12%, transparent);
28
+ color: var(--simple-color-status-info);
30
29
  }
31
30
 
32
31
  [part="base"][data-tone="success"] {
33
- background: var(--simple-color-status-success-background);
34
- border-color: var(--simple-color-status-success);
35
- color: var(--simple-color-status-success-foreground);
32
+ background: color-mix(in srgb, var(--simple-color-status-success) 12%, transparent);
33
+ color: var(--simple-color-status-success);
36
34
  }
37
35
 
38
36
  [part="base"][data-tone="warning"] {
39
- background: var(--simple-color-status-warning-background);
40
- border-color: var(--simple-color-status-warning);
41
- color: var(--simple-color-status-warning-foreground);
37
+ background: color-mix(in srgb, var(--simple-color-status-warning) 12%, transparent);
38
+ color: var(--simple-color-status-warning);
42
39
  }
43
40
 
44
41
  [part="base"][data-tone="danger"] {
45
- background: var(--simple-color-status-danger-background);
46
- border-color: var(--simple-color-status-danger);
47
- color: var(--simple-color-status-danger-foreground);
42
+ background: color-mix(in srgb, var(--simple-color-status-danger) 12%, transparent);
43
+ color: var(--simple-color-status-danger);
48
44
  }
49
45
 
50
46
  [part="description"] {
@@ -1,4 +1,6 @@
1
+ export type { BoardMoveRequest, BoardPreset, BoardProps, ControlledFilterProps, DataGridPreset, DataGridProps, ListPreset, ListViewProps, RecordViewPreset, RecordViewProps, } from '../contracts/index.js';
1
2
  export { RecordActivity, type RecordActivityProps } from './record-activity.js';
2
3
  export { RecordForm, type RecordFormProps } from './record-form.js';
4
+ export { Board, DataGrid, ListView, } from './record-view.js';
3
5
  export { StatusBadge, type StatusBadgeProps } from './status-badge.js';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE/E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -1,3 +1,4 @@
1
1
  export { RecordActivity } from './record-activity.js';
2
2
  export { RecordForm } from './record-form.js';
3
+ export { Board, DataGrid, ListView, } from './record-view.js';
3
4
  export { StatusBadge } from './status-badge.js';
@@ -22,6 +22,9 @@ interface ManagedRecordBridge {
22
22
  form?: unknown;
23
23
  graphql: (document: string, variables?: Readonly<Record<string, unknown>>) => Promise<unknown>;
24
24
  metadata?: ManagedRecordMetadata;
25
+ onDraftChange?: () => void;
26
+ registerDiscard?: (discard: (values: Readonly<Record<string, unknown>>) => Promise<void>) => () => void;
27
+ registerDraftState?: (getDirty: () => boolean) => () => void;
25
28
  registerSubmitPreparation: (preparation: () => Promise<Readonly<Record<string, unknown>> | undefined>) => () => void;
26
29
  runtime?: RuntimeDescriptor;
27
30
  subscribe: (listener: (snapshot: unknown) => void) => () => void;
@@ -30,5 +33,11 @@ interface ManagedRecordBridge {
30
33
  }
31
34
  /** Finds the SDK-owned bridge without adding a package export or RecordHandle member. */
32
35
  export declare function getManagedRecordBridge(record: RecordHandle): ManagedRecordBridge | undefined;
36
+ export interface ManagedUiBridge {
37
+ graphql: (document: string, variables?: Readonly<Record<string, unknown>>) => Promise<unknown>;
38
+ runtime?: RuntimeDescriptor;
39
+ }
40
+ /** Finds the SDK-owned client UI bridge without adding a public member to SimpleClient. */
41
+ export declare function getManagedUiBridge(client: unknown): ManagedUiBridge | undefined;
33
42
  export {};
34
43
  //# sourceMappingURL=record-bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"record-bridge.d.ts","sourceRoot":"","sources":["../../src/react/record-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAItD,UAAU,qBAAqB;IAC7B,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAA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BAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAM/E"}
@@ -6,3 +6,11 @@ export function getManagedRecordBridge(record) {
6
6
  const bridge = record[MANAGED_RECORD_UI_SYMBOL];
7
7
  return bridge && typeof bridge === 'object' ? bridge : undefined;
8
8
  }
9
+ const MANAGED_UI_SYMBOL = Symbol.for('@simpleplatform/sdk/space/managed-ui/v1');
10
+ /** Finds the SDK-owned client UI bridge without adding a public member to SimpleClient. */
11
+ export function getManagedUiBridge(client) {
12
+ if (!client || typeof client !== 'object')
13
+ return undefined;
14
+ const bridge = client[MANAGED_UI_SYMBOL];
15
+ return bridge && typeof bridge === 'object' ? bridge : undefined;
16
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"record-form.d.ts","sourceRoot":"","sources":["../../src/react/record-form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAQ7D,UAAU,eAAe;IACvB,MAAM,EAAE,YAAY,CAAA;CACrB;AAsBD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,2CAErD;AAiID,YAAY,EAAE,eAAe,EAAE,CAAA"}
1
+ {"version":3,"file":"record-form.d.ts","sourceRoot":"","sources":["../../src/react/record-form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAQ7D,UAAU,eAAe;IACvB,MAAM,EAAE,YAAY,CAAA;CACrB;AAyBD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,2CAErD;AAoID,YAAY,EAAE,eAAe,EAAE,CAAA"}
@@ -63,6 +63,9 @@ function RecordFormInstance({ record }) {
63
63
  element.graphql = bridge.graphql;
64
64
  element.capabilities = bridge.capabilities;
65
65
  element.navigate = bridge.capabilities?.navigate;
66
+ element.onDraftChange = bridge.onDraftChange;
67
+ element.registerDiscard = bridge.registerDiscard;
68
+ element.registerDraftState = bridge.registerDraftState;
66
69
  element.registerSubmitPreparation = bridge.registerSubmitPreparation;
67
70
  element.record = record;
68
71
  element.subscribe = bridge.subscribe;
@@ -0,0 +1,6 @@
1
+ import type { BoardProps, DataGridProps, ListViewProps } from '../contracts/views.js';
2
+ export type ViewComponentKind = 'board' | 'list' | 'table';
3
+ export declare function ListView(props: ListViewProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare function DataGrid(props: DataGridProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function Board(props: BoardProps): import("react/jsx-runtime").JSX.Element;
6
+ //# sourceMappingURL=record-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-view.d.ts","sourceRoot":"","sources":["../../src/react/record-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,UAAU,EACV,aAAa,EACb,aAAa,EAKd,MAAM,uBAAuB,CAAA;AAe9B,MAAM,MAAM,iBAAiB,GACvB,OAAO,GACP,MAAM,GACN,OAAO,CAAA;AAoQb,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAE5C;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAE5C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,2CAEtC"}
@@ -0,0 +1,186 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { RecordViewContractError, validateBoardPresetV1, validateControlledFilterPropsV1, validateDataGridPresetV1, validateListPresetV1, validateRecordSourceV1, } from '../contracts/views.js';
4
+ import { loadRuntime, RuntimeLoadError } from '../runtime.js';
5
+ import { waitForElementMount } from './mount-boundary.js';
6
+ import { getManagedUiBridge } from './record-bridge.js';
7
+ const VIEW_READY_EVENT = 'simple-record-view-ready';
8
+ const VIEW_ERROR_EVENT = 'simple-record-view-error';
9
+ function validateRecordViewProps(props) {
10
+ validateRecordSourceV1(props.source);
11
+ switch (props.viewKind) {
12
+ case 'list':
13
+ validateListPresetV1(props.preset);
14
+ validateControlledFilterPropsV1(props);
15
+ break;
16
+ case 'table':
17
+ validateDataGridPresetV1(props.preset);
18
+ validateControlledFilterPropsV1(props);
19
+ break;
20
+ case 'board':
21
+ validateBoardPresetV1(props.preset);
22
+ validateControlledFilterPropsV1(props);
23
+ if (props.onMoveRequest !== undefined && typeof props.onMoveRequest !== 'function')
24
+ throw new RecordViewContractError('onMoveRequest must be a function.');
25
+ break;
26
+ }
27
+ if (props.onItemOpen !== undefined && typeof props.onItemOpen !== 'function')
28
+ throw new RecordViewContractError('onItemOpen must be a function.');
29
+ }
30
+ function applyRecordViewProperties(element, props, graphql) {
31
+ const properties = {
32
+ filter: props.filter,
33
+ filterControlled: typeof props.onFilterChange === 'function',
34
+ graphql,
35
+ kind: props.viewKind,
36
+ onFilterChange: props.onFilterChange,
37
+ onItemOpen: props.onItemOpen,
38
+ onMoveRequest: props.onMoveRequest,
39
+ preset: props.preset,
40
+ source: props.source,
41
+ viewKind: props.viewKind,
42
+ };
43
+ if (element.applyProperties) {
44
+ element.applyProperties(properties);
45
+ return;
46
+ }
47
+ Object.assign(element, properties);
48
+ }
49
+ function RecordViewAdapter(props) {
50
+ const containerRef = useRef(null);
51
+ const [state, setState] = useState({ kind: 'loading' });
52
+ const [attempt, setAttempt] = useState(0);
53
+ const bridge = getManagedUiBridge(props.client);
54
+ const propsRef = useRef(props);
55
+ propsRef.current = props;
56
+ const propsValidationError = useRef();
57
+ // Synchronize dynamic prop updates onto the mounted element without remounting
58
+ useEffect(() => {
59
+ try {
60
+ validateRecordViewProps(props);
61
+ }
62
+ catch (err) {
63
+ const error = err instanceof Error ? err : new Error('Invalid record view configuration.');
64
+ if (propsValidationError.current !== error.message) {
65
+ propsValidationError.current = error.message;
66
+ setState({ error, kind: 'error' });
67
+ }
68
+ return;
69
+ }
70
+ if (propsValidationError.current) {
71
+ propsValidationError.current = undefined;
72
+ if (containerRef.current?.querySelector('simple-record-view')) {
73
+ setState({ kind: 'ready' });
74
+ }
75
+ else {
76
+ setState({ kind: 'loading' });
77
+ setAttempt(current => current + 1);
78
+ }
79
+ }
80
+ const element = containerRef.current?.querySelector('simple-record-view');
81
+ if (element && bridge?.graphql) {
82
+ applyRecordViewProperties(element, props, bridge.graphql);
83
+ }
84
+ }, [
85
+ props.source,
86
+ props.preset,
87
+ props.filter,
88
+ props.onFilterChange,
89
+ props.onItemOpen,
90
+ props.onMoveRequest,
91
+ props.viewKind,
92
+ ]);
93
+ useEffect(() => {
94
+ if (!bridge) {
95
+ setState({
96
+ error: new Error('The managed record view is unavailable for this Space.'),
97
+ kind: 'error',
98
+ });
99
+ return;
100
+ }
101
+ try {
102
+ validateRecordViewProps(props);
103
+ }
104
+ catch (err) {
105
+ setState({
106
+ error: err instanceof Error ? err : new Error('Invalid record view configuration.'),
107
+ kind: 'error',
108
+ });
109
+ return;
110
+ }
111
+ let disposed = false;
112
+ let failed = false;
113
+ let element;
114
+ let disposeMount;
115
+ const mountController = new AbortController();
116
+ const mount = async () => {
117
+ try {
118
+ if (bridge.runtime) {
119
+ await loadRuntime(bridge.runtime);
120
+ }
121
+ if (!customElements.get('simple-record-view')) {
122
+ throw new Error('The Simple UI Runtime did not register RecordView.');
123
+ }
124
+ if (disposed || !containerRef.current) {
125
+ return;
126
+ }
127
+ const currentProps = propsRef.current;
128
+ validateRecordViewProps(currentProps);
129
+ element = document.createElement('simple-record-view');
130
+ element.style.display = 'block';
131
+ element.style.width = '100%';
132
+ element.style.height = '100%';
133
+ applyRecordViewProperties(element, currentProps, bridge.graphql);
134
+ const ready = waitForElementMount({
135
+ element,
136
+ errorEventName: VIEW_ERROR_EVENT,
137
+ fallbackErrorMessage: 'The record view could not be rendered.',
138
+ onPostMountError: (error) => {
139
+ failed = true;
140
+ if (!disposed) {
141
+ setState({ error, kind: 'error' });
142
+ }
143
+ },
144
+ readyEventName: VIEW_READY_EVENT,
145
+ signal: mountController.signal,
146
+ timeoutMessage: 'The record view did not become ready in time.',
147
+ });
148
+ containerRef.current.replaceChildren(element);
149
+ disposeMount = await ready;
150
+ if (!disposed && !failed) {
151
+ setState({ kind: 'ready' });
152
+ }
153
+ }
154
+ catch (error) {
155
+ if (!disposed) {
156
+ const failure = error instanceof RuntimeLoadError || error instanceof Error
157
+ ? error
158
+ : new Error('The Simple UI Runtime could not be loaded.');
159
+ setState({ error: failure, kind: 'error' });
160
+ }
161
+ }
162
+ };
163
+ void mount();
164
+ return () => {
165
+ disposed = true;
166
+ mountController.abort();
167
+ disposeMount?.();
168
+ if (containerRef.current && element && containerRef.current.contains(element)) {
169
+ containerRef.current.replaceChildren();
170
+ }
171
+ };
172
+ }, [attempt, bridge, props.source?.kind, props.viewKind]);
173
+ return (_jsxs(_Fragment, { children: [state.kind === 'error' && (_jsxs("div", { role: "alert", children: [_jsx("p", { children: state.error.message }), _jsx("button", { onClick: () => {
174
+ setState({ kind: 'loading' });
175
+ setAttempt(current => current + 1);
176
+ }, type: "button", children: "Try again" })] })), _jsx("div", { "aria-busy": state.kind === 'loading' ? 'true' : undefined, "data-simple-managed-record-view": "", style: { height: '100%', minHeight: 0 }, ref: containerRef })] }));
177
+ }
178
+ export function ListView(props) {
179
+ return _jsx(RecordViewAdapter, { ...props, viewKind: "list" });
180
+ }
181
+ export function DataGrid(props) {
182
+ return _jsx(RecordViewAdapter, { ...props, viewKind: "table" });
183
+ }
184
+ export function Board(props) {
185
+ return _jsx(RecordViewAdapter, { ...props, viewKind: "board" });
186
+ }
package/dist/runtime.d.ts CHANGED
@@ -3,9 +3,11 @@ export interface RuntimeDescriptor {
3
3
  version: string;
4
4
  }
5
5
  export interface RuntimeInfo {
6
+ capabilities?: readonly string[];
6
7
  version: string;
7
8
  }
8
9
  export interface RuntimeModule {
10
+ capabilities?: unknown;
9
11
  version?: unknown;
10
12
  }
11
13
  export declare class RuntimeLoadError extends Error {
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":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GAAG,EAAE,OAAO,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CA2BrF"}
package/dist/runtime.js CHANGED
@@ -42,5 +42,11 @@ function readRuntimeInfo(module, expected) {
42
42
  if (typeof module.version !== 'string' || module.version !== expected) {
43
43
  throw new RuntimeLoadError(`Simple UI Runtime version mismatch. Expected ${expected}.`, expected, typeof module.version === 'string' ? module.version : undefined);
44
44
  }
45
- return { version: module.version };
45
+ const rawCapabilities = Array.isArray(module.capabilities)
46
+ ? module.capabilities.filter((c) => typeof c === 'string')
47
+ : undefined;
48
+ return {
49
+ ...(rawCapabilities !== undefined ? { capabilities: Object.freeze(rawCapabilities) } : {}),
50
+ version: module.version,
51
+ };
46
52
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simpleplatform/ui-kit",
3
3
  "type": "module",
4
- "version": "0.2.1",
4
+ "version": "0.4.0",
5
5
  "description": "Supported UI contracts and framework bridges for Simple Spaces",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -42,7 +42,7 @@
42
42
  "theme.css"
43
43
  ],
44
44
  "peerDependencies": {
45
- "@simpleplatform/sdk": "^3.0.0 || 0.0.0",
45
+ "@simpleplatform/sdk": "^4.1.0 || 0.0.0",
46
46
  "react": ">=18.3.0 <20"
47
47
  },
48
48
  "dependencies": {
package/theme.css CHANGED
@@ -64,17 +64,9 @@
64
64
  --simple-color-action-danger-foreground: hsl(0 0% 98%);
65
65
  --simple-gradient-action-primary: none;
66
66
  --simple-color-status-info: hsl(221 83% 35%);
67
- --simple-color-status-info-background: hsl(214 95% 93%);
68
- --simple-color-status-info-foreground: hsl(221 83% 35%);
69
67
  --simple-color-status-success: hsl(142 72% 25%);
70
- --simple-color-status-success-background: hsl(142 76% 90%);
71
- --simple-color-status-success-foreground: hsl(142 72% 25%);
72
68
  --simple-color-status-warning: hsl(28 80% 25%);
73
- --simple-color-status-warning-background: hsl(38 92% 90%);
74
- --simple-color-status-warning-foreground: hsl(28 80% 25%);
75
69
  --simple-color-status-danger: hsl(0 84.2% 60.2%);
76
- --simple-color-status-danger-background: hsl(0 84% 95%);
77
- --simple-color-status-danger-foreground: hsl(0 72% 35%);
78
70
  --simple-color-field-background: hsl(0 0% 100%);
79
71
  --simple-color-field-background-disabled: hsl(240 4.8% 95.9%);
80
72
  --simple-color-field-border: hsl(240 5.9% 90%);
@@ -128,9 +120,9 @@
128
120
  --simple-sidebar-width: 16rem;
129
121
  --simple-radius-none: 0;
130
122
  --simple-radius-sm: 0.25rem;
131
- --simple-radius-md: 0.5rem;
132
- --simple-radius-lg: 0.75rem;
133
- --simple-radius-xl: 1rem;
123
+ --simple-radius-md: 0.375rem;
124
+ --simple-radius-lg: 0.5rem;
125
+ --simple-radius-xl: 0.75rem;
134
126
  --simple-radius-round: 9999px;
135
127
  --simple-shadow-none: none;
136
128
  --simple-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.08);
@@ -192,17 +184,9 @@
192
184
  --simple-color-navbar-primary: hsl(224.3 76.3% 48%);
193
185
  --simple-color-navbar-primary-foreground: hsl(0 0% 100%);
194
186
  --simple-color-status-danger: hsl(0 55% 42%);
195
- --simple-color-status-danger-background: hsl(0 45% 24%);
196
- --simple-color-status-danger-foreground: hsl(0 85% 88%);
197
187
  --simple-color-status-info: hsl(214 70% 45%);
198
- --simple-color-status-info-background: hsl(214 60% 25%);
199
- --simple-color-status-info-foreground: hsl(214 95% 90%);
200
188
  --simple-color-status-success: hsl(142 50% 38%);
201
- --simple-color-status-success-background: hsl(142 45% 22%);
202
- --simple-color-status-success-foreground: hsl(142 65% 85%);
203
189
  --simple-color-status-warning: hsl(38 65% 42%);
204
- --simple-color-status-warning-background: hsl(38 55% 24%);
205
- --simple-color-status-warning-foreground: hsl(38 90% 85%);
206
190
  --simple-color-surface: hsl(240 10% 3.9%);
207
191
  --simple-color-surface-active: hsl(240 3.7% 21%);
208
192
  --simple-color-surface-disabled: hsl(240 3.7% 15.9%);
@@ -329,17 +313,17 @@
329
313
 
330
314
  /* Semantic utility families: status */
331
315
  --color-status-info: var(--simple-color-status-info);
332
- --color-status-info-background: var(--simple-color-status-info-background);
333
- --color-status-info-foreground: var(--simple-color-status-info-foreground);
316
+ --color-status-info-background: color-mix(in srgb, var(--simple-color-status-info) 12%, transparent);
317
+ --color-status-info-foreground: var(--simple-color-status-info);
334
318
  --color-status-success: var(--simple-color-status-success);
335
- --color-status-success-background: var(--simple-color-status-success-background);
336
- --color-status-success-foreground: var(--simple-color-status-success-foreground);
319
+ --color-status-success-background: color-mix(in srgb, var(--simple-color-status-success) 12%, transparent);
320
+ --color-status-success-foreground: var(--simple-color-status-success);
337
321
  --color-status-warning: var(--simple-color-status-warning);
338
- --color-status-warning-background: var(--simple-color-status-warning-background);
339
- --color-status-warning-foreground: var(--simple-color-status-warning-foreground);
322
+ --color-status-warning-background: color-mix(in srgb, var(--simple-color-status-warning) 12%, transparent);
323
+ --color-status-warning-foreground: var(--simple-color-status-warning);
340
324
  --color-status-danger: var(--simple-color-status-danger);
341
- --color-status-danger-background: var(--simple-color-status-danger-background);
342
- --color-status-danger-foreground: var(--simple-color-status-danger-foreground);
325
+ --color-status-danger-background: color-mix(in srgb, var(--simple-color-status-danger) 12%, transparent);
326
+ --color-status-danger-foreground: var(--simple-color-status-danger);
343
327
 
344
328
  /* Semantic utility families: field */
345
329
  --color-field-background: var(--simple-color-field-background);