@workday/canvas-kit-react 16.0.0-alpha.0499-next.0 → 16.0.0-alpha.0500-next.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.
- package/common/lib/CanvasProvider.tsx +156 -324
- package/common/lib/theming/README.md +49 -6
- package/common/lib/theming/brandScope.ts +566 -0
- package/common/lib/theming/index.ts +1 -0
- package/common/lib/theming/sanaTheme.ts +133 -0
- package/common/lib/theming/types.ts +292 -0
- package/dist/commonjs/common/lib/CanvasProvider.d.ts +296 -5
- package/dist/commonjs/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/commonjs/common/lib/CanvasProvider.js +105 -287
- package/dist/commonjs/common/lib/theming/brandScope.d.ts +64 -0
- package/dist/commonjs/common/lib/theming/brandScope.d.ts.map +1 -0
- package/dist/commonjs/common/lib/theming/brandScope.js +499 -0
- package/dist/commonjs/common/lib/theming/index.d.ts +1 -0
- package/dist/commonjs/common/lib/theming/index.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/index.js +1 -0
- package/dist/commonjs/common/lib/theming/sanaTheme.d.ts +33 -0
- package/dist/commonjs/common/lib/theming/sanaTheme.d.ts.map +1 -0
- package/dist/commonjs/common/lib/theming/sanaTheme.js +130 -0
- package/dist/commonjs/common/lib/theming/types.d.ts +162 -0
- package/dist/commonjs/common/lib/theming/types.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/types.js +81 -1
- package/dist/commonjs/pill/lib/Pill.d.ts +2 -2
- package/dist/commonjs/popup/lib/hooks/usePopupStack.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/hooks/usePopupStack.js +18 -16
- package/dist/commonjs/testing/lib/StaticStates.d.ts +2 -2
- package/dist/commonjs/testing/lib/StaticStates.d.ts.map +1 -1
- package/dist/commonjs/testing/lib/StaticStates.js +5 -2
- package/dist/es6/common/lib/CanvasProvider.d.ts +296 -5
- package/dist/es6/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/es6/common/lib/CanvasProvider.js +82 -288
- package/dist/es6/common/lib/theming/brandScope.d.ts +64 -0
- package/dist/es6/common/lib/theming/brandScope.d.ts.map +1 -0
- package/dist/es6/common/lib/theming/brandScope.js +483 -0
- package/dist/es6/common/lib/theming/index.d.ts +1 -0
- package/dist/es6/common/lib/theming/index.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/index.js +1 -0
- package/dist/es6/common/lib/theming/sanaTheme.d.ts +33 -0
- package/dist/es6/common/lib/theming/sanaTheme.d.ts.map +1 -0
- package/dist/es6/common/lib/theming/sanaTheme.js +127 -0
- package/dist/es6/common/lib/theming/types.d.ts +162 -0
- package/dist/es6/common/lib/theming/types.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/types.js +78 -0
- package/dist/es6/pill/lib/Pill.d.ts +2 -2
- package/dist/es6/popup/lib/hooks/usePopupStack.d.ts.map +1 -1
- package/dist/es6/popup/lib/hooks/usePopupStack.js +13 -11
- package/dist/es6/testing/lib/StaticStates.d.ts +2 -2
- package/dist/es6/testing/lib/StaticStates.d.ts.map +1 -1
- package/dist/es6/testing/lib/StaticStates.js +6 -3
- package/package.json +4 -4
- package/popup/lib/hooks/usePopupStack.ts +13 -11
- package/testing/lib/StaticStates.tsx +11 -9
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanaCanvasProviderTheme = exports.sanaCanvasNumericalTheme = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sana Canvas theme presets.
|
|
6
|
+
*
|
|
7
|
+
* Sana is a distinct theme from classic Canvas — not a delta on `defaultCanvasTheme`.
|
|
8
|
+
* Full visual treatment (fonts, shapes, system surfaces) comes from global CSS:
|
|
9
|
+
* import `@workday/canvas-tokens-web/css/sana/_variables.css` and set
|
|
10
|
+
* `data-theme="sana-canvas"` on `<html>`.
|
|
11
|
+
*
|
|
12
|
+
* These JS presets reference Sana brand CSS variables so `CanvasProvider` can forward
|
|
13
|
+
* them to popup containers (menus, selects, modals). Keep in sync with
|
|
14
|
+
* `@workday/canvas-tokens-web/css/sana/_variables.css`.
|
|
15
|
+
*
|
|
16
|
+
* | Preset | Use case |
|
|
17
|
+
* |--------|----------|
|
|
18
|
+
* | `sanaCanvasNumericalTheme` | Numerical `brand` shape for popup forwarding |
|
|
19
|
+
* | `sanaCanvasProviderTheme` | Same — pass to root `CanvasProvider` when `<html>` is unavailable |
|
|
20
|
+
*/
|
|
21
|
+
const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
|
|
22
|
+
/** Reference a canvas-tokens CSS variable (resolves under `[data-theme="sana-canvas"]`). */
|
|
23
|
+
const varRef = (token) => `var(${token})`;
|
|
24
|
+
/**
|
|
25
|
+
* Sana extends the neutral ramp with steps not yet exported from canvas-tokens-web JS.
|
|
26
|
+
* Defined in `@workday/canvas-tokens-web/css/sana/_variables.css`.
|
|
27
|
+
*/
|
|
28
|
+
const sanaBrandNeutral = {
|
|
29
|
+
'150': '--cnvs-brand-neutral-150',
|
|
30
|
+
'850': '--cnvs-brand-neutral-850',
|
|
31
|
+
A150: '--cnvs-brand-neutral-a150',
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Sana Canvas brand tokens for scoped `CanvasProvider` / popup forwarding.
|
|
35
|
+
* Values are `var()` references to Sana brand variables — not merged from `defaultCanvasTheme`.
|
|
36
|
+
*/
|
|
37
|
+
exports.sanaCanvasNumericalTheme = {
|
|
38
|
+
// Explicit brand vars only — multi-key ramps write 1:1; no system shortcut bundles run.
|
|
39
|
+
themeScope: 'brand',
|
|
40
|
+
brand: {
|
|
41
|
+
action: {
|
|
42
|
+
base: varRef(canvas_tokens_web_1.brand.neutral975),
|
|
43
|
+
dark: varRef(canvas_tokens_web_1.brand.neutral950),
|
|
44
|
+
darkest: varRef(canvas_tokens_web_1.brand.neutral900),
|
|
45
|
+
accent: varRef(canvas_tokens_web_1.base.neutral0),
|
|
46
|
+
lightest: varRef(canvas_tokens_web_1.brand.neutral25),
|
|
47
|
+
lighter: varRef(canvas_tokens_web_1.brand.neutral50),
|
|
48
|
+
light: varRef(canvas_tokens_web_1.brand.neutral200),
|
|
49
|
+
},
|
|
50
|
+
neutral: {
|
|
51
|
+
'25': varRef(canvas_tokens_web_1.brand.neutral25),
|
|
52
|
+
'50': varRef(canvas_tokens_web_1.brand.neutral50),
|
|
53
|
+
'100': varRef(canvas_tokens_web_1.brand.neutral100),
|
|
54
|
+
'150': varRef(sanaBrandNeutral['150']),
|
|
55
|
+
'200': varRef(canvas_tokens_web_1.brand.neutral200),
|
|
56
|
+
'300': varRef(canvas_tokens_web_1.brand.neutral300),
|
|
57
|
+
'400': varRef(canvas_tokens_web_1.brand.neutral400),
|
|
58
|
+
'500': varRef(canvas_tokens_web_1.brand.neutral500),
|
|
59
|
+
'600': varRef(canvas_tokens_web_1.brand.neutral600),
|
|
60
|
+
'700': varRef(canvas_tokens_web_1.brand.neutral700),
|
|
61
|
+
'800': varRef(canvas_tokens_web_1.brand.neutral800),
|
|
62
|
+
'850': varRef(sanaBrandNeutral['850']),
|
|
63
|
+
'900': varRef(canvas_tokens_web_1.brand.neutral900),
|
|
64
|
+
'950': varRef(canvas_tokens_web_1.brand.neutral950),
|
|
65
|
+
'975': varRef(canvas_tokens_web_1.brand.neutral975),
|
|
66
|
+
A25: varRef(canvas_tokens_web_1.brand.neutralA25),
|
|
67
|
+
A50: varRef(canvas_tokens_web_1.brand.neutralA50),
|
|
68
|
+
A100: varRef(canvas_tokens_web_1.brand.neutralA100),
|
|
69
|
+
A150: varRef(sanaBrandNeutral.A150),
|
|
70
|
+
A200: varRef(canvas_tokens_web_1.brand.neutralA200),
|
|
71
|
+
},
|
|
72
|
+
primary: {
|
|
73
|
+
'500': varRef(canvas_tokens_web_1.brand.primary500),
|
|
74
|
+
'600': varRef(canvas_tokens_web_1.brand.primary600),
|
|
75
|
+
'700': varRef(canvas_tokens_web_1.brand.primary700),
|
|
76
|
+
A25: varRef(canvas_tokens_web_1.brand.primaryA25),
|
|
77
|
+
A50: varRef(canvas_tokens_web_1.brand.primaryA50),
|
|
78
|
+
A100: varRef(canvas_tokens_web_1.brand.primaryA100),
|
|
79
|
+
},
|
|
80
|
+
critical: {
|
|
81
|
+
'500': varRef(canvas_tokens_web_1.brand.critical500),
|
|
82
|
+
'600': varRef(canvas_tokens_web_1.brand.critical600),
|
|
83
|
+
'700': varRef(canvas_tokens_web_1.brand.critical700),
|
|
84
|
+
A25: varRef(canvas_tokens_web_1.brand.criticalA25),
|
|
85
|
+
A50: varRef(canvas_tokens_web_1.brand.criticalA50),
|
|
86
|
+
},
|
|
87
|
+
caution: {
|
|
88
|
+
'400': varRef(canvas_tokens_web_1.brand.caution400),
|
|
89
|
+
'500': varRef(canvas_tokens_web_1.brand.caution500),
|
|
90
|
+
A25: varRef(canvas_tokens_web_1.brand.cautionA25),
|
|
91
|
+
A50: varRef(canvas_tokens_web_1.brand.cautionA50),
|
|
92
|
+
},
|
|
93
|
+
positive: {
|
|
94
|
+
'600': varRef(canvas_tokens_web_1.brand.positive600),
|
|
95
|
+
'800': varRef(canvas_tokens_web_1.brand.positive800),
|
|
96
|
+
A25: varRef(canvas_tokens_web_1.brand.positiveA25),
|
|
97
|
+
A50: varRef(canvas_tokens_web_1.brand.positiveA50),
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
selected: {
|
|
101
|
+
fg: varRef(canvas_tokens_web_1.brand.neutralA900),
|
|
102
|
+
surface: varRef(canvas_tokens_web_1.brand.neutralA100),
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Pass to root `CanvasProvider` to forward Sana brand CSS variables onto popup containers
|
|
107
|
+
* (menus, selects, modals, tooltips).
|
|
108
|
+
*
|
|
109
|
+
* **When to use it**
|
|
110
|
+
* - **Required** when you cannot set `data-theme="sana-canvas"` on `<html>` (embedded apps,
|
|
111
|
+
* microfrontends, third-party shells). Popups portal to `document.body` and will not inherit
|
|
112
|
+
* a nested `data-theme` — this preset copies Sana brand vars onto the popup stack container.
|
|
113
|
+
* - Also useful in tests without global Sana CSS, or custom popup hosts outside normal cascade.
|
|
114
|
+
*
|
|
115
|
+
* **When you can skip it**
|
|
116
|
+
* - Prefer setting `data-theme="sana-canvas"` on `<html>` with Sana CSS imported. Popups then
|
|
117
|
+
* inherit brand variables from the document and no `theme` prop is needed.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```tsx
|
|
121
|
+
* // Preferred — control <html>
|
|
122
|
+
* import '@workday/canvas-tokens-web/css/sana/_variables.css';
|
|
123
|
+
* // <html data-theme="sana-canvas">
|
|
124
|
+
* <CanvasProvider><App /></CanvasProvider>
|
|
125
|
+
*
|
|
126
|
+
* // No access to <html> — required for popup parity
|
|
127
|
+
* <CanvasProvider theme={sanaCanvasProviderTheme}><App /></CanvasProvider>
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
exports.sanaCanvasProviderTheme = exports.sanaCanvasNumericalTheme;
|
|
@@ -273,5 +273,167 @@ declare module '@emotion/react' {
|
|
|
273
273
|
export type EmotionCanvasTheme = {
|
|
274
274
|
canvas: CanvasTheme;
|
|
275
275
|
};
|
|
276
|
+
/**
|
|
277
|
+
* Numerical brand ramp keys. Each key maps 1:1 to a `--cnvs-brand-{family}-{key}` CSS variable.
|
|
278
|
+
*
|
|
279
|
+
* Common keys:
|
|
280
|
+
* - `'600'` — main accent / button fill / default brand fg
|
|
281
|
+
* - `'700'` — strong fg / selected text (when not using `selected.fg`)
|
|
282
|
+
* - `'500'` — focus rings and border primary (independent of `'600'`)
|
|
283
|
+
* - `'A50'` — selected surface tint (when not using `selected.surface`)
|
|
284
|
+
* - `'25'` / `'A25'` — subtle brand surfaces
|
|
285
|
+
*
|
|
286
|
+
* Neutral-only Sana steps (`'150'`, `'850'`, `'A150'`) live on {@link CanvasNeutralBrandRamp}.
|
|
287
|
+
*/
|
|
288
|
+
export type CanvasBrandRamp = Partial<Record<'25' | '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950' | '975' | 'A25' | 'A50' | 'A100' | 'A200', string>>;
|
|
289
|
+
/**
|
|
290
|
+
* Neutral brand ramp — includes Sana-only steps (`150` / `850` / `A150`) that are not
|
|
291
|
+
* exported for primary/critical/caution/positive families.
|
|
292
|
+
*/
|
|
293
|
+
export type CanvasNeutralBrandRamp = CanvasBrandRamp & Partial<Record<'150' | '850' | 'A150', string>>;
|
|
294
|
+
/** Semantic keys for `brand.action.*` CSS variables (PrimaryButton, etc.). */
|
|
295
|
+
export type CanvasActionBrandRamp = Partial<Record<'base' | 'lightest' | 'lighter' | 'light' | 'dark' | 'darkest' | 'darker' | 'accent', string>>;
|
|
296
|
+
/**
|
|
297
|
+
* Controls how partial theme input is expanded.
|
|
298
|
+
*
|
|
299
|
+
* - `'brand'` (default): predictable, design-aligned behavior. Setting only
|
|
300
|
+
* `brand.primary['600']` themes PrimaryButton and selected list/menu
|
|
301
|
+
* states. Other keys write only their CSS variable — no auto-generated ramps.
|
|
302
|
+
* - `'full'`: legacy behavior for the deprecated `canvas.palette` shape — auto-fills
|
|
303
|
+
* lightest→darkest via `shiftColor` and forwards to many `system.color.brand.*`
|
|
304
|
+
* tokens. On the numerical `brand` shape, `'full'` disables the primary shortcut
|
|
305
|
+
* and writes each ramp key literally.
|
|
306
|
+
*/
|
|
307
|
+
export type CanvasThemingScope = 'brand' | 'full';
|
|
308
|
+
/**
|
|
309
|
+
* Preferred theme input for `CanvasProvider`. Each value maps directly to brand CSS
|
|
310
|
+
* variables unless noted as a shortcut below.
|
|
311
|
+
*
|
|
312
|
+
* @example Minimal — brand buttons + selected states only
|
|
313
|
+
* ```tsx
|
|
314
|
+
* <CanvasProvider theme={{brand: {primary: {'600': base.magenta600}}}} />
|
|
315
|
+
* ```
|
|
316
|
+
*
|
|
317
|
+
* @example Explicit — focus independent of primary
|
|
318
|
+
* ```tsx
|
|
319
|
+
* <CanvasProvider theme={{
|
|
320
|
+
* brand: {primary: {'600': base.red600, '500': base.blue500}},
|
|
321
|
+
* selected: {fg: base.red700, surface: base.redA50},
|
|
322
|
+
* }} />
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @see sanaCanvasProviderTheme when `<html>` is unavailable and popups need Sana brand forwarding
|
|
326
|
+
*/
|
|
327
|
+
export interface CanvasNumericalBrandTheme {
|
|
328
|
+
brand?: {
|
|
329
|
+
/**
|
|
330
|
+
* Primary brand ramp (`--cnvs-brand-primary-*`).
|
|
331
|
+
*
|
|
332
|
+
* **Shortcut (brand scope only):** when `'600'` is the only key under `primary`,
|
|
333
|
+
* also sets:
|
|
334
|
+
* - `PrimaryButton` — `brand.action.base`, `accent.primary`, `accent.action`
|
|
335
|
+
* - Selected `Menu.Item` — `system.color.brand.fg.selected`, `surface.selected`
|
|
336
|
+
*
|
|
337
|
+
* Does **not** set focus rings — use `'500'` or `canvas.palette.common.focusOutline`.
|
|
338
|
+
*
|
|
339
|
+
* | Key | CSS variable | Typical consumers |
|
|
340
|
+
* |-----|--------------|-------------------|
|
|
341
|
+
* | `'600'` | `--cnvs-brand-primary-600` | PrimaryButton, brand links, accent.primary |
|
|
342
|
+
* | `'700'` | `--cnvs-brand-primary-700` | Strong primary fg, selected text |
|
|
343
|
+
* | `'500'` | `--cnvs-brand-primary-500` | Focus rings, border primary |
|
|
344
|
+
* | `'A50'` | `--cnvs-brand-primary-A50` | Selected/hover surfaces |
|
|
345
|
+
*/
|
|
346
|
+
primary?: CanvasBrandRamp;
|
|
347
|
+
/**
|
|
348
|
+
* Button-specific ramp (`--cnvs-brand-action-*`). PrimaryButton reads
|
|
349
|
+
* these **before** `brand.primary`.
|
|
350
|
+
*
|
|
351
|
+
* | Key | Typical consumers |
|
|
352
|
+
* |-----|-------------------|
|
|
353
|
+
* | `base` | PrimaryButton background |
|
|
354
|
+
* | `dark` / `darkest` | PrimaryButton hover / pressed |
|
|
355
|
+
* | `accent` | PrimaryButton label color |
|
|
356
|
+
*/
|
|
357
|
+
action?: CanvasActionBrandRamp;
|
|
358
|
+
/**
|
|
359
|
+
* Critical/error ramp (`--cnvs-brand-critical-*`).
|
|
360
|
+
*
|
|
361
|
+
* | Key | Typical consumers |
|
|
362
|
+
* |-----|-------------------|
|
|
363
|
+
* | `'600'` | TextInput error, DeleteButton, critical fg |
|
|
364
|
+
* | `'500'` | Critical focus ring, error border |
|
|
365
|
+
* | `'A25'` / `'A50'` | Error surface tints |
|
|
366
|
+
*/
|
|
367
|
+
critical?: CanvasBrandRamp;
|
|
368
|
+
/**
|
|
369
|
+
* Caution/warning ramp (`--cnvs-brand-caution-*`).
|
|
370
|
+
*
|
|
371
|
+
* | Key | Typical consumers |
|
|
372
|
+
* |-----|-------------------|
|
|
373
|
+
* | `'400'` | Caution accent, TextInput caution |
|
|
374
|
+
* | `'500'` | Caution focus outer, caution border |
|
|
375
|
+
* | `'A25'` / `'A50'` | Caution surface tints |
|
|
376
|
+
*/
|
|
377
|
+
caution?: CanvasBrandRamp;
|
|
378
|
+
/**
|
|
379
|
+
* Positive/success ramp (`--cnvs-brand-positive-*`).
|
|
380
|
+
*
|
|
381
|
+
* | Key | Typical consumers |
|
|
382
|
+
* |-----|-------------------|
|
|
383
|
+
* | `'600'` | Checkbox/Radio checked, success fg |
|
|
384
|
+
* | `'A25'` / `'A50'` | Success surface tints |
|
|
385
|
+
*/
|
|
386
|
+
positive?: CanvasBrandRamp;
|
|
387
|
+
/**
|
|
388
|
+
* Neutral brand ramp (`--cnvs-brand-neutral-*`). Sana Canvas uses `base.neutral*`
|
|
389
|
+
* instead of legacy `base.slate*` — see {@link sanaCanvasNumericalTheme}.
|
|
390
|
+
*
|
|
391
|
+
* Affects brand-neutral text, borders, and surfaces where components reference
|
|
392
|
+
* `brand.neutral.*` or `system.color.brand` tokens tied to neutral.
|
|
393
|
+
*/
|
|
394
|
+
neutral?: CanvasNeutralBrandRamp;
|
|
395
|
+
};
|
|
396
|
+
/**
|
|
397
|
+
* Selected-state shortcuts. Prefer these over indirect `brand.primary['700']` /
|
|
398
|
+
* `brand.primary.A50` when customizing list/menu selection.
|
|
399
|
+
*
|
|
400
|
+
* | Key | CSS variable | Typical consumers |
|
|
401
|
+
* |-----|--------------|-------------------|
|
|
402
|
+
* | `fg` | `--cnvs-sys-color-brand-fg-selected` | Menu.Item, SegmentedControl selected text |
|
|
403
|
+
* | `surface` | `--cnvs-sys-color-brand-surface-selected` | Menu.Item, list selected background |
|
|
404
|
+
*/
|
|
405
|
+
selected?: {
|
|
406
|
+
/** Selected text/icon color */
|
|
407
|
+
fg?: string;
|
|
408
|
+
/** Selected row/chip background */
|
|
409
|
+
surface?: string;
|
|
410
|
+
};
|
|
411
|
+
/**
|
|
412
|
+
* Escape hatch for `system.color.brand.*` tokens not covered by `brand` ramps.
|
|
413
|
+
* Keys mirror the token path, e.g. `{color: {brand: {focus: {primary: '#00f'}}}}`.
|
|
414
|
+
*/
|
|
415
|
+
system?: {
|
|
416
|
+
color?: {
|
|
417
|
+
brand?: Record<string, unknown>;
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
/** Text direction for the provider subtree. */
|
|
421
|
+
direction?: ContentDirection;
|
|
422
|
+
/**
|
|
423
|
+
* @default 'brand'
|
|
424
|
+
* @see CanvasThemingScope
|
|
425
|
+
*/
|
|
426
|
+
themeScope?: CanvasThemingScope;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Theme input accepted by {@link CanvasProvider}.
|
|
430
|
+
* - Numerical `brand` shape (preferred)
|
|
431
|
+
* - Deprecated `canvas.palette` shape (legacy)
|
|
432
|
+
*/
|
|
433
|
+
export type CanvasProviderTheme = (PartialEmotionCanvasTheme & {
|
|
434
|
+
themeScope?: CanvasThemingScope;
|
|
435
|
+
}) | CanvasNumericalBrandTheme;
|
|
436
|
+
export declare function isNumericalTheme(theme: CanvasProviderTheme | undefined): theme is CanvasNumericalBrandTheme;
|
|
437
|
+
export declare function resolveThemingScope(theme: CanvasProviderTheme | undefined): CanvasThemingScope;
|
|
276
438
|
export {};
|
|
277
439
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAEnE;;GAEG;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,oBAAY,gBAAgB;IAC1B,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE;QACP,MAAM,EAAE,wBAAwB,CAAC;QACjC,OAAO,EAAE,kBAAkB,CAAC;QAC5B,KAAK,EAAE,kBAAkB,CAAC;QAC1B,KAAK,EAAE,kBAAkB,CAAC;QAC1B,OAAO,EAAE,kBAAkB,CAAC;QAC5B,OAAO,EAAE,kBAAkB,CAAC;KAC7B,CAAC;IACF;;;;;;;;OAQG;IACH,WAAW,EAAE;QACX;;;;;;;;;;;;;;;;;;;;;WAqBG;QACH,MAAM,EAAE,iBAAiB,CAAC;QAC1B;;;;;;;;;;;;;;;;;;;;;;WAsBG;QACH,EAAE,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,MAAM,CAA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;CACjC;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B,CAAC,yBAAyB,GAAG;IAAC,UAAU,CAAC,EAAE,kBAAkB,CAAA;CAAC,CAAC,GAC/D,yBAAyB,CAAC;AAE9B,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,mBAAmB,GAAG,SAAS,GACrC,KAAK,IAAI,yBAAyB,CAepC;AA6BD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,GAAG,kBAAkB,CA0C9F"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContentDirection = void 0;
|
|
3
|
+
exports.resolveThemingScope = exports.isNumericalTheme = exports.ContentDirection = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Direction of page content for internationalization
|
|
6
6
|
* @deprecated ⚠️ `ContentDirection` is deprecated. Use the `:dir()` CSS pseudo-class selector and CSS logical properties instead. For more information, see [MDN :dir()](https://developer.mozilla.org/en-US/docs/Web/CSS/:dir) and [CSS Logical Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values).
|
|
@@ -10,3 +10,83 @@ var ContentDirection;
|
|
|
10
10
|
ContentDirection["LTR"] = "ltr";
|
|
11
11
|
ContentDirection["RTL"] = "rtl";
|
|
12
12
|
})(ContentDirection = exports.ContentDirection || (exports.ContentDirection = {}));
|
|
13
|
+
function isNumericalTheme(theme) {
|
|
14
|
+
if (!theme) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if ('canvas' in theme) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
// `direction` / `themeScope` alone are valid numerical themes (e.g. RTL-only).
|
|
21
|
+
return ('brand' in theme ||
|
|
22
|
+
'system' in theme ||
|
|
23
|
+
'selected' in theme ||
|
|
24
|
+
'direction' in theme ||
|
|
25
|
+
'themeScope' in theme);
|
|
26
|
+
}
|
|
27
|
+
exports.isNumericalTheme = isNumericalTheme;
|
|
28
|
+
const EXTENDED_RAMP_KEYS = new Set([
|
|
29
|
+
'25',
|
|
30
|
+
'50',
|
|
31
|
+
'100',
|
|
32
|
+
'200',
|
|
33
|
+
'300',
|
|
34
|
+
'400',
|
|
35
|
+
'500',
|
|
36
|
+
'600',
|
|
37
|
+
'700',
|
|
38
|
+
'800',
|
|
39
|
+
'900',
|
|
40
|
+
'950',
|
|
41
|
+
'975',
|
|
42
|
+
'A25',
|
|
43
|
+
'A50',
|
|
44
|
+
'A100',
|
|
45
|
+
'A200',
|
|
46
|
+
'lightest',
|
|
47
|
+
'lighter',
|
|
48
|
+
'light',
|
|
49
|
+
'main',
|
|
50
|
+
'dark',
|
|
51
|
+
'darkest',
|
|
52
|
+
'contrast',
|
|
53
|
+
]);
|
|
54
|
+
function resolveThemingScope(theme) {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
if (!theme) {
|
|
57
|
+
return 'brand';
|
|
58
|
+
}
|
|
59
|
+
if (theme.themeScope) {
|
|
60
|
+
return theme.themeScope;
|
|
61
|
+
}
|
|
62
|
+
if (isNumericalTheme(theme)) {
|
|
63
|
+
return (_a = theme.themeScope) !== null && _a !== void 0 ? _a : 'brand';
|
|
64
|
+
}
|
|
65
|
+
const palette = (_b = theme.canvas) === null || _b === void 0 ? void 0 : _b.palette;
|
|
66
|
+
if (!palette) {
|
|
67
|
+
return 'brand';
|
|
68
|
+
}
|
|
69
|
+
if (palette.common && Object.keys(palette.common).length > 0) {
|
|
70
|
+
const commonOnlyFocus = Object.keys(palette.common).length === 1 && palette.common.focusOutline != null;
|
|
71
|
+
if (!commonOnlyFocus) {
|
|
72
|
+
return 'full';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
for (const color of ['primary', 'error', 'alert', 'success', 'neutral']) {
|
|
76
|
+
const colorPalette = palette[color];
|
|
77
|
+
if (!colorPalette) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
for (const key of Object.keys(colorPalette)) {
|
|
81
|
+
// `main` alone uses brand-scope bundles for every semantic palette color.
|
|
82
|
+
if (key === 'main') {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (EXTENDED_RAMP_KEYS.has(key)) {
|
|
86
|
+
return 'full';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return 'brand';
|
|
91
|
+
}
|
|
92
|
+
exports.resolveThemingScope = resolveThemingScope;
|
|
@@ -15,7 +15,7 @@ export declare const pillStencil: import("@workday/canvas-kit-styling").Stencil<
|
|
|
15
15
|
variant: {
|
|
16
16
|
readOnly: {
|
|
17
17
|
[x: string]: string | {
|
|
18
|
-
[x: string]: "var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)))"
|
|
18
|
+
[x: string]: "--cnvs-sys-color-bg-default" | "var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)))";
|
|
19
19
|
borderColor: "var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)))";
|
|
20
20
|
} | {
|
|
21
21
|
[x: string]: "--cnvs-sys-color-bg-default";
|
|
@@ -24,7 +24,7 @@ export declare const pillStencil: import("@workday/canvas-kit-styling").Stencil<
|
|
|
24
24
|
border: string;
|
|
25
25
|
cursor: string;
|
|
26
26
|
'&:hover, &.hover': {
|
|
27
|
-
[x: string]: "var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)))"
|
|
27
|
+
[x: string]: "--cnvs-sys-color-bg-default" | "var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)))";
|
|
28
28
|
borderColor: "var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)))";
|
|
29
29
|
};
|
|
30
30
|
'&:focus-visible, &.focus': {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePopupStack.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/usePopupStack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePopupStack.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/usePopupStack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,aAAa,mEAEf,WAAW,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAClD,MAAM,SAAS,CAAC,WAAW,CA2F7B,CAAC"}
|
|
@@ -4,8 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.usePopupStack = void 0;
|
|
7
|
-
const react_1 = require("
|
|
8
|
-
const react_2 = __importDefault(require("react"));
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
9
8
|
const canvas_kit_popup_stack_1 = require("@workday/canvas-kit-popup-stack");
|
|
10
9
|
const common_1 = require("@workday/canvas-kit-react/common");
|
|
11
10
|
/**
|
|
@@ -52,11 +51,11 @@ const common_1 = require("@workday/canvas-kit-react/common");
|
|
|
52
51
|
*/
|
|
53
52
|
const usePopupStack = (ref, target) => {
|
|
54
53
|
const { elementRef, localRef } = (0, common_1.useLocalRef)(ref);
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
const firstLoadRef =
|
|
54
|
+
// Read brand style from the context provided by CanvasProvider
|
|
55
|
+
const style = react_1.default.useContext(common_1.CanvasBrandStyleContext);
|
|
56
|
+
const firstLoadRef = react_1.default.useRef(true); // React 19 can call a useState more than once, so we need to track if we've already created a container
|
|
58
57
|
// useState function input ensures we only create a container once.
|
|
59
|
-
const [popupRef] =
|
|
58
|
+
const [popupRef] = react_1.default.useState(() => {
|
|
60
59
|
if (firstLoadRef.current) {
|
|
61
60
|
const container = canvas_kit_popup_stack_1.PopupStack.createContainer();
|
|
62
61
|
elementRef(container);
|
|
@@ -65,22 +64,25 @@ const usePopupStack = (ref, target) => {
|
|
|
65
64
|
}
|
|
66
65
|
return localRef.current;
|
|
67
66
|
});
|
|
68
|
-
// Forward only
|
|
69
|
-
// CanvasProvider
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
|
|
67
|
+
// Forward only CSS custom properties to the popup container when a theme was provided via
|
|
68
|
+
// CanvasProvider. We do NOT apply defaultBranding (className) so we don't create a cascade
|
|
69
|
+
// barrier. Filter to `--*` keys and string values so consumer layout styles from the provider
|
|
70
|
+
// are not copied onto the popup stack. Runs before PopupStack.add to avoid a theme flash.
|
|
71
|
+
react_1.default.useLayoutEffect(() => {
|
|
73
72
|
const element = localRef.current;
|
|
74
73
|
if (!element) {
|
|
75
74
|
return undefined;
|
|
76
75
|
}
|
|
77
|
-
const styleKeys = Object.keys(style);
|
|
76
|
+
const styleKeys = Object.keys(style).filter(key => key.startsWith('--'));
|
|
78
77
|
if (styleKeys.length === 0) {
|
|
79
78
|
return undefined;
|
|
80
79
|
}
|
|
81
80
|
for (const key of styleKeys) {
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const value = style[key];
|
|
82
|
+
if (typeof value !== 'string') {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
element.style.setProperty(key, value);
|
|
84
86
|
}
|
|
85
87
|
// No cleanup: leave theme on container so reopening doesn't flash
|
|
86
88
|
return undefined;
|
|
@@ -88,7 +90,7 @@ const usePopupStack = (ref, target) => {
|
|
|
88
90
|
// We useLayoutEffect to ensure proper timing of registration of the element to the popup stack.
|
|
89
91
|
// Without this, the timing is unpredictable when mixed with other frameworks. Other frameworks
|
|
90
92
|
// should also register as soon as the element is available
|
|
91
|
-
|
|
93
|
+
react_1.default.useLayoutEffect(() => {
|
|
92
94
|
if (popupRef !== localRef.current) {
|
|
93
95
|
throw Error(`The 'ref' passed to usePopupStack should not be applied to a React element. This will cause a runtime error where the PopupStack and React compete for the element. Instead use ReactDOM.createPortal(<YourComponent />, ref.current)`);
|
|
94
96
|
}
|
|
@@ -108,7 +110,7 @@ const usePopupStack = (ref, target) => {
|
|
|
108
110
|
// Popup.Target), find the nearest element with a `dir` attribute: start from the focused element
|
|
109
111
|
// (the trigger) or body, then use closest('[dir]'). Prefer reading getAttribute('dir') when
|
|
110
112
|
// present to avoid getComputedStyle.
|
|
111
|
-
|
|
113
|
+
react_1.default.useLayoutEffect(() => {
|
|
112
114
|
var _a, _b, _c;
|
|
113
115
|
const targetEl = target ? ('current' in target ? target.current : target) : undefined;
|
|
114
116
|
let elementToCheck = targetEl !== null && targetEl !== void 0 ? targetEl : undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { CanvasProviderTheme, StyleRewriteFn } from '@workday/canvas-kit-react/common';
|
|
3
3
|
export declare const convertToStaticStates: StyleRewriteFn;
|
|
4
4
|
export declare const StaticStates: React.FC<React.PropsWithChildren<{
|
|
5
|
-
theme?:
|
|
5
|
+
theme?: CanvasProviderTheme;
|
|
6
6
|
className?: React.HTMLAttributes<HTMLElement>['className'];
|
|
7
7
|
} & React.HTMLAttributes<HTMLElement>>>;
|
|
8
8
|
//# sourceMappingURL=StaticStates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticStates.d.ts","sourceRoot":"","sources":["../../../../testing/lib/StaticStates.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StaticStates.d.ts","sourceRoot":"","sources":["../../../../testing/lib/StaticStates.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEL,mBAAmB,EAGnB,cAAc,EAGf,MAAM,kCAAkC,CAAC;AAG1C,eAAO,MAAM,qBAAqB,EAAE,cAoBnC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CACjC,KAAK,CAAC,iBAAiB,CACrB;IACE,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,SAAS,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC;CAC5D,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CACtC,CAcF,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StaticStates = exports.convertToStaticStates = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@emotion/react");
|
|
5
6
|
const common_1 = require("@workday/canvas-kit-react/common");
|
|
6
7
|
const convertToStaticStates = obj => {
|
|
7
8
|
if (!obj) {
|
|
@@ -23,8 +24,10 @@ const convertToStaticStates = obj => {
|
|
|
23
24
|
};
|
|
24
25
|
exports.convertToStaticStates = convertToStaticStates;
|
|
25
26
|
const StaticStates = ({ children, theme, className, ...elemProps }) => {
|
|
26
|
-
const localTheme = (0, common_1.useTheme)(theme);
|
|
27
|
+
const localTheme = (0, common_1.useTheme)(theme && !(0, common_1.isNumericalTheme)(theme) ? theme : undefined);
|
|
27
28
|
localTheme._styleRewriteFn = exports.convertToStaticStates;
|
|
28
|
-
|
|
29
|
+
// Nest ThemeProvider *inside* CanvasProvider so CanvasProvider's own ThemeProvider
|
|
30
|
+
// (used for legacy Emotion theme consumers) does not wipe `_styleRewriteFn`.
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(common_1.CanvasProvider, { className: className, ...elemProps, theme: theme, children: (0, jsx_runtime_1.jsx)(react_1.ThemeProvider, { theme: localTheme, children: children }) }));
|
|
29
32
|
};
|
|
30
33
|
exports.StaticStates = StaticStates;
|