@viraui/react 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog.json +6 -0
- package/dist/components/avatar/avatar.css +1 -55
- package/dist/components/avatar/avatar.d.ts +1 -2
- package/dist/components/avatar/avatar.js +49 -14
- package/dist/components/avatar/avatar.module.js +7 -0
- package/dist/components/avatar/index.d.ts +2 -2
- package/dist/components/basic-input/basic-input.css +1 -45
- package/dist/components/basic-input/basic-input.d.ts +0 -1
- package/dist/components/basic-input/basic-input.js +24 -13
- package/dist/components/basic-input/basic-input.module.js +3 -0
- package/dist/components/basic-input/field-helper-copy.d.ts +2 -1
- package/dist/components/basic-input/field-helper-copy.js +43 -24
- package/dist/components/basic-input/field-label.css +1 -0
- package/dist/components/basic-input/field-label.d.ts +10 -0
- package/dist/components/basic-input/field-label.js +24 -0
- package/dist/components/basic-input/field-label.module.js +3 -0
- package/dist/components/basic-input/index.d.ts +7 -2
- package/dist/components/basic-input/input-control-group.d.ts +2 -0
- package/dist/components/basic-input/input-control-group.js +40 -7
- package/dist/components/button/button.css +1 -156
- package/dist/components/button/button.d.ts +3 -3
- package/dist/components/button/button.js +104 -14
- package/dist/components/button/button.module.js +7 -0
- package/dist/components/button/index.d.ts +2 -2
- package/dist/components/checkbox/checkbox.css +1 -0
- package/dist/components/checkbox/checkbox.d.ts +65 -0
- package/dist/components/checkbox/checkbox.guide.json +22 -0
- package/dist/components/checkbox/checkbox.js +73 -0
- package/dist/components/checkbox/checkbox.module.js +10 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/clamp-text/clamp-text.css +1 -12
- package/dist/components/clamp-text/clamp-text.d.ts +1 -2
- package/dist/components/clamp-text/clamp-text.js +27 -22
- package/dist/components/clamp-text/clamp-text.module.js +3 -0
- package/dist/components/clamp-text/index.d.ts +2 -2
- package/dist/components/elevator/elevator.d.ts +5 -5
- package/dist/components/elevator/elevator.js +27 -27
- package/dist/components/elevator/index.d.ts +2 -2
- package/dist/components/icon/icon.css +1 -7
- package/dist/components/icon/icon.d.ts +2 -3
- package/dist/components/icon/icon.js +18 -9
- package/dist/components/icon/icon.module.js +3 -0
- package/dist/components/icon/index.d.ts +2 -2
- package/dist/components/icon-button/icon-button.d.ts +2 -2
- package/dist/components/icon-button/icon-button.js +10 -3
- package/dist/components/icon-button/index.d.ts +2 -2
- package/dist/components/index.d.ts +18 -17
- package/dist/components/select/index.d.ts +2 -2
- package/dist/components/select/select-group.d.ts +1 -1
- package/dist/components/select/select-group.js +37 -9
- package/dist/components/select/select-indicator-slot.js +33 -10
- package/dist/components/select/select-option.d.ts +1 -1
- package/dist/components/select/select-option.js +40 -10
- package/dist/components/select/select-separator.js +14 -6
- package/dist/components/select/select.css +1 -193
- package/dist/components/select/select.d.ts +10 -11
- package/dist/components/select/select.js +156 -32
- package/dist/components/select/select.module.js +19 -0
- package/dist/components/skeleton/index.d.ts +2 -2
- package/dist/components/skeleton/skeleton.css +1 -36
- package/dist/components/skeleton/skeleton.d.ts +2 -3
- package/dist/components/skeleton/skeleton.js +26 -15
- package/dist/components/skeleton/skeleton.module.js +6 -0
- package/dist/components/slider/index.d.ts +2 -2
- package/dist/components/slider/slider-control.d.ts +1 -2
- package/dist/components/slider/slider-control.js +43 -19
- package/dist/components/slider/slider-utils.js +6 -3
- package/dist/components/slider/slider.css +1 -64
- package/dist/components/slider/slider.d.ts +5 -8
- package/dist/components/slider/slider.js +83 -17
- package/dist/components/slider/slider.module.js +12 -0
- package/dist/components/spinner/index.d.ts +2 -2
- package/dist/components/spinner/spinner.css +1 -45
- package/dist/components/spinner/spinner.d.ts +1 -2
- package/dist/components/spinner/spinner.js +29 -6
- package/dist/components/spinner/spinner.module.js +7 -0
- package/dist/components/stack/index.d.ts +2 -2
- package/dist/components/stack/stack.css +1 -57
- package/dist/components/stack/stack.d.ts +2 -3
- package/dist/components/stack/stack.js +40 -36
- package/dist/components/stack/stack.module.js +3 -0
- package/dist/components/surface/index.d.ts +2 -2
- package/dist/components/surface/surface.css +1 -70
- package/dist/components/surface/surface.d.ts +10 -6
- package/dist/components/surface/surface.js +43 -40
- package/dist/components/surface/surface.module.js +6 -0
- package/dist/components/switch/index.d.ts +2 -2
- package/dist/components/switch/switch.css +1 -73
- package/dist/components/switch/switch.d.ts +17 -5
- package/dist/components/switch/switch.js +59 -13
- package/dist/components/switch/switch.module.js +7 -0
- package/dist/components/text/index.d.ts +2 -2
- package/dist/components/text/text.css +1 -140
- package/dist/components/text/text.d.ts +8 -3
- package/dist/components/text/text.js +46 -41
- package/dist/components/text/text.module.js +3 -0
- package/dist/components/textarea/index.d.ts +2 -2
- package/dist/components/textarea/textarea.css +1 -45
- package/dist/components/textarea/textarea.d.ts +3 -4
- package/dist/components/textarea/textarea.js +51 -11
- package/dist/components/textarea/textarea.module.js +7 -0
- package/dist/components/textfield/index.d.ts +2 -2
- package/dist/components/textfield/textfield.css +1 -87
- package/dist/components/textfield/textfield.d.ts +3 -4
- package/dist/components/textfield/textfield.js +58 -12
- package/dist/components/textfield/textfield.module.js +9 -0
- package/dist/components/title/index.d.ts +2 -2
- package/dist/components/title/title.css +1 -127
- package/dist/components/title/title.d.ts +8 -3
- package/dist/components/title/title.js +44 -39
- package/dist/components/title/title.module.js +3 -0
- package/dist/consumption.json +8 -4
- package/dist/core/elevation/elevation-types.js +6 -3
- package/dist/core/elevation/get-elevation-props.d.ts +1 -1
- package/dist/core/elevation/get-elevation-props.js +14 -11
- package/dist/core/props/intrinsic-vira-props.js +12 -9
- package/dist/core/styles/resolve-axis-padding.d.ts +1 -1
- package/dist/core/styles/resolve-axis-padding.js +15 -16
- package/dist/core/theme/resolve-theme-value.d.ts +1 -1
- package/dist/core/theme/resolve-theme-value.js +7 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -1
- package/dist/internal-icons/icon-registry.d.ts +242 -239
- package/dist/internal-icons/icon-registry.js +247 -238
- package/dist/internal-icons/icons/duo/Magnifier.d.ts +7 -0
- package/dist/internal-icons/icons/duo/Magnifier.js +13 -0
- package/dist/internal-icons/icons/duo/Minus.d.ts +7 -0
- package/dist/internal-icons/icons/duo/Minus.js +13 -0
- package/dist/internal-icons/icons/duo/Plus.d.ts +7 -0
- package/dist/internal-icons/icons/duo/Plus.js +13 -0
- package/dist/internal-icons/icons/duo/index.d.ts +241 -238
- package/dist/internal-icons/icons/duo/index.js +241 -238
- package/dist/preflight-surface.json +160 -0
- package/dist/preflight.css +1 -1
- package/package.json +11 -9
- package/dist/components/avatar/index.js +0 -1
- package/dist/components/basic-input/index.js +0 -1
- package/dist/components/button/index.js +0 -1
- package/dist/components/clamp-text/index.js +0 -1
- package/dist/components/elevator/index.js +0 -1
- package/dist/components/icon/index.js +0 -1
- package/dist/components/icon-button/index.js +0 -1
- package/dist/components/index.js +0 -17
- package/dist/components/select/index.js +0 -1
- package/dist/components/skeleton/index.js +0 -1
- package/dist/components/slider/index.js +0 -1
- package/dist/components/slider/slider-control.css +0 -71
- package/dist/components/spinner/index.js +0 -1
- package/dist/components/stack/index.js +0 -1
- package/dist/components/surface/index.js +0 -1
- package/dist/components/switch/index.js +0 -1
- package/dist/components/text/index.js +0 -1
- package/dist/components/textarea/index.js +0 -1
- package/dist/components/textfield/index.js +0 -1
- package/dist/components/title/index.js +0 -1
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
|
-
import { extractIntrinsicViraProps } from '../../core/props/intrinsic-vira-props.js';
|
|
5
|
-
import { resolveAxisPadding } from '../../core/styles/resolve-axis-padding.js';
|
|
6
|
-
import { resolveThemeValue } from '../../core/theme/resolve-theme-value.js';
|
|
7
1
|
import './stack.css';
|
|
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
|
-
|
|
2
|
+
"use client";
|
|
3
|
+
import { extractIntrinsicViraProps } from "../../core/props/intrinsic-vira-props.js";
|
|
4
|
+
import { resolveThemeValue } from "../../core/theme/resolve-theme-value.js";
|
|
5
|
+
import { resolveAxisPadding } from "../../core/styles/resolve-axis-padding.js";
|
|
6
|
+
import stack_module_default from "./stack.module.js";
|
|
7
|
+
import { clsx } from "clsx";
|
|
8
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
9
|
+
//#region src/components/stack/stack.tsx
|
|
10
|
+
var Stack = ({ className, direction = "column", fillChildren = true, hAlign = "initial", hPadding, inline = false, maxWidth, minWidth, ref, render, rowGap, columnGap, style, vAlign = "initial", vPadding, wrap = false, ...otherProps }) => {
|
|
11
|
+
const hasPadding = Boolean(hPadding || vPadding);
|
|
12
|
+
const { componentProps, intrinsicAttributes } = extractIntrinsicViraProps(otherProps);
|
|
13
|
+
const dynamicStyle = {
|
|
14
|
+
"--stack-row-gap": resolveThemeValue(rowGap, "space", 0),
|
|
15
|
+
"--stack-column-gap": resolveThemeValue(columnGap, "space", 0),
|
|
16
|
+
"--stack-h-align": hAlign,
|
|
17
|
+
"--stack-v-align": vAlign,
|
|
18
|
+
...maxWidth ? { "--stack-max-width": maxWidth } : {},
|
|
19
|
+
...minWidth ? { "--stack-min-width": minWidth } : {},
|
|
20
|
+
...resolveAxisPadding(hPadding, "--stack-padding-inline-start", "--stack-padding-inline-end"),
|
|
21
|
+
...resolveAxisPadding(vPadding, "--stack-padding-block-start", "--stack-padding-block-end"),
|
|
22
|
+
...style
|
|
23
|
+
};
|
|
24
|
+
return useRender({
|
|
25
|
+
defaultTagName: "div",
|
|
26
|
+
render,
|
|
27
|
+
ref,
|
|
28
|
+
props: {
|
|
29
|
+
...componentProps,
|
|
30
|
+
...intrinsicAttributes,
|
|
31
|
+
"data-stack-direction": direction,
|
|
32
|
+
"data-stack-inline": inline ? "true" : "false",
|
|
33
|
+
"data-stack-wrap": wrap ? "true" : "false",
|
|
34
|
+
"data-stack-fill-children": fillChildren ? "true" : "false",
|
|
35
|
+
"data-stack-has-padding": hasPadding ? "true" : "false",
|
|
36
|
+
className: clsx(stack_module_default.Stack, className),
|
|
37
|
+
style: dynamicStyle
|
|
38
|
+
}
|
|
39
|
+
});
|
|
38
40
|
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Stack };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Surface } from './surface
|
|
2
|
-
export type { SurfaceProps } from './surface
|
|
1
|
+
export { Surface } from './surface';
|
|
2
|
+
export type { SurfaceProps } from './surface';
|
|
@@ -1,70 +1 @@
|
|
|
1
|
-
@
|
|
2
|
-
:scope {
|
|
3
|
-
--surface-background-hover: var(--surface-background);
|
|
4
|
-
--surface-border-radius: var(--radius-medium);
|
|
5
|
-
--surface-padding-inline-start: 0;
|
|
6
|
-
--surface-padding-inline-end: 0;
|
|
7
|
-
--surface-padding-block-start: 0;
|
|
8
|
-
--surface-padding-block-end: 0;
|
|
9
|
-
|
|
10
|
-
position: relative;
|
|
11
|
-
box-sizing: border-box;
|
|
12
|
-
background: var(--surface-background, transparent);
|
|
13
|
-
border-radius: var(--surface-border-radius);
|
|
14
|
-
border: 0;
|
|
15
|
-
|
|
16
|
-
&[data-surface-has-padding='true'] {
|
|
17
|
-
padding: var(--surface-padding-block-start) var(--surface-padding-inline-end) var(--surface-padding-block-end)
|
|
18
|
-
var(--surface-padding-inline-start);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&[data-surface-border] {
|
|
22
|
-
border-style: solid;
|
|
23
|
-
border-color: var(--global-contrast);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&[data-surface-border='all'] {
|
|
27
|
-
border-width: 1px;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
&[data-surface-border='top'] {
|
|
31
|
-
border-width: 1px 0 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&[data-surface-border='right'] {
|
|
35
|
-
border-width: 0 1px 0 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&[data-surface-border='bottom'] {
|
|
39
|
-
border-width: 0 0 1px;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&[data-surface-border='left'] {
|
|
43
|
-
border-width: 0 0 0 1px;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&[data-surface-border='x'] {
|
|
47
|
-
border-width: 0 1px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&[data-surface-border='y'] {
|
|
51
|
-
border-width: 1px 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@media (hover: hover) and (pointer: fine) {
|
|
55
|
-
&[data-surface-has-hover-color='true']:hover {
|
|
56
|
-
animation: surface-background-hover var(--duration-fast) var(--easing-standard);
|
|
57
|
-
animation-fill-mode: both;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@keyframes surface-background-hover {
|
|
63
|
-
from {
|
|
64
|
-
background: var(--surface-background);
|
|
65
|
-
}
|
|
66
|
-
to {
|
|
67
|
-
background: var(--surface-background-hover);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
.surface-module_Surface_slEYq{--surface-background-hover:var(--surface-background);--surface-border-radius:var(--radius-medium);--surface-padding-inline-start:0;--surface-padding-inline-end:0;--surface-padding-block-start:0;--surface-padding-block-end:0;position:relative;box-sizing:border-box;background:var(--surface-background,transparent);border-radius:var(--surface-border-radius);border:0;&[data-surface-has-padding=true]{padding:var(--surface-padding-block-start) var(--surface-padding-inline-end) var(--surface-padding-block-end) var(--surface-padding-inline-start)}&[data-surface-border]{border-style:var(--surface-border-style,solid);border-color:var(--global-contrast)}&[data-surface-border=all]{border-width:1px}&[data-surface-border=top]{border-width:1px 0 0}&[data-surface-border=right]{border-width:0 1px 0 0}&[data-surface-border=bottom]{border-width:0 0 1px}&[data-surface-border=left]{border-width:0 0 0 1px}&[data-surface-border=x]{border-width:0 1px}&[data-surface-border=y]{border-width:1px 0}@media (hover:hover) and (pointer:fine){&[data-surface-has-hover-color=true]:hover{animation:surface-module_surface-background-hover_HwH9- var(--duration-fast) var(--easing-standard);animation-fill-mode:both}}}@keyframes surface-module_surface-background-hover_HwH9-{to{background:var(--surface-background-hover)}}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { useRender } from '@base-ui/react/use-render';
|
|
2
|
-
import
|
|
2
|
+
import { IntrinsicViraProps } from '../../core/props/intrinsic-vira-props';
|
|
3
|
+
import { ThemeTypes } from '@viraui/foundation/vira/types';
|
|
3
4
|
import type * as React from 'react';
|
|
4
|
-
import './surface.css';
|
|
5
|
-
import type { IntrinsicViraProps } from '../../core/props/intrinsic-vira-props.js';
|
|
6
5
|
/** Base ramp layer for nested surfaces; clamped to 1–3 at runtime. */
|
|
7
6
|
type SurfaceBaseLevel = 1 | 2 | 3;
|
|
8
7
|
type SurfaceColor = string | SurfaceBaseLevel;
|
|
9
|
-
type SurfaceAxisPadding = ThemeTypes['space'] | [ThemeTypes['space'] | 0, ThemeTypes['space'] | 0];
|
|
10
8
|
/**
|
|
11
9
|
* Public Surface props.
|
|
12
10
|
*
|
|
@@ -46,6 +44,12 @@ export type SurfaceProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'color'>
|
|
|
46
44
|
* @default No border.
|
|
47
45
|
*/
|
|
48
46
|
border?: 'all' | 'top' | 'right' | 'bottom' | 'left' | 'x' | 'y';
|
|
47
|
+
/**
|
|
48
|
+
* Sets the CSS border style when `border` is set.
|
|
49
|
+
*
|
|
50
|
+
* @default solid
|
|
51
|
+
*/
|
|
52
|
+
borderStyle?: 'solid' | 'dashed' | 'dotted' | 'double';
|
|
49
53
|
/**
|
|
50
54
|
* Sets the corner radius from the Vira radius token scale.
|
|
51
55
|
*
|
|
@@ -57,13 +61,13 @@ export type SurfaceProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'color'>
|
|
|
57
61
|
*
|
|
58
62
|
* @default No inline padding.
|
|
59
63
|
*/
|
|
60
|
-
hPadding?:
|
|
64
|
+
hPadding?: ThemeTypes['space'] | [ThemeTypes['space'] | 0, ThemeTypes['space'] | 0];
|
|
61
65
|
/**
|
|
62
66
|
* Sets block padding using one token for both sides or a `[start, end]` tuple.
|
|
63
67
|
*
|
|
64
68
|
* @default No block padding.
|
|
65
69
|
*/
|
|
66
|
-
vPadding?:
|
|
70
|
+
vPadding?: ThemeTypes['space'] | [ThemeTypes['space'] | 0, ThemeTypes['space'] | 0];
|
|
67
71
|
};
|
|
68
72
|
export declare const Surface: React.FC<SurfaceProps>;
|
|
69
73
|
export {};
|
|
@@ -1,43 +1,46 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
-
import { extractIntrinsicViraProps } from '../../core/props/intrinsic-vira-props.js';
|
|
4
|
-
import { resolveAxisPadding } from '../../core/styles/resolve-axis-padding.js';
|
|
5
|
-
import { resolveThemeValue } from '../../core/theme/resolve-theme-value.js';
|
|
6
|
-
import { clsx } from 'clsx';
|
|
7
1
|
import './surface.css';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
"use client";
|
|
3
|
+
import { extractIntrinsicViraProps } from "../../core/props/intrinsic-vira-props.js";
|
|
4
|
+
import { resolveThemeValue } from "../../core/theme/resolve-theme-value.js";
|
|
5
|
+
import { resolveAxisPadding } from "../../core/styles/resolve-axis-padding.js";
|
|
6
|
+
import surface_module_default from "./surface.module.js";
|
|
7
|
+
import { clsx } from "clsx";
|
|
8
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
9
|
+
//#region src/components/surface/surface.tsx
|
|
10
|
+
var clampSurfaceBaseLevel = (value) => {
|
|
11
|
+
if (value <= 1) return 1;
|
|
12
|
+
if (value >= 3) return 3;
|
|
13
|
+
return value;
|
|
14
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
|
-
|
|
15
|
+
var toSurfaceColor = (value) => typeof value === "string" ? value : `var(--base-${clampSurfaceBaseLevel(value)})`;
|
|
16
|
+
var Surface = ({ border, borderStyle = "solid", className, color, hPadding, hoverColor, radius, ref, render, style, vPadding, ...otherProps }) => {
|
|
17
|
+
const hasColor = color !== void 0;
|
|
18
|
+
const hasPadding = Boolean(hPadding || vPadding);
|
|
19
|
+
const hasHoverColor = hoverColor !== void 0;
|
|
20
|
+
const { componentProps, intrinsicAttributes } = extractIntrinsicViraProps(otherProps);
|
|
21
|
+
const dynamicStyle = {
|
|
22
|
+
...hasColor ? { "--surface-background": toSurfaceColor(color) } : {},
|
|
23
|
+
...hasHoverColor ? { "--surface-background-hover": toSurfaceColor(hoverColor) } : {},
|
|
24
|
+
...border ? { "--surface-border-style": borderStyle } : {},
|
|
25
|
+
"--surface-border-radius": resolveThemeValue(radius, "radius", "var(--radius-medium)"),
|
|
26
|
+
...resolveAxisPadding(hPadding, "--surface-padding-inline-start", "--surface-padding-inline-end"),
|
|
27
|
+
...resolveAxisPadding(vPadding, "--surface-padding-block-start", "--surface-padding-block-end"),
|
|
28
|
+
...style
|
|
29
|
+
};
|
|
30
|
+
return useRender({
|
|
31
|
+
defaultTagName: "div",
|
|
32
|
+
render,
|
|
33
|
+
ref,
|
|
34
|
+
props: {
|
|
35
|
+
...componentProps,
|
|
36
|
+
...intrinsicAttributes,
|
|
37
|
+
...border ? { "data-surface-border": border } : {},
|
|
38
|
+
"data-surface-has-hover-color": hasHoverColor ? "true" : "false",
|
|
39
|
+
"data-surface-has-padding": hasPadding ? "true" : "false",
|
|
40
|
+
className: clsx(surface_module_default.Surface, className),
|
|
41
|
+
style: dynamicStyle
|
|
42
|
+
}
|
|
43
|
+
});
|
|
43
44
|
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { Surface };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Switch } from './switch
|
|
2
|
-
export type { SwitchProps } from './switch
|
|
1
|
+
export { Switch } from './switch';
|
|
2
|
+
export type { SwitchProps } from './switch';
|
|
@@ -1,73 +1 @@
|
|
|
1
|
-
|
|
2
|
-
:scope {
|
|
3
|
-
--switch-track-block-size: var(--space-large);
|
|
4
|
-
--switch-track-radius: var(--radius-small);
|
|
5
|
-
--switch-track-background: var(--global-contrast);
|
|
6
|
-
--switch-thumb-background: var(--global-primary);
|
|
7
|
-
--switch-thumb-size: calc(var(--space-large) - var(--space-x-small));
|
|
8
|
-
--switch-thumb-inset: var(--space-2x-small);
|
|
9
|
-
--switch-thumb-radius: calc(var(--radius-x-small) + var(--switch-thumb-inset));
|
|
10
|
-
|
|
11
|
-
> .SwitchRoot {
|
|
12
|
-
position: relative;
|
|
13
|
-
appearance: none;
|
|
14
|
-
border: 0;
|
|
15
|
-
box-shadow: none;
|
|
16
|
-
inline-size: calc((var(--switch-thumb-size) * 2) + var(--switch-thumb-inset) * 2);
|
|
17
|
-
block-size: var(--switch-track-block-size);
|
|
18
|
-
background: var(--switch-track-background);
|
|
19
|
-
border-radius: var(--switch-track-radius);
|
|
20
|
-
|
|
21
|
-
&[data-size='small'] {
|
|
22
|
-
--switch-track-radius: var(--radius-x-small);
|
|
23
|
-
--switch-track-block-size: var(--space-medium);
|
|
24
|
-
--switch-thumb-size: calc(var(--space-medium) - var(--space-x-small));
|
|
25
|
-
--switch-thumb-radius: calc(var(--radius-x-small) - var(--switch-thumb-inset));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* Checked track and thumb colors when not disabled or invalid */
|
|
29
|
-
&[data-checked]:not([data-disabled]):not([data-invalid]) {
|
|
30
|
-
--switch-track-background: var(--global-primary);
|
|
31
|
-
--switch-thumb-background: var(--base-1);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/* Invalid: red inset border and focus outline on SwitchRoot (from parent or root data-invalid) */
|
|
35
|
-
:scope[data-invalid] > &:not([data-disabled]),
|
|
36
|
-
&[data-invalid]:not([data-disabled]) {
|
|
37
|
-
box-shadow: inset 0 0 0 1px var(--highlight-red);
|
|
38
|
-
outline-color: oklab(from var(--highlight-red) l a b / 0.5);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/* Disabled: muted track/thumb and no shadow (from parent or root data-disabled) */
|
|
42
|
-
:scope[data-disabled] > &,
|
|
43
|
-
&[data-disabled] {
|
|
44
|
-
--switch-track-background: var(--global-disabled-background);
|
|
45
|
-
--switch-thumb-background: var(--global-disabled-foreground);
|
|
46
|
-
box-shadow: none;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
> .Thumb {
|
|
50
|
-
position: absolute;
|
|
51
|
-
inset-block: var(--switch-thumb-inset);
|
|
52
|
-
inset-inline-start: var(--switch-thumb-inset);
|
|
53
|
-
background: var(--switch-thumb-background);
|
|
54
|
-
inline-size: var(--switch-thumb-size);
|
|
55
|
-
block-size: var(--switch-thumb-size);
|
|
56
|
-
border-radius: var(--switch-thumb-radius);
|
|
57
|
-
transition: translate var(--easing-entrance) var(--duration-fast);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
&[data-checked] > .Thumb {
|
|
61
|
-
translate: 100% 0;
|
|
62
|
-
}
|
|
63
|
-
&[data-checked]:dir(rtl) > .Thumb {
|
|
64
|
-
translate: -100% 0;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
> .Copy > .Label {
|
|
69
|
-
-webkit-user-select: none;
|
|
70
|
-
user-select: none;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
1
|
+
.switch-module_Switch_L86y7{--switch-track-block-size:var(--space-large);--switch-track-radius:var(--radius-small);--switch-track-background:var(--global-contrast);--switch-thumb-background:var(--global-primary);--switch-thumb-size:calc(var(--space-large) - var(--space-x-small));--switch-thumb-inset:var(--space-2x-small);--switch-thumb-radius:calc(var(--radius-x-small) + var(--switch-thumb-inset));&:has([required]) [data-field-label]:after{content:" *";color:var(--highlight-red)}}.switch-module_SwitchRoot_Zv9An{position:relative;appearance:none;border:0;box-shadow:none;inline-size:calc((var(--switch-thumb-size) * 2) + var(--switch-thumb-inset) * 2);block-size:var(--switch-track-block-size);background:var(--switch-track-background);border-radius:var(--switch-track-radius);&[data-size=small]{--switch-track-radius:var(--radius-x-small);--switch-track-block-size:var(--space-medium);--switch-thumb-size:calc(var(--space-medium) - var(--space-x-small));--switch-thumb-radius:calc(var(--radius-x-small) - var(--switch-thumb-inset))}&[data-checked]:not([data-disabled]):not([data-invalid]){--switch-track-background:var(--global-primary);--switch-thumb-background:var(--base-1)}&[data-invalid]:not([data-disabled]),.switch-module_Switch_L86y7[data-invalid]>&:not([data-disabled]){box-shadow:inset 0 0 0 1px var(--highlight-red);outline-color:oklab(from var(--highlight-red) l a b/.5)}&[data-disabled],.switch-module_Switch_L86y7[data-disabled]>&{--switch-track-background:var(--global-disabled-background);--switch-thumb-background:var(--global-disabled-foreground);box-shadow:none}}.switch-module_Thumb_ldwJw{position:absolute;inset-block:var(--switch-thumb-inset);inset-inline-start:var(--switch-thumb-inset);background:var(--switch-thumb-background);inline-size:var(--switch-thumb-size);block-size:var(--switch-thumb-size);border-radius:var(--switch-thumb-radius);transition:translate var(--easing-entrance) var(--duration-fast);.switch-module_SwitchRoot_Zv9An[data-checked]>&{translate:100% 0}.switch-module_SwitchRoot_Zv9An[data-checked]:dir(rtl)>&{translate:-100% 0}}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { FieldRoot } from '@base-ui/react/field';
|
|
2
|
+
import { SwitchRoot } from '@base-ui/react/switch';
|
|
3
|
+
import { StackProps } from '..';
|
|
4
|
+
import { IntrinsicViraProps } from '../../core/props/intrinsic-vira-props';
|
|
3
5
|
import type * as React from 'react';
|
|
4
|
-
import type { IntrinsicViraProps } from '../../core/props/intrinsic-vira-props.js';
|
|
5
|
-
import './switch.css';
|
|
6
6
|
/**
|
|
7
7
|
* Public Switch props.
|
|
8
8
|
*
|
|
@@ -26,7 +26,7 @@ export type SwitchProps = SwitchRoot.Props & Omit<FieldRoot.Props, 'ref'> & {
|
|
|
26
26
|
*/
|
|
27
27
|
shrink?: IntrinsicViraProps['shrink'];
|
|
28
28
|
/**
|
|
29
|
-
* Visible label rendered with
|
|
29
|
+
* Visible label rendered with shared internal `FieldLabel`.
|
|
30
30
|
*
|
|
31
31
|
* @default No label is rendered.
|
|
32
32
|
*/
|
|
@@ -50,5 +50,17 @@ export type SwitchProps = SwitchRoot.Props & Omit<FieldRoot.Props, 'ref'> & {
|
|
|
50
50
|
* @default 'small'
|
|
51
51
|
*/
|
|
52
52
|
size?: 'regular' | 'small';
|
|
53
|
+
/**
|
|
54
|
+
* Sets block padding using one token for both sides or a `[start, end]` tuple.
|
|
55
|
+
*
|
|
56
|
+
* @default No block padding.
|
|
57
|
+
*/
|
|
58
|
+
vPadding?: StackProps['vPadding'];
|
|
59
|
+
/**
|
|
60
|
+
* Sets inline padding using one token for both sides or a `[start, end]` tuple.
|
|
61
|
+
*
|
|
62
|
+
* @default No inline padding.
|
|
63
|
+
*/
|
|
64
|
+
hPadding?: StackProps['hPadding'];
|
|
53
65
|
};
|
|
54
66
|
export declare const Switch: React.FC<SwitchProps>;
|
|
@@ -1,15 +1,61 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Field } from '@base-ui/react/field';
|
|
4
|
-
import { Switch as PrimitiveSwitch } from '@base-ui/react/switch';
|
|
5
|
-
import { FieldHelperCopy } from '../../components/basic-input/field-helper-copy.js';
|
|
6
|
-
import { Stack } from '../../components/stack/index.js';
|
|
7
|
-
import { Text } from '../../components/text/index.js';
|
|
8
|
-
import { extractIntrinsicViraProps } from '../../core/props/intrinsic-vira-props.js';
|
|
9
|
-
import { clsx } from 'clsx';
|
|
10
1
|
import './switch.css';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
"use client";
|
|
3
|
+
import { extractIntrinsicViraProps } from "../../core/props/intrinsic-vira-props.js";
|
|
4
|
+
import { FieldHelperCopy } from "../basic-input/field-helper-copy.js";
|
|
5
|
+
import { FieldLabel } from "../basic-input/field-label.js";
|
|
6
|
+
import { Stack } from "../stack/stack.js";
|
|
7
|
+
import switch_module_default from "./switch.module.js";
|
|
8
|
+
import { clsx } from "clsx";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Field } from "@base-ui/react/field";
|
|
11
|
+
import { Switch } from "@base-ui/react/switch";
|
|
12
|
+
//#region src/components/switch/switch.tsx
|
|
13
|
+
var Switch$1 = ({ className, description, dirty, disabled, error, invalid, label, name, ref, size = "small", vPadding, hPadding, touched, validate, validationDebounceTime, validationMode, ...switchRootProps }) => {
|
|
14
|
+
const hasTextDescription = Boolean(description || error);
|
|
15
|
+
const { componentProps, intrinsicAttributes } = extractIntrinsicViraProps(switchRootProps);
|
|
16
|
+
return /* @__PURE__ */ jsx(Field.Root, {
|
|
17
|
+
...intrinsicAttributes,
|
|
18
|
+
className: switch_module_default.Switch,
|
|
19
|
+
dirty,
|
|
20
|
+
disabled,
|
|
21
|
+
invalid,
|
|
22
|
+
name,
|
|
23
|
+
touched,
|
|
24
|
+
validate,
|
|
25
|
+
validationDebounceTime,
|
|
26
|
+
validationMode,
|
|
27
|
+
render: /* @__PURE__ */ jsx(Stack, {
|
|
28
|
+
direction: "row",
|
|
29
|
+
columnGap: size === "small" ? "small" : "medium",
|
|
30
|
+
fillChildren: false,
|
|
31
|
+
vAlign: hasTextDescription ? "start" : "center"
|
|
32
|
+
}),
|
|
33
|
+
children: /* @__PURE__ */ jsx(Field.Label, { children: /* @__PURE__ */ jsxs(Stack, {
|
|
34
|
+
direction: "row",
|
|
35
|
+
columnGap: size === "small" ? "small" : "medium",
|
|
36
|
+
fillChildren: false,
|
|
37
|
+
vAlign: hasTextDescription ? "start" : "center",
|
|
38
|
+
...hPadding !== void 0 ? { hPadding } : {},
|
|
39
|
+
...vPadding !== void 0 ? { vPadding } : {},
|
|
40
|
+
children: [/* @__PURE__ */ jsx(Switch.Root, {
|
|
41
|
+
...componentProps,
|
|
42
|
+
className: clsx(switch_module_default.SwitchRoot, className),
|
|
43
|
+
"data-size": size,
|
|
44
|
+
disabled,
|
|
45
|
+
name,
|
|
46
|
+
ref,
|
|
47
|
+
children: /* @__PURE__ */ jsx(Switch.Thumb, { className: switch_module_default.Thumb })
|
|
48
|
+
}), label || description || error ? /* @__PURE__ */ jsxs(Stack, {
|
|
49
|
+
direction: "column",
|
|
50
|
+
fillChildren: false,
|
|
51
|
+
rowGap: size === "small" ? "2x-small" : "x-small",
|
|
52
|
+
children: [label && /* @__PURE__ */ jsx(FieldLabel, { children: label }), /* @__PURE__ */ jsx(FieldHelperCopy, {
|
|
53
|
+
description,
|
|
54
|
+
error
|
|
55
|
+
})]
|
|
56
|
+
}) : null]
|
|
57
|
+
}) })
|
|
58
|
+
});
|
|
15
59
|
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { Switch$1 as Switch };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Text } from './text
|
|
2
|
-
export type { TextProps } from './text
|
|
1
|
+
export { Text } from './text';
|
|
2
|
+
export type { TextProps } from './text';
|