reshaped 3.0.9 → 3.0.10
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/CHANGELOG.md +6 -0
- package/bin/cli.js +0 -1
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +3 -1
- package/dist/bundle.js +10 -10
- package/dist/cjs/themes/_generator/utilities/color.d.ts +16 -0
- package/dist/cjs/themes/_generator/utilities/color.js +57 -7
- package/dist/cjs/themes/_generator/utilities/generateBackgroundColors.js +4 -0
- package/dist/cjs/themes/_generator/utilities/tests/color.test.js +73 -42
- package/dist/cjs/themes/index.d.ts +17 -0
- package/dist/cjs/themes/index.js +3 -0
- package/dist/cjs/types/config.d.ts +1 -0
- package/dist/components/Button/Button.module.css +1 -1
- package/dist/components/Button/tests/Button.stories.js +3 -1
- package/dist/components/DropdownMenu/DropdownMenu.module.css +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +1 -1
- package/dist/components/Modal/Modal.js +4 -3
- package/dist/components/Modal/tests/Modal.stories.d.ts +0 -1
- package/dist/components/Modal/tests/Modal.stories.js +0 -16
- package/dist/components/Overlay/Overlay.js +7 -7
- package/dist/components/Overlay/tests/Overlay.stories.js +3 -1
- package/dist/components/Popover/Popover.js +2 -2
- package/dist/components/Popover/Popover.types.d.ts +1 -1
- package/dist/components/Resizable/Resizable.d.ts +8 -0
- package/dist/components/Resizable/Resizable.js +149 -0
- package/dist/components/Resizable/Resizable.module.css +1 -0
- package/dist/components/Resizable/Resizable.types.d.ts +29 -0
- package/dist/components/Resizable/Resizable.types.js +1 -0
- package/dist/components/Resizable/index.d.ts +2 -0
- package/dist/components/Resizable/index.js +1 -0
- package/dist/components/Resizable/tests/Resizable.stories.d.ts +15 -0
- package/dist/components/Resizable/tests/Resizable.stories.js +58 -0
- package/dist/components/ScrollArea/ScrollArea.js +4 -4
- package/dist/components/Slider/Slider.types.d.ts +2 -2
- package/dist/components/Slider/Slider.utilities.js +4 -4
- package/dist/components/Slider/SliderControlled.js +11 -9
- package/dist/components/Slider/SliderThumb.js +1 -1
- package/dist/components/Slider/tests/Slider.stories.js +4 -0
- package/dist/components/Toast/Toast.types.d.ts +7 -6
- package/dist/components/Toast/index.d.ts +1 -1
- package/dist/components/Toast/useToast.d.ts +1 -1
- package/dist/components/Tooltip/tests/Tooltip.stories.js +31 -0
- package/dist/components/_private/Flyout/Flyout.context.d.ts +3 -1
- package/dist/components/_private/Flyout/Flyout.context.js +4 -1
- package/dist/components/_private/Flyout/Flyout.types.d.ts +1 -0
- package/dist/components/_private/Flyout/FlyoutContent.js +5 -7
- package/dist/components/_private/Flyout/FlyoutControlled.js +18 -12
- package/dist/components/_private/Flyout/FlyoutTrigger.js +3 -2
- package/dist/components/_private/Flyout/tests/Flyout.stories.d.ts +2 -7
- package/dist/components/_private/Flyout/tests/Flyout.stories.js +87 -38
- package/dist/components/_private/Portal/Portal.module.css +1 -1
- package/dist/hooks/_private/useOnClickOutside.js +5 -3
- package/dist/hooks/tests/useDrag.stories.d.ts +6 -0
- package/dist/hooks/tests/useDrag.stories.js +29 -0
- package/dist/hooks/useDrag.d.ts +17 -0
- package/dist/hooks/useDrag.js +116 -0
- package/dist/hooks/useHandlerRef.d.ts +8 -0
- package/dist/hooks/useHandlerRef.js +16 -0
- package/dist/hooks/useScrollLock.js +4 -3
- package/dist/hooks/useToggle.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/themes/_generator/tests/themes.stories.js +23 -0
- package/dist/themes/_generator/utilities/color.d.ts +16 -0
- package/dist/themes/_generator/utilities/color.js +54 -6
- package/dist/themes/_generator/utilities/generateBackgroundColors.js +4 -0
- package/dist/themes/index.d.ts +17 -0
- package/dist/themes/index.js +3 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/global.d.ts +1 -1
- package/package.json +1 -1
@@ -81,9 +81,25 @@ export declare const getDarkModeColor: (hsl: HslColor) => {
|
|
81
81
|
};
|
82
82
|
export declare const getLuminanceDelta: (luminance: number) => number;
|
83
83
|
export declare function getRgbLuminance({ r, g, b }: RgbColor): number;
|
84
|
+
export declare const getOnColorWCAG: (args: {
|
85
|
+
bgHexColor: string;
|
86
|
+
lightHexColor?: string;
|
87
|
+
darkHexColor?: string;
|
88
|
+
}) => string;
|
89
|
+
export declare const getOnColorAPCA: (args: {
|
90
|
+
bgHexColor: string;
|
91
|
+
mode: "light" | "dark";
|
92
|
+
lightHexColor?: string;
|
93
|
+
darkHexColor?: string;
|
94
|
+
}) => string;
|
95
|
+
/**
|
96
|
+
* On color resolver
|
97
|
+
*/
|
84
98
|
export declare const getOnColor: (args: {
|
85
99
|
bgHexColor: string;
|
86
100
|
lightHexColor?: string;
|
87
101
|
darkHexColor?: string;
|
102
|
+
mode: "light" | "dark";
|
103
|
+
algorithm?: "wcag" | "apca";
|
88
104
|
}) => string;
|
89
105
|
export {};
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* They have been rewritten for easier color transformations in the theme generation case
|
5
5
|
*/
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
-
exports.getOnColor = exports.getLuminanceDelta = exports.getDarkModeColor = exports.hslToHex = exports.hexToHsluv = exports.hexToHsl = exports.hsluvToHex = exports.hsluvToLch = exports.lchToHsluv = exports.lchToLuv = exports.luvToLch = exports.luvToXyz = exports.xyzToLuv = exports.lToY = exports.yToL = exports.xyzToRgb = exports.rgbToXyz = exports.fromLinear = exports.toLinear = exports.rgbToHex = exports.hslToRgb = exports.rgbToHsl = exports.calcMaxChromaHsluv = exports.distanceFromOriginAngle = exports.calculateBoundingLines = void 0;
|
7
|
+
exports.getOnColor = exports.getOnColorAPCA = exports.getOnColorWCAG = exports.getLuminanceDelta = exports.getDarkModeColor = exports.hslToHex = exports.hexToHsluv = exports.hexToHsl = exports.hsluvToHex = exports.hsluvToLch = exports.lchToHsluv = exports.lchToLuv = exports.luvToLch = exports.luvToXyz = exports.xyzToLuv = exports.lToY = exports.yToL = exports.xyzToRgb = exports.rgbToXyz = exports.fromLinear = exports.toLinear = exports.rgbToHex = exports.hslToRgb = exports.rgbToHsl = exports.calcMaxChromaHsluv = exports.distanceFromOriginAngle = exports.calculateBoundingLines = void 0;
|
8
8
|
exports.hexToRgb = hexToRgb;
|
9
9
|
exports.getRgbLuminance = getRgbLuminance;
|
10
10
|
/**
|
@@ -330,30 +330,80 @@ function getRgbLuminance({ r, g, b }) {
|
|
330
330
|
return Math.pow(y, 1 / 3) * 116 - 16;
|
331
331
|
}
|
332
332
|
}
|
333
|
+
/**
|
334
|
+
* WCAG contrast
|
335
|
+
*/
|
333
336
|
const RED = 0.2126;
|
334
337
|
const GREEN = 0.7152;
|
335
338
|
const BLUE = 0.0722;
|
336
339
|
const GAMMA = 2.4;
|
337
|
-
function
|
340
|
+
function luminanceWCAG(r, g, b) {
|
338
341
|
var a = [r, g, b].map((v) => {
|
339
342
|
v /= 255;
|
340
343
|
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, GAMMA);
|
341
344
|
});
|
342
345
|
return a[0] * RED + a[1] * GREEN + a[2] * BLUE;
|
343
346
|
}
|
344
|
-
function
|
345
|
-
var lum1 =
|
346
|
-
var lum2 =
|
347
|
+
function contrastWCAG(rgb1, rgb2) {
|
348
|
+
var lum1 = luminanceWCAG(...rgb1);
|
349
|
+
var lum2 = luminanceWCAG(...rgb2);
|
347
350
|
var brightest = Math.max(lum1, lum2);
|
348
351
|
var darkest = Math.min(lum1, lum2);
|
349
352
|
return (brightest + 0.05) / (darkest + 0.05);
|
350
353
|
}
|
351
|
-
const
|
354
|
+
const getOnColorWCAG = (args) => {
|
352
355
|
const { bgHexColor, lightHexColor = "#ffffff", darkHexColor = "#000000" } = args;
|
353
356
|
const bgRgb = hexToRgb(bgHexColor);
|
354
357
|
const lightRgb = hexToRgb(lightHexColor);
|
355
|
-
return
|
358
|
+
return contrastWCAG([bgRgb.r, bgRgb.g, bgRgb.b], [lightRgb.r, lightRgb.g, lightRgb.b]) > 4.5
|
356
359
|
? lightHexColor
|
357
360
|
: darkHexColor;
|
358
361
|
};
|
362
|
+
exports.getOnColorWCAG = getOnColorWCAG;
|
363
|
+
/**
|
364
|
+
* APCA contrast
|
365
|
+
*/
|
366
|
+
function luminanceAPCA({ r, g, b }) {
|
367
|
+
return (0.2126 * Math.pow(r / 255, 2.2) +
|
368
|
+
0.7152 * Math.pow(g / 255, 2.2) +
|
369
|
+
0.0722 * Math.pow(b / 255, 2.2));
|
370
|
+
}
|
371
|
+
function contrastAPCA(backgroundLuminance, textLuminance) {
|
372
|
+
// Calculate the contrast based on APCA
|
373
|
+
let Lc = textLuminance - backgroundLuminance;
|
374
|
+
return Math.abs(Lc); // Return the absolute value of contrast
|
375
|
+
}
|
376
|
+
const getOnColorAPCA = (args) => {
|
377
|
+
const { bgHexColor, mode, lightHexColor = "#ffffff", darkHexColor = "#000000" } = args;
|
378
|
+
const bgHexAlpha = bgHexColor.slice(7);
|
379
|
+
const bgAlpha = bgHexAlpha ? Number((parseInt(bgHexAlpha, 16) / 255).toFixed(2)) : 1;
|
380
|
+
const bgColor = hexToRgb(bgHexColor.slice(0, 7));
|
381
|
+
const baseColor = mode === "light" ? { r: 255, g: 255, b: 255 } : { r: 0, g: 0, b: 0 };
|
382
|
+
const { r, g, b } = {
|
383
|
+
r: (1 - bgAlpha) * baseColor.r + bgAlpha * bgColor.r,
|
384
|
+
g: (1 - bgAlpha) * baseColor.g + bgAlpha * bgColor.g,
|
385
|
+
b: (1 - bgAlpha) * baseColor.b + bgAlpha * bgColor.b,
|
386
|
+
};
|
387
|
+
// Calculate luminance for background and for white & black
|
388
|
+
let backgroundLuminance = luminanceAPCA({ r, g, b });
|
389
|
+
let whiteLuminance = luminanceAPCA({ r: 255, g: 255, b: 255 });
|
390
|
+
let blackLuminance = luminanceAPCA({ r: 0, g: 0, b: 0 });
|
391
|
+
// Calculate contrast
|
392
|
+
let contrastWithWhite = contrastAPCA(backgroundLuminance, whiteLuminance);
|
393
|
+
let contrastWithBlack = contrastAPCA(backgroundLuminance, blackLuminance);
|
394
|
+
// Choose the color with higher contrast
|
395
|
+
return contrastWithWhite > contrastWithBlack ? lightHexColor : darkHexColor;
|
396
|
+
};
|
397
|
+
exports.getOnColorAPCA = getOnColorAPCA;
|
398
|
+
/**
|
399
|
+
* On color resolver
|
400
|
+
*/
|
401
|
+
const getOnColor = (args) => {
|
402
|
+
if (args.algorithm === "apca") {
|
403
|
+
return (0, exports.getOnColorAPCA)(args);
|
404
|
+
}
|
405
|
+
else {
|
406
|
+
return (0, exports.getOnColorWCAG)(args);
|
407
|
+
}
|
408
|
+
};
|
359
409
|
exports.getOnColor = getOnColor;
|
@@ -31,10 +31,14 @@ const generateBackgroundColors = (definition, themeOptions) => {
|
|
31
31
|
};
|
32
32
|
const hex = (0, color_1.getOnColor)({
|
33
33
|
bgHexColor: bgToken.hex,
|
34
|
+
mode: "light",
|
35
|
+
algorithm: themeOptions?.colorContrastAlgorithm,
|
34
36
|
...onColorHexMap,
|
35
37
|
});
|
36
38
|
const hexDark = (0, color_1.getOnColor)({
|
37
39
|
bgHexColor: bgToken.hexDark || bgToken.hex,
|
40
|
+
mode: "dark",
|
41
|
+
algorithm: themeOptions?.colorContrastAlgorithm,
|
38
42
|
...onColorHexMap,
|
39
43
|
});
|
40
44
|
// eslint-disable-next-line no-param-reassign
|
@@ -2,48 +2,79 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const color_1 = require("../color");
|
4
4
|
describe("cli/utilities/color", () => {
|
5
|
-
|
6
|
-
|
5
|
+
describe("wcag", () => {
|
6
|
+
test("returns white for black background", () => {
|
7
|
+
expect((0, color_1.getOnColor)({ bgHexColor: "#000000", mode: "light" })).toBe("#ffffff");
|
8
|
+
});
|
9
|
+
test("returns white for dark colored background", () => {
|
10
|
+
expect((0, color_1.getOnColor)({ bgHexColor: "#aa0000", mode: "light" })).toBe("#ffffff");
|
11
|
+
});
|
12
|
+
test("returns black for white background", () => {
|
13
|
+
expect((0, color_1.getOnColor)({ bgHexColor: "#ffffff", mode: "light" })).toBe("#000000");
|
14
|
+
});
|
15
|
+
test("returns white for light colored background", () => {
|
16
|
+
expect((0, color_1.getOnColor)({ bgHexColor: "#dedede", mode: "light" })).toBe("#000000");
|
17
|
+
});
|
18
|
+
test("returns #999 for white background", () => {
|
19
|
+
expect((0, color_1.getOnColor)({
|
20
|
+
bgHexColor: "#ffffff",
|
21
|
+
lightHexColor: "#eeeeee",
|
22
|
+
darkHexColor: "#999999",
|
23
|
+
mode: "dark",
|
24
|
+
})).toBe("#999999");
|
25
|
+
});
|
26
|
+
test("returns #eee for black background", () => {
|
27
|
+
expect((0, color_1.getOnColor)({
|
28
|
+
bgHexColor: "#000000",
|
29
|
+
lightHexColor: "#eeeeee",
|
30
|
+
darkHexColor: "#999999",
|
31
|
+
mode: "dark",
|
32
|
+
})).toBe("#eeeeee");
|
33
|
+
});
|
34
|
+
test("returns black for muted green background", () => {
|
35
|
+
expect((0, color_1.getOnColor)({
|
36
|
+
bgHexColor: "#1abc9c",
|
37
|
+
mode: "dark",
|
38
|
+
})).toBe("#000000");
|
39
|
+
});
|
7
40
|
});
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
darkHexColor: "#999999",
|
47
|
-
})).toBe("#eeeeee");
|
41
|
+
describe("apca", () => {
|
42
|
+
test("returns white for black background", () => {
|
43
|
+
expect((0, color_1.getOnColor)({ bgHexColor: "#000000", mode: "light", algorithm: "apca" })).toBe("#ffffff");
|
44
|
+
});
|
45
|
+
test("returns white for dark colored background", () => {
|
46
|
+
expect((0, color_1.getOnColor)({ bgHexColor: "#aa0000", mode: "light", algorithm: "apca" })).toBe("#ffffff");
|
47
|
+
});
|
48
|
+
test("returns black for white background", () => {
|
49
|
+
expect((0, color_1.getOnColor)({ bgHexColor: "#ffffff", mode: "light", algorithm: "apca" })).toBe("#000000");
|
50
|
+
});
|
51
|
+
test("returns white for light colored background", () => {
|
52
|
+
expect((0, color_1.getOnColor)({ bgHexColor: "#dedede", mode: "light", algorithm: "apca" })).toBe("#000000");
|
53
|
+
});
|
54
|
+
test("returns #999 for white background", () => {
|
55
|
+
expect((0, color_1.getOnColor)({
|
56
|
+
bgHexColor: "#ffffff",
|
57
|
+
lightHexColor: "#eeeeee",
|
58
|
+
darkHexColor: "#999999",
|
59
|
+
mode: "dark",
|
60
|
+
algorithm: "apca",
|
61
|
+
})).toBe("#999999");
|
62
|
+
});
|
63
|
+
test("returns #eee for black background", () => {
|
64
|
+
expect((0, color_1.getOnColor)({
|
65
|
+
bgHexColor: "#000000",
|
66
|
+
lightHexColor: "#eeeeee",
|
67
|
+
darkHexColor: "#999999",
|
68
|
+
mode: "dark",
|
69
|
+
algorithm: "apca",
|
70
|
+
})).toBe("#eeeeee");
|
71
|
+
});
|
72
|
+
test("returns white for muted green background", () => {
|
73
|
+
expect((0, color_1.getOnColor)({
|
74
|
+
bgHexColor: "#1abc9c",
|
75
|
+
mode: "dark",
|
76
|
+
algorithm: "apca",
|
77
|
+
})).toBe("#ffffff");
|
78
|
+
});
|
48
79
|
});
|
49
80
|
});
|
@@ -1,5 +1,22 @@
|
|
1
1
|
import type * as T from "./_generator/types";
|
2
2
|
import type { FullThemeDefinition } from "./_generator/tokens/types";
|
3
|
+
/**
|
4
|
+
* Exported types
|
5
|
+
*/
|
6
|
+
export type { FullThemeDefinition } from "./_generator/tokens/types";
|
7
|
+
export type { Name as ColorTokenName } from "./_generator/tokens/color/color.types";
|
8
|
+
export type { Name as DurationTokenName } from "./_generator/tokens/duration/duration.types";
|
9
|
+
export type { Name as EasingTokenName } from "./_generator/tokens/easing/easing.types";
|
10
|
+
export type { Name as FontTokenName } from "./_generator/tokens/font/font.types";
|
11
|
+
export type { Name as FontFamilyTokenName } from "./_generator/tokens/fontFamily/fontFamily.types";
|
12
|
+
export type { Name as FontWeightTokenName } from "./_generator/tokens/fontWeight/fontWeight.types";
|
13
|
+
export type { Name as RadiusTokenName } from "./_generator/tokens/radius/radius.types";
|
14
|
+
export type { Name as ShadowTokenName } from "./_generator/tokens/shadow/shadow.types";
|
15
|
+
export type { GeneratedName as UnitTokenName } from "./_generator/tokens/unit/unit.types";
|
16
|
+
export type { Name as ViewportTokenName } from "./_generator/tokens/viewport/viewport.types";
|
17
|
+
/**
|
18
|
+
* Exported runtime code
|
19
|
+
*/
|
3
20
|
export { default as baseThemeDefinition } from "./_generator/definitions/reshaped";
|
4
21
|
export declare const generateThemeColors: (options: {
|
5
22
|
primary: T.Color;
|
package/dist/cjs/themes/index.js
CHANGED
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getThemeCSS = exports.generateThemeColors = exports.baseThemeDefinition = void 0;
|
7
7
|
const transform_1 = __importDefault(require("./_generator/transform"));
|
8
8
|
const generateColors_1 = __importDefault(require("./_generator/utilities/generateColors"));
|
9
|
+
/**
|
10
|
+
* Exported runtime code
|
11
|
+
*/
|
9
12
|
var reshaped_1 = require("./_generator/definitions/reshaped");
|
10
13
|
Object.defineProperty(exports, "baseThemeDefinition", { enumerable: true, get: function () { return __importDefault(reshaped_1).default; } });
|
11
14
|
const generateThemeColors = (options) => {
|
@@ -1 +1 @@
|
|
1
|
-
.root{--rs-p-v:var(--rs-button-p-v);--rs-p-h:var(--rs-button-p-h);align-items:center;border:var(--rs-button-border-width) solid transparent;border-radius:var(--rs-button-radius);box-sizing:border-box;cursor:pointer;display:inline-flex;justify-content:center;overflow:hidden;padding:calc(var(--rs-unit-x1) - var(--rs-button-border-width)) calc(var(--rs-p-h) - var(--rs-button-border-width));position:relative;text-align:initial;text-decoration:none;transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:background-color,box-shadow,border-color,color,transform;z-index:0;-webkit-tap-highlight-color:transparent;font-family:var(--rs-font-family-body);font-size:var(--rs-button-font-size);font-weight:var(--rs-font-weight-medium);line-height:var(--rs-button-line-height);min-height:calc(var(--rs-button-line-height) + var(--rs-p-v) * 2);min-width:calc(var(--rs-button-line-height) - (var(--rs-unit-x1) * 2) + (var(--rs-button-p-h) * 2))}.root:active{transform:scale(.98)}.root:before{content:"";inset:0;opacity:0;position:absolute;transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:opacity}.text{align-items:center;display:flex;gap:var(--rs-button-gap)}.icon{margin-inline-end:var(--rs-button-gap)}.icon.--icon-position-end{margin-inline-end:0;margin-inline-start:var(--rs-button-gap)}.icon:last-child{margin-inline-end:0}.icon,.text{position:relative;z-index:5}.loader{align-items:center;display:none;inset:0;justify-content:center;position:absolute}.root.--icon-only .icon{margin:0 calc(var(--rs-unit-x1) * -1)}.root.--loading{cursor:default}.root.--loading:active{transform:none}.root.--loading .icon,.root.--loading .text{visibility:hidden}.root.--loading .loader{display:flex}.root.--rounded{border-radius:999px}.--size-small{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width{text-align:center;width:100%}.root.--variant-faded.--color-neutral,.root.--variant-solid.--color-neutral{background-color:var(--rs-color-background-neutral);color:var(--rs-color-on-background-neutral)}.root.--variant-faded.--color-neutral:before,.root.--variant-solid.--color-neutral:before{background-color:var(--rs-color-on-background-neutral)}.root.--variant-faded.--color-neutral.--highlighted:before,.root.--variant-faded.--color-neutral:hover:not(.--loading):before,.root.--variant-solid.--color-neutral.--highlighted:before,.root.--variant-solid.--color-neutral:hover:not(.--loading):before{opacity:.04}.root.--variant-solid{--rs-button-border-width:0px}.root.--variant-solid.--color-primary{background-color:var(--rs-color-background-primary);color:var(--rs-color-on-background-primary)}.root.--variant-solid.--color-primary:before{background-color:var(--rs-color-on-background-primary)}.root.--variant-solid.--color-primary.--highlighted:before,.root.--variant-solid.--color-primary:hover:not(.--loading):before{opacity:.08}.root.--variant-solid.--color-critical{background-color:var(--rs-color-background-critical);color:var(--rs-color-on-background-critical)}.root.--variant-solid.--color-critical:before{background-color:var(--rs-color-on-background-critical)}.root.--variant-solid.--color-critical.--highlighted:before,.root.--variant-solid.--color-critical:hover:not(.--loading):before{opacity:.08}.root.--variant-solid.--color-positive{background-color:var(--rs-color-background-positive);color:var(--rs-color-on-background-positive)}.root.--variant-solid.--color-positive:before{background-color:var(--rs-color-on-background-positive)}.root.--variant-solid.--color-positive.--highlighted:before,.root.--variant-solid.--color-positive:hover:not(.--loading):before{opacity:.08}.root.--variant-solid.--color-media{background-color:var(--rs-color-white);color:var(--rs-color-black)}.root.--variant-solid.--color-media:before{background-color:var(--rs-color-black)}.root.--variant-solid.--color-media.--highlighted:before,.root.--variant-solid.--color-media:hover:not(.--loading,.--disabled):before{opacity:.04}.root.--variant-faded{--rs-button-border-width:0px}.root.--variant-faded.--color-primary{background-color:var(--rs-color-background-primary-faded);color:var(--rs-color-foreground-primary)}.root.--variant-faded.--color-primary:before{background-color:var(--rs-color-foreground-primary)}.root.--variant-faded.--color-primary.--highlighted:before,.root.--variant-faded.--color-primary:hover:not(.--loading):before{opacity:.04}.root.--variant-faded.--color-critical{background-color:var(--rs-color-background-critical-faded);color:var(--rs-color-foreground-critical)}.root.--variant-faded.--color-critical:before{background-color:var(--rs-color-foreground-critical)}.root.--variant-faded.--color-critical.--highlighted:before,.root.--variant-faded.--color-critical:hover:not(.--loading):before{opacity:.04}.root.--variant-faded.--color-positive{background-color:var(--rs-color-background-positive-faded);color:var(--rs-color-foreground-positive)}.root.--variant-faded.--color-positive:before{background-color:var(--rs-color-foreground-positive)}.root.--variant-faded.--color-positive.--highlighted:before,.root.--variant-faded.--color-positive:hover:not(.--loading):before{opacity:.04}.root.--variant-faded.--color-media{color:var(--rs-color-white)}.root.--variant-faded.--color-media:before{background-color:var(--rs-color-black);opacity:.28}.root.--variant-faded.--color-media.--highlighted:before,.root.--variant-faded.--color-media:hover:not(.--loading,.--disabled):before{opacity:.32}.root.--variant-faded.--color-inherit{color:inherit}.root.--variant-faded.--color-inherit:before{background-color:currentcolor;opacity:.16}.root.--variant-faded.--color-inherit.--highlighted:before,.root.--variant-faded.--color-inherit:hover:not(.--loading):before{opacity:.2}.root.--variant-outline{--rs-button-border-width:1px}.root.--variant-outline.--color-neutral{border-color:var(--rs-color-border-neutral);color:var(--rs-color-foreground-neutral)}.root.--variant-outline.--color-neutral:before{background-color:var(--rs-color-foreground-neutral)}.root.--variant-outline.--color-neutral.--highlighted:before,.root.--variant-outline.--color-neutral:hover:not(.--loading):before{opacity:.04}.root.--variant-outline.--color-primary{border-color:var(--rs-color-border-primary);color:var(--rs-color-foreground-primary)}.root.--variant-outline.--color-primary:before{background-color:var(--rs-color-foreground-primary)}.root.--variant-outline.--color-primary.--highlighted:before,.root.--variant-outline.--color-primary:hover:not(.--loading):before{opacity:.08}.root.--variant-outline.--color-critical{border-color:var(--rs-color-border-critical);color:var(--rs-color-foreground-critical)}.root.--variant-outline.--color-critical:before{background-color:var(--rs-color-foreground-critical)}.root.--variant-outline.--color-critical.--highlighted:before,.root.--variant-outline.--color-critical:hover:not(.--loading):before{opacity:.08}.root.--variant-outline.--color-positive{border-color:var(--rs-color-border-positive);color:var(--rs-color-foreground-positive)}.root.--variant-outline.--color-positive:before{background-color:var(--rs-color-foreground-positive)}.root.--variant-outline.--color-positive.--highlighted:before,.root.--variant-outline.--color-positive:hover:not(.--loading):before{opacity:.08}.root.--variant-outline.--color-inherit{border-color:currentcolor;color:inherit}.root.--variant-outline.--color-inherit:before{background-color:currentcolor}.root.--variant-outline.--color-inherit.--highlighted:before,.root.--variant-outline.--color-inherit:hover:not(.--loading):before{opacity:.08}.root.--variant-ghost{--rs-button-border-width:0px;--rs-p-h:max(calc(var(--rs-button-p-h) - var(--rs-unit-x1)),var(--rs-unit-x2))}.root.--variant-ghost.--color-neutral{color:var(--rs-color-foreground-neutral)}.root.--variant-ghost.--color-neutral:before{background-color:var(--rs-color-background-neutral)}.root.--variant-ghost.--color-neutral.--highlighted:before,.root.--variant-ghost.--color-neutral:hover:not(.--loading):before{opacity:.32}.root.--variant-ghost.--color-primary{color:var(--rs-color-foreground-primary)}.root.--variant-ghost.--color-primary:before{background-color:var(--rs-color-background-primary)}.root.--variant-ghost.--color-primary.--highlighted:before,.root.--variant-ghost.--color-primary:hover:not(.--loading):before{opacity:.12}.root.--variant-ghost.--color-critical{color:var(--rs-color-foreground-critical)}.root.--variant-ghost.--color-critical:before{background-color:var(--rs-color-background-critical)}.root.--variant-ghost.--color-critical.--highlighted:before,.root.--variant-ghost.--color-critical:hover:not(.--loading):before{opacity:.12}.root.--variant-ghost.--color-positive{color:var(--rs-color-foreground-positive)}.root.--variant-ghost.--color-positive:before{background-color:var(--rs-color-background-positive)}.root.--variant-ghost.--color-positive.--highlighted:before,.root.--variant-ghost.--color-positive:hover:not(.--loading):before{opacity:.12}.root.--variant-ghost.--color-inherit{color:inherit}.root.--variant-ghost.--color-inherit:before{background-color:currentcolor}.root.--variant-ghost.--color-inherit.--highlighted:before,.root.--variant-ghost.--color-inherit:hover:not(.--loading):before{opacity:.08}.root.--elevated{box-shadow:var(--rs-shadow-raised)}.root.--elevated.--variant-outline.--color-critical,.root.--elevated.--variant-outline.--color-neutral,.root.--elevated.--variant-outline.--color-positive,.root.--elevated.--variant-outline.--color-primary{background:var(--rs-color-background-elevation-raised)}.root.--disabled:active{transform:none!important}.root.--disabled.--color-critical,.root.--disabled.--color-critical.--highlighted,.root.--disabled.--color-critical:hover,.root.--disabled.--color-inherit,.root.--disabled.--color-inherit.--highlighted,.root.--disabled.--color-inherit:hover,.root.--disabled.--color-neutral,.root.--disabled.--color-neutral.--highlighted,.root.--disabled.--color-neutral:hover,.root.--disabled.--color-positive,.root.--disabled.--color-positive.--highlighted,.root.--disabled.--color-positive:hover,.root.--disabled.--color-primary,.root.--disabled.--color-primary.--highlighted,.root.--disabled.--color-primary:hover{background-color:var(--rs-color-background-disabled)!important;border-color:var(--rs-color-border-disabled)!important;color:var(--rs-color-foreground-disabled)!important}.root.--disabled.--color-critical.--highlighted:before,.root.--disabled.--color-critical:before,.root.--disabled.--color-critical:hover:before,.root.--disabled.--color-inherit.--highlighted:before,.root.--disabled.--color-inherit:before,.root.--disabled.--color-inherit:hover:before,.root.--disabled.--color-neutral.--highlighted:before,.root.--disabled.--color-neutral:before,.root.--disabled.--color-neutral:hover:before,.root.--disabled.--color-positive.--highlighted:before,.root.--disabled.--color-positive:before,.root.--disabled.--color-positive:hover:before,.root.--disabled.--color-primary.--highlighted:before,.root.--disabled.--color-primary:before,.root.--disabled.--color-primary:hover:before{opacity:0!important}.root.--disabled.--color-critical.--highlighted.--variant-faded,.root.--disabled.--color-critical.--variant-faded,.root.--disabled.--color-critical:hover.--variant-faded,.root.--disabled.--color-inherit.--highlighted.--variant-faded,.root.--disabled.--color-inherit.--variant-faded,.root.--disabled.--color-inherit:hover.--variant-faded,.root.--disabled.--color-neutral.--highlighted.--variant-faded,.root.--disabled.--color-neutral.--variant-faded,.root.--disabled.--color-neutral:hover.--variant-faded,.root.--disabled.--color-positive.--highlighted.--variant-faded,.root.--disabled.--color-positive.--variant-faded,.root.--disabled.--color-positive:hover.--variant-faded,.root.--disabled.--color-primary.--highlighted.--variant-faded,.root.--disabled.--color-primary.--variant-faded,.root.--disabled.--color-primary:hover.--variant-faded{background-color:var(--rs-color-background-disabled-faded)!important}.root.--disabled.--color-critical.--highlighted.--variant-outline,.root.--disabled.--color-critical.--variant-outline,.root.--disabled.--color-critical:hover.--variant-outline,.root.--disabled.--color-inherit.--highlighted.--variant-outline,.root.--disabled.--color-inherit.--variant-outline,.root.--disabled.--color-inherit:hover.--variant-outline,.root.--disabled.--color-neutral.--highlighted.--variant-outline,.root.--disabled.--color-neutral.--variant-outline,.root.--disabled.--color-neutral:hover.--variant-outline,.root.--disabled.--color-positive.--highlighted.--variant-outline,.root.--disabled.--color-positive.--variant-outline,.root.--disabled.--color-positive:hover.--variant-outline,.root.--disabled.--color-primary.--highlighted.--variant-outline,.root.--disabled.--color-primary.--variant-outline,.root.--disabled.--color-primary:hover.--variant-outline{background-color:transparent!important}.root.--disabled.--color-critical.--highlighted.--variant-ghost,.root.--disabled.--color-critical.--variant-ghost,.root.--disabled.--color-critical:hover.--variant-ghost,.root.--disabled.--color-inherit.--highlighted.--variant-ghost,.root.--disabled.--color-inherit.--variant-ghost,.root.--disabled.--color-inherit:hover.--variant-ghost,.root.--disabled.--color-neutral.--highlighted.--variant-ghost,.root.--disabled.--color-neutral.--variant-ghost,.root.--disabled.--color-neutral:hover.--variant-ghost,.root.--disabled.--color-positive.--highlighted.--variant-ghost,.root.--disabled.--color-positive.--variant-ghost,.root.--disabled.--color-positive:hover.--variant-ghost,.root.--disabled.--color-primary.--highlighted.--variant-ghost,.root.--disabled.--color-primary.--variant-ghost,.root.--disabled.--color-primary:hover.--variant-ghost{background-color:transparent!important;border-color:transparent!important}.root.--disabled.--color-media,.root.--disabled.--color-media.--highlighted,.root.--disabled.--color-media:hover{opacity:.4!important}.group .root{border-radius:0}.group .root:first-child{border-end-start-radius:var(--rs-button-radius);border-start-start-radius:var(--rs-button-radius)}.group .root:not(:first-child){border-inline-start:1px solid var(--rs-button-group-separator-color)}.group .root:last-child{border-end-end-radius:var(--rs-button-radius);border-start-end-radius:var(--rs-button-radius)}.group .root.--variant-solid.--color-neutral{--rs-button-group-separator-color:var(--rs-color-border-neutral)}.group .root.--variant-ghost.--color-neutral{--rs-button-group-separator-color:var(--rs-color-border-neutral-faded)}.group .root.--variant-solid.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive)}.group .root.--variant-ghost.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive-faded)}.group .root.--variant-solid.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical)}.group .root.--variant-ghost.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical-faded)}.group .root.--variant-solid.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary)}.group .root.--variant-ghost.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary-faded)}.group .root.--variant-faded.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive-faded)}.group .root.--variant-faded.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical-faded)}.group .root.--variant-faded.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary-faded)}.group .root.--variant-solid.--color-black{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.28)}.group .root.--variant-faded.--color-black{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.14)}.group .root.--variant-faded.--color-white,.group .root.--variant-ghost.--color-black,.group .root.--variant-solid.--color-white{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-black),0.2)}.group .root.--variant-ghost.--color-white{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.28)}.aligner{line-height:0}@media (--rs-viewport-m ){.--size-small--m{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--m{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--m{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--m{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--m{text-align:center;width:100%}.--full-width-false--m{text-align:initial;width:auto}}@media (--rs-viewport-l ){.--size-small--l{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--l{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--l{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--l{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--l{text-align:center;width:100%}.--full-width-false--l{text-align:initial;width:auto}}@media (--rs-viewport-xl ){.--size-small--xl{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--xl{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--xl{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--xl{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--xl{text-align:center;width:100%}.--full-width-false--xl{text-align:initial;width:auto}}
|
1
|
+
.root{--rs-p-v:var(--rs-button-p-v);--rs-p-h:var(--rs-button-p-h);align-items:center;border:var(--rs-button-border-width) solid transparent;border-radius:var(--rs-button-radius);box-sizing:border-box;cursor:pointer;display:inline-flex;justify-content:center;overflow:hidden;padding:calc(var(--rs-unit-x1) - var(--rs-button-border-width)) calc(var(--rs-p-h) - var(--rs-button-border-width));position:relative;text-align:initial;text-decoration:none;transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:background-color,box-shadow,border-color,color,transform;z-index:0;-webkit-tap-highlight-color:transparent;font-family:var(--rs-font-family-body);font-size:var(--rs-button-font-size);font-weight:var(--rs-font-weight-medium);line-height:var(--rs-button-line-height);min-height:calc(var(--rs-button-line-height) + var(--rs-p-v) * 2);min-width:calc(var(--rs-button-line-height) - (var(--rs-unit-x1) * 2) + (var(--rs-button-p-h) * 2))}.root:active{transform:scale(.98)}.root:before{content:"";inset:0;opacity:0;position:absolute;transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:opacity}.text{align-items:center;display:flex;gap:var(--rs-button-gap)}.icon{margin-inline-end:var(--rs-button-gap)}.icon.--icon-position-end{margin-inline-end:0;margin-inline-start:var(--rs-button-gap)}.icon:last-child{margin-inline-end:0}.icon,.text{position:relative;z-index:5}.loader{align-items:center;display:none;inset:0;justify-content:center;position:absolute}.root.--icon-only .icon{margin:0 calc(var(--rs-unit-x1) * -1)}.root.--loading{cursor:default}.root.--loading:active{transform:none}.root.--loading .icon,.root.--loading .text{visibility:hidden}.root.--loading .loader{display:flex}.root.--rounded{border-radius:999px}.--size-small{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width{text-align:center;width:100%}.root.--variant-faded.--color-neutral,.root.--variant-solid.--color-neutral{background-color:var(--rs-color-background-neutral);color:var(--rs-color-on-background-neutral)}.root.--variant-faded.--color-neutral:before,.root.--variant-solid.--color-neutral:before{background-color:var(--rs-color-on-background-neutral)}.root.--variant-faded.--color-neutral.--highlighted:before,.root.--variant-faded.--color-neutral:hover:not(.--loading):before,.root.--variant-solid.--color-neutral.--highlighted:before,.root.--variant-solid.--color-neutral:hover:not(.--loading):before{opacity:.04}.root.--variant-solid{--rs-button-border-width:0px}.root.--variant-solid.--color-primary{background-color:var(--rs-color-background-primary);color:var(--rs-color-on-background-primary)}.root.--variant-solid.--color-primary:before{background-color:var(--rs-color-on-background-primary)}.root.--variant-solid.--color-primary.--highlighted:before,.root.--variant-solid.--color-primary:hover:not(.--loading):before{opacity:.08}.root.--variant-solid.--color-critical{background-color:var(--rs-color-background-critical);color:var(--rs-color-on-background-critical)}.root.--variant-solid.--color-critical:before{background-color:var(--rs-color-on-background-critical)}.root.--variant-solid.--color-critical.--highlighted:before,.root.--variant-solid.--color-critical:hover:not(.--loading):before{opacity:.08}.root.--variant-solid.--color-positive{background-color:var(--rs-color-background-positive);color:var(--rs-color-on-background-positive)}.root.--variant-solid.--color-positive:before{background-color:var(--rs-color-on-background-positive)}.root.--variant-solid.--color-positive.--highlighted:before,.root.--variant-solid.--color-positive:hover:not(.--loading):before{opacity:.08}.root.--variant-solid.--color-media{background-color:var(--rs-color-white);color:var(--rs-color-black)}.root.--variant-solid.--color-media:before{background-color:var(--rs-color-black)}.root.--variant-solid.--color-media.--highlighted:before,.root.--variant-solid.--color-media:hover:not(.--loading,.--disabled):before{opacity:.04}.root.--variant-faded{--rs-button-border-width:0px}.root.--variant-faded.--color-primary{background-color:var(--rs-color-background-primary-faded);color:var(--rs-color-foreground-primary)}.root.--variant-faded.--color-primary:before{background-color:var(--rs-color-foreground-primary)}.root.--variant-faded.--color-primary.--highlighted:before,.root.--variant-faded.--color-primary:hover:not(.--loading):before{opacity:.04}.root.--variant-faded.--color-critical{background-color:var(--rs-color-background-critical-faded);color:var(--rs-color-foreground-critical)}.root.--variant-faded.--color-critical:before{background-color:var(--rs-color-foreground-critical)}.root.--variant-faded.--color-critical.--highlighted:before,.root.--variant-faded.--color-critical:hover:not(.--loading):before{opacity:.04}.root.--variant-faded.--color-positive{background-color:var(--rs-color-background-positive-faded);color:var(--rs-color-foreground-positive)}.root.--variant-faded.--color-positive:before{background-color:var(--rs-color-foreground-positive)}.root.--variant-faded.--color-positive.--highlighted:before,.root.--variant-faded.--color-positive:hover:not(.--loading):before{opacity:.04}.root.--variant-faded.--color-media{color:var(--rs-color-white)}.root.--variant-faded.--color-media:before{background-color:var(--rs-color-black);opacity:.28}.root.--variant-faded.--color-media.--highlighted:before,.root.--variant-faded.--color-media:hover:not(.--loading,.--disabled):before{opacity:.32}.root.--variant-faded.--color-inherit{color:inherit}.root.--variant-faded.--color-inherit:before{background-color:currentcolor;opacity:.16}.root.--variant-faded.--color-inherit.--highlighted:before,.root.--variant-faded.--color-inherit:hover:not(.--loading):before{opacity:.2}.root.--variant-outline{--rs-button-border-width:1px}.root.--variant-outline.--color-neutral{border-color:var(--rs-color-border-neutral);color:var(--rs-color-foreground-neutral)}.root.--variant-outline.--color-neutral:before{background-color:var(--rs-color-foreground-neutral)}.root.--variant-outline.--color-neutral.--highlighted:before,.root.--variant-outline.--color-neutral:hover:not(.--loading):before{opacity:.04}.root.--variant-outline.--color-primary{border-color:var(--rs-color-border-primary);color:var(--rs-color-foreground-primary)}.root.--variant-outline.--color-primary:before{background-color:var(--rs-color-foreground-primary)}.root.--variant-outline.--color-primary.--highlighted:before,.root.--variant-outline.--color-primary:hover:not(.--loading):before{opacity:.08}.root.--variant-outline.--color-critical{border-color:var(--rs-color-border-critical);color:var(--rs-color-foreground-critical)}.root.--variant-outline.--color-critical:before{background-color:var(--rs-color-foreground-critical)}.root.--variant-outline.--color-critical.--highlighted:before,.root.--variant-outline.--color-critical:hover:not(.--loading):before{opacity:.08}.root.--variant-outline.--color-positive{border-color:var(--rs-color-border-positive);color:var(--rs-color-foreground-positive)}.root.--variant-outline.--color-positive:before{background-color:var(--rs-color-foreground-positive)}.root.--variant-outline.--color-positive.--highlighted:before,.root.--variant-outline.--color-positive:hover:not(.--loading):before{opacity:.08}.root.--variant-outline.--color-inherit{border-color:currentcolor;color:inherit}.root.--variant-outline.--color-inherit:before{background-color:currentcolor}.root.--variant-outline.--color-inherit.--highlighted:before,.root.--variant-outline.--color-inherit:hover:not(.--loading):before{opacity:.08}.root.--variant-ghost{--rs-button-border-width:0px;--rs-p-h:max(calc(var(--rs-button-p-h) - var(--rs-unit-x1)),var(--rs-unit-x2))}.root.--variant-ghost.--color-neutral{color:var(--rs-color-foreground-neutral)}.root.--variant-ghost.--color-neutral:before{background-color:var(--rs-color-background-neutral)}.root.--variant-ghost.--color-neutral.--highlighted:before,.root.--variant-ghost.--color-neutral:hover:not(.--loading):before{opacity:.32}.root.--variant-ghost.--color-primary{color:var(--rs-color-foreground-primary)}.root.--variant-ghost.--color-primary:before{background-color:var(--rs-color-background-primary)}.root.--variant-ghost.--color-primary.--highlighted:before,.root.--variant-ghost.--color-primary:hover:not(.--loading):before{opacity:.12}.root.--variant-ghost.--color-critical{color:var(--rs-color-foreground-critical)}.root.--variant-ghost.--color-critical:before{background-color:var(--rs-color-background-critical)}.root.--variant-ghost.--color-critical.--highlighted:before,.root.--variant-ghost.--color-critical:hover:not(.--loading):before{opacity:.12}.root.--variant-ghost.--color-positive{color:var(--rs-color-foreground-positive)}.root.--variant-ghost.--color-positive:before{background-color:var(--rs-color-background-positive)}.root.--variant-ghost.--color-positive.--highlighted:before,.root.--variant-ghost.--color-positive:hover:not(.--loading):before{opacity:.12}.root.--variant-ghost.--color-inherit{color:inherit}.root.--variant-ghost.--color-inherit:before{background-color:currentcolor}.root.--variant-ghost.--color-inherit.--highlighted:before,.root.--variant-ghost.--color-inherit:hover:not(.--loading):before{opacity:.08}.root.--elevated:not(:focus-visible){box-shadow:var(--rs-shadow-raised)}.root.--elevated.--variant-outline.--color-critical,.root.--elevated.--variant-outline.--color-neutral,.root.--elevated.--variant-outline.--color-positive,.root.--elevated.--variant-outline.--color-primary{background:var(--rs-color-background-elevation-raised)}.root.--disabled:active{transform:none!important}.root.--disabled.--color-critical,.root.--disabled.--color-critical.--highlighted,.root.--disabled.--color-critical:hover,.root.--disabled.--color-inherit,.root.--disabled.--color-inherit.--highlighted,.root.--disabled.--color-inherit:hover,.root.--disabled.--color-neutral,.root.--disabled.--color-neutral.--highlighted,.root.--disabled.--color-neutral:hover,.root.--disabled.--color-positive,.root.--disabled.--color-positive.--highlighted,.root.--disabled.--color-positive:hover,.root.--disabled.--color-primary,.root.--disabled.--color-primary.--highlighted,.root.--disabled.--color-primary:hover{background-color:var(--rs-color-background-disabled)!important;border-color:var(--rs-color-border-disabled)!important;color:var(--rs-color-foreground-disabled)!important}.root.--disabled.--color-critical.--highlighted:before,.root.--disabled.--color-critical:before,.root.--disabled.--color-critical:hover:before,.root.--disabled.--color-inherit.--highlighted:before,.root.--disabled.--color-inherit:before,.root.--disabled.--color-inherit:hover:before,.root.--disabled.--color-neutral.--highlighted:before,.root.--disabled.--color-neutral:before,.root.--disabled.--color-neutral:hover:before,.root.--disabled.--color-positive.--highlighted:before,.root.--disabled.--color-positive:before,.root.--disabled.--color-positive:hover:before,.root.--disabled.--color-primary.--highlighted:before,.root.--disabled.--color-primary:before,.root.--disabled.--color-primary:hover:before{opacity:0!important}.root.--disabled.--color-critical.--highlighted.--variant-faded,.root.--disabled.--color-critical.--variant-faded,.root.--disabled.--color-critical:hover.--variant-faded,.root.--disabled.--color-inherit.--highlighted.--variant-faded,.root.--disabled.--color-inherit.--variant-faded,.root.--disabled.--color-inherit:hover.--variant-faded,.root.--disabled.--color-neutral.--highlighted.--variant-faded,.root.--disabled.--color-neutral.--variant-faded,.root.--disabled.--color-neutral:hover.--variant-faded,.root.--disabled.--color-positive.--highlighted.--variant-faded,.root.--disabled.--color-positive.--variant-faded,.root.--disabled.--color-positive:hover.--variant-faded,.root.--disabled.--color-primary.--highlighted.--variant-faded,.root.--disabled.--color-primary.--variant-faded,.root.--disabled.--color-primary:hover.--variant-faded{background-color:var(--rs-color-background-disabled-faded)!important}.root.--disabled.--color-critical.--highlighted.--variant-outline,.root.--disabled.--color-critical.--variant-outline,.root.--disabled.--color-critical:hover.--variant-outline,.root.--disabled.--color-inherit.--highlighted.--variant-outline,.root.--disabled.--color-inherit.--variant-outline,.root.--disabled.--color-inherit:hover.--variant-outline,.root.--disabled.--color-neutral.--highlighted.--variant-outline,.root.--disabled.--color-neutral.--variant-outline,.root.--disabled.--color-neutral:hover.--variant-outline,.root.--disabled.--color-positive.--highlighted.--variant-outline,.root.--disabled.--color-positive.--variant-outline,.root.--disabled.--color-positive:hover.--variant-outline,.root.--disabled.--color-primary.--highlighted.--variant-outline,.root.--disabled.--color-primary.--variant-outline,.root.--disabled.--color-primary:hover.--variant-outline{background-color:transparent!important}.root.--disabled.--color-critical.--highlighted.--variant-ghost,.root.--disabled.--color-critical.--variant-ghost,.root.--disabled.--color-critical:hover.--variant-ghost,.root.--disabled.--color-inherit.--highlighted.--variant-ghost,.root.--disabled.--color-inherit.--variant-ghost,.root.--disabled.--color-inherit:hover.--variant-ghost,.root.--disabled.--color-neutral.--highlighted.--variant-ghost,.root.--disabled.--color-neutral.--variant-ghost,.root.--disabled.--color-neutral:hover.--variant-ghost,.root.--disabled.--color-positive.--highlighted.--variant-ghost,.root.--disabled.--color-positive.--variant-ghost,.root.--disabled.--color-positive:hover.--variant-ghost,.root.--disabled.--color-primary.--highlighted.--variant-ghost,.root.--disabled.--color-primary.--variant-ghost,.root.--disabled.--color-primary:hover.--variant-ghost{background-color:transparent!important;border-color:transparent!important}.root.--disabled.--color-media,.root.--disabled.--color-media.--highlighted,.root.--disabled.--color-media:hover{opacity:.4!important}.group .root{border-radius:0}.group .root:first-child{border-end-start-radius:var(--rs-button-radius);border-start-start-radius:var(--rs-button-radius)}.group .root:not(:first-child){border-inline-start:1px solid var(--rs-button-group-separator-color)}.group .root:last-child{border-end-end-radius:var(--rs-button-radius);border-start-end-radius:var(--rs-button-radius)}.group .root.--variant-solid.--color-neutral{--rs-button-group-separator-color:var(--rs-color-border-neutral)}.group .root.--variant-ghost.--color-neutral{--rs-button-group-separator-color:var(--rs-color-border-neutral-faded)}.group .root.--variant-solid.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive)}.group .root.--variant-ghost.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive-faded)}.group .root.--variant-solid.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical)}.group .root.--variant-ghost.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical-faded)}.group .root.--variant-solid.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary)}.group .root.--variant-ghost.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary-faded)}.group .root.--variant-faded.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive-faded)}.group .root.--variant-faded.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical-faded)}.group .root.--variant-faded.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary-faded)}.group .root.--variant-solid.--color-black{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.28)}.group .root.--variant-faded.--color-black{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.14)}.group .root.--variant-faded.--color-white,.group .root.--variant-ghost.--color-black,.group .root.--variant-solid.--color-white{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-black),0.2)}.group .root.--variant-ghost.--color-white{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.28)}.aligner{line-height:0}@media (--rs-viewport-m ){.--size-small--m{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--m{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--m{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--m{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--m{text-align:center;width:100%}.--full-width-false--m{text-align:initial;width:auto}}@media (--rs-viewport-l ){.--size-small--l{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--l{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--l{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--l{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--l{text-align:center;width:100%}.--full-width-false--l{text-align:initial;width:auto}}@media (--rs-viewport-xl ){.--size-small--xl{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--xl{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--xl{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--xl{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--xl{text-align:center;width:100%}.--full-width-false--xl{text-align:initial;width:auto}}
|
@@ -125,7 +125,9 @@ export const icon = () => (<Example>
|
|
125
125
|
export const elevated = () => (<Example>
|
126
126
|
<Example.Item title="color: neutral, elevated, variant: solid and outline">
|
127
127
|
<View gap={3} direction="row">
|
128
|
-
<Button elevated>
|
128
|
+
<Button elevated onClick={() => { }}>
|
129
|
+
Button
|
130
|
+
</Button>
|
129
131
|
<Button elevated variant="outline">
|
130
132
|
Button
|
131
133
|
</Button>
|
@@ -1 +1 @@
|
|
1
|
-
.menu{padding:var(--rs-unit-x1)}.section+.section{border-top:1px solid var(--rs-color-border-neutral-faded);padding-top:var(--rs-unit-x1)}.item
|
1
|
+
.menu{padding:var(--rs-unit-x1)}.section+.section{border-top:1px solid var(--rs-color-border-neutral-faded);padding-top:var(--rs-unit-x1)}.item,.section+.section{margin-top:var(--rs-unit-x1)}.item:first-child{margin-top:0}[dir=rtl] .arrow{transform:scaleX(-1)}
|
@@ -2,7 +2,7 @@ import type React from "react";
|
|
2
2
|
import type { PopoverProps, PopoverInstance } from "../Popover";
|
3
3
|
import type { FlyoutContentProps } from "../_private/Flyout";
|
4
4
|
export type Instance = PopoverInstance;
|
5
|
-
export type Props = Pick<PopoverProps, "children" | "position" | "forcePosition" | "triggerType" | "contentGap" | "onOpen" | "onClose" | "active" | "defaultActive" | "width" | "disableHideAnimation" | "instanceRef" | "containerRef"> & {
|
5
|
+
export type Props = Pick<PopoverProps, "children" | "position" | "forcePosition" | "triggerType" | "contentGap" | "onOpen" | "onClose" | "active" | "defaultActive" | "width" | "disableHideAnimation" | "disableCloseOnOutsideClick" | "instanceRef" | "containerRef"> & {
|
6
6
|
trapFocusMode?: Extract<PopoverProps["trapFocusMode"], "action-menu" | "selection-menu">;
|
7
7
|
};
|
8
8
|
export type ContentProps = Pick<FlyoutContentProps, "attributes" | "children" | "className">;
|
@@ -9,6 +9,7 @@ import Overlay from "../Overlay/index.js";
|
|
9
9
|
import useElementId from "../../hooks/useElementId.js";
|
10
10
|
import s from "./Modal.module.css";
|
11
11
|
import getPaddingStyles from "../../styles/padding/index.js";
|
12
|
+
import useHandlerRef from "../../hooks/useHandlerRef.js";
|
12
13
|
const DRAG_THRESHOLD = 32;
|
13
14
|
const DRAG_OPPOSITE_THRESHOLD = 100;
|
14
15
|
const DRAG_EDGE_BOUNDARY = 32;
|
@@ -40,6 +41,7 @@ const ModalSubtitle = (props) => {
|
|
40
41
|
};
|
41
42
|
const Modal = (props) => {
|
42
43
|
const { children, onClose, onOpen, active, size, padding = 4, position = "center", transparentOverlay, ariaLabel, autoFocus = true, disableSwipeGesture, overlayClassName, className, attributes, } = props;
|
44
|
+
const onCloseRef = useHandlerRef(onClose);
|
43
45
|
const id = useElementId();
|
44
46
|
const clientPosition = useResponsiveClientValue(position);
|
45
47
|
const [titleMounted, setTitleMounted] = React.useState(false);
|
@@ -110,7 +112,7 @@ const Modal = (props) => {
|
|
110
112
|
// Changing to a different direction will keep the modal opened
|
111
113
|
const shouldClose = clientPosition === "start" ? dragDirectionRef.current < 0 : dragDirectionRef.current > 0;
|
112
114
|
if (Math.abs(dragDistanceRef.current) > DRAG_THRESHOLD && shouldClose) {
|
113
|
-
|
115
|
+
onCloseRef.current?.();
|
114
116
|
}
|
115
117
|
else {
|
116
118
|
resetDragData();
|
@@ -151,8 +153,7 @@ const Modal = (props) => {
|
|
151
153
|
document.removeEventListener("touchmove", handleDrag);
|
152
154
|
document.removeEventListener("touchend", handleDragEnd);
|
153
155
|
};
|
154
|
-
|
155
|
-
}, [dragging, clientPosition]);
|
156
|
+
}, [dragging, clientPosition, onCloseRef, position, rootRef]);
|
156
157
|
// Syncing distance to the ref to avoid having a dependency on dragDistance in handleDragEnd
|
157
158
|
React.useEffect(() => {
|
158
159
|
const rootEl = rootRef.current;
|
@@ -14,7 +14,6 @@ declare const _default: {
|
|
14
14
|
};
|
15
15
|
};
|
16
16
|
export default _default;
|
17
|
-
export declare const foo: () => React.JSX.Element;
|
18
17
|
export declare const position: () => React.JSX.Element;
|
19
18
|
export declare const size: () => React.JSX.Element;
|
20
19
|
export declare const padding: () => React.JSX.Element;
|
@@ -9,7 +9,6 @@ import Switch from "../../Switch/index.js";
|
|
9
9
|
import TextField from "../../TextField/index.js";
|
10
10
|
import useToggle from "../../../hooks/useToggle.js";
|
11
11
|
import Radio from "../../Radio/index.js";
|
12
|
-
import Slider from "../../Slider/index.js";
|
13
12
|
export default {
|
14
13
|
title: "Components/Modal",
|
15
14
|
component: Modal,
|
@@ -19,21 +18,6 @@ export default {
|
|
19
18
|
},
|
20
19
|
},
|
21
20
|
};
|
22
|
-
export const foo = () => {
|
23
|
-
const { activate, deactivate, active } = useToggle(false);
|
24
|
-
return (<>
|
25
|
-
<Button onClick={console.log}>Other</Button>
|
26
|
-
<Button onClick={activate}>Open modal</Button>
|
27
|
-
<Button onClick={console.log}>Other</Button>
|
28
|
-
|
29
|
-
<Modal active={active} onClose={deactivate}>
|
30
|
-
<Slider name="slider" defaultValue={20} onChange={(args) => console.log(args.value)}/>
|
31
|
-
<Button onClick={console.log}>Btn 1</Button>
|
32
|
-
|
33
|
-
<Button onClick={console.log}>Btn 2</Button>
|
34
|
-
</Modal>
|
35
|
-
</>);
|
36
|
-
};
|
37
21
|
const Demo = (props) => {
|
38
22
|
const { active: activeProp, title, subtitle, children, ...modalProps } = props;
|
39
23
|
const { active, activate, deactivate } = useToggle(activeProp);
|
@@ -11,8 +11,11 @@ import useScrollLock from "../../hooks/useScrollLock.js";
|
|
11
11
|
import useIsDismissible from "../../hooks/_private/useIsDismissible.js";
|
12
12
|
import Portal from "../_private/Portal/index.js";
|
13
13
|
import s from "./Overlay.module.css";
|
14
|
+
import useHandlerRef from "../../hooks/useHandlerRef.js";
|
14
15
|
const Overlay = (props) => {
|
15
16
|
const { active, children, transparent, onClose, onOpen, className, attributes } = props;
|
17
|
+
const onCloseRef = useHandlerRef(onClose);
|
18
|
+
const onOpenRef = useHandlerRef(onOpen);
|
16
19
|
const clickThrough = transparent === true;
|
17
20
|
const opacity = clickThrough ? 0 : (1 - (transparent || 0)) * 0.7;
|
18
21
|
const [mounted, setMounted] = React.useState(false);
|
@@ -35,10 +38,8 @@ const Overlay = (props) => {
|
|
35
38
|
const close = React.useCallback(() => {
|
36
39
|
if (!visible || !isDismissible())
|
37
40
|
return;
|
38
|
-
|
39
|
-
|
40
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
41
|
-
}, [visible, isDismissible]);
|
41
|
+
onCloseRef.current?.();
|
42
|
+
}, [visible, isDismissible, onCloseRef]);
|
42
43
|
const handleMouseDown = (event) => {
|
43
44
|
isMouseDownValidRef.current = !isInsideChild(event.target);
|
44
45
|
};
|
@@ -84,11 +85,10 @@ const Overlay = (props) => {
|
|
84
85
|
trapFocus.trap({
|
85
86
|
initialFocusEl: contentRef.current.querySelector("[role=dialog][tabindex='-1']"),
|
86
87
|
});
|
87
|
-
|
88
|
+
onOpenRef.current?.();
|
88
89
|
return () => trapFocus.release();
|
89
90
|
// Ignoring onOpen since it might be not memoized when passed
|
90
|
-
|
91
|
-
}, [rendered]);
|
91
|
+
}, [rendered, onOpenRef]);
|
92
92
|
// Unlock scroll on unmount
|
93
93
|
React.useEffect(() => {
|
94
94
|
return () => {
|
@@ -47,7 +47,9 @@ class CustomElement extends window.HTMLElement {
|
|
47
47
|
root.render(overlay);
|
48
48
|
}
|
49
49
|
}
|
50
|
-
window.customElements.
|
50
|
+
if (!window.customElements.get("custom-element")) {
|
51
|
+
window.customElements.define("custom-element", CustomElement);
|
52
|
+
}
|
51
53
|
export const shadowDom = () => {
|
52
54
|
return (<Example>
|
53
55
|
<Example.Item>
|
@@ -5,14 +5,14 @@ import Dismissible from "../Dismissible/index.js";
|
|
5
5
|
import s from "./Popover.module.css";
|
6
6
|
import getPaddingStyles from "../../styles/padding/index.js";
|
7
7
|
const Popover = (props) => {
|
8
|
-
const { id, forcePosition, onOpen, onClose, active, defaultActive, children, width, contentGap, variant = "elevated", triggerType = "click", position = "bottom", disableHideAnimation, disableContentHover, instanceRef, containerRef, } = props;
|
8
|
+
const { id, forcePosition, onOpen, onClose, active, defaultActive, children, width, contentGap, variant = "elevated", triggerType = "click", position = "bottom", disableHideAnimation, disableContentHover, disableCloseOnOutsideClick, instanceRef, containerRef, } = props;
|
9
9
|
const padding = props.padding ?? (variant === "headless" ? 0 : 4);
|
10
10
|
const trapFocusMode = props.trapFocusMode || (triggerType === "hover" ? "content-menu" : undefined);
|
11
11
|
const paddingStyles = getPaddingStyles(padding);
|
12
12
|
const contentClassName = classNames(s.content, !!width && s["content--has-width"], variant && s[`content--variant-${variant}`], paddingStyles?.classNames);
|
13
13
|
return (
|
14
14
|
// @ts-ignore
|
15
|
-
_jsx(Flyout, { id: id, instanceRef: instanceRef, position: position, forcePosition: forcePosition, onOpen: onOpen, onClose: onClose, trapFocusMode: trapFocusMode, triggerType: triggerType, active: active, defaultActive: defaultActive, width: width, disableHideAnimation: disableHideAnimation, disableContentHover: disableContentHover, contentGap: contentGap, containerRef: containerRef, contentClassName: contentClassName, contentAttributes: { style: { ...paddingStyles?.variables } }, children: children }));
|
15
|
+
_jsx(Flyout, { id: id, instanceRef: instanceRef, position: position, forcePosition: forcePosition, onOpen: onOpen, onClose: onClose, trapFocusMode: trapFocusMode, triggerType: triggerType, active: active, defaultActive: defaultActive, width: width, disableHideAnimation: disableHideAnimation, disableContentHover: disableContentHover, disableCloseOnOutsideClick: disableCloseOnOutsideClick, contentGap: contentGap, containerRef: containerRef, contentClassName: contentClassName, contentAttributes: { style: { ...paddingStyles?.variables } }, children: children }));
|
16
16
|
};
|
17
17
|
const PopoverDismissible = (props) => {
|
18
18
|
const { handleClose } = useFlyoutContext();
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type React from "react";
|
2
2
|
import type { FlyoutProps, FlyoutInstance } from "../_private/Flyout";
|
3
3
|
export type Instance = FlyoutInstance;
|
4
|
-
export type Props = Pick<FlyoutProps, "id" | "position" | "forcePosition" | "onOpen" | "onClose" | "width" | "trapFocusMode" | "active" | "defaultActive" | "contentGap" | "instanceRef" | "triggerType" | "disableHideAnimation" | "disableContentHover" | "containerRef"> & {
|
4
|
+
export type Props = Pick<FlyoutProps, "id" | "position" | "forcePosition" | "onOpen" | "onClose" | "width" | "trapFocusMode" | "active" | "defaultActive" | "contentGap" | "instanceRef" | "triggerType" | "disableHideAnimation" | "disableContentHover" | "disableCloseOnOutsideClick" | "containerRef"> & {
|
5
5
|
children?: React.ReactNode;
|
6
6
|
padding?: number;
|
7
7
|
variant?: "elevated" | "headless";
|