@solostylist/ui-kit 2.0.1 → 2.0.3
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/s-animated-gradient-text/index.d.ts +2 -0
- package/dist/s-animated-gradient-text/index.js +2 -0
- package/dist/s-animated-gradient-text/s-animated-gradient-text.d.ts +64 -0
- package/dist/s-animated-gradient-text/s-animated-gradient-text.js +92 -0
- package/dist/s-announcement-bar/index.d.ts +2 -0
- package/dist/s-announcement-bar/index.js +2 -0
- package/dist/s-announcement-bar/s-announcement-bar.d.ts +113 -0
- package/dist/s-announcement-bar/s-announcement-bar.js +272 -0
- package/dist/s-carousel/s-carousel.d.ts +2 -0
- package/dist/s-carousel/s-carousel.js +52 -50
- package/dist/s-date-picker/s-date-picker.js +1 -1
- package/dist/s-datetime-picker/s-datetime-picker.js +1 -1
- package/dist/s-drawer/index.d.ts +3 -0
- package/dist/s-drawer/index.js +2 -0
- package/dist/s-drawer/s-drawer.d.ts +70 -0
- package/dist/s-drawer/s-drawer.js +139 -0
- package/dist/s-gradient-blob-pulse/index.d.ts +2 -0
- package/dist/s-gradient-blob-pulse/index.js +2 -0
- package/dist/s-gradient-blob-pulse/s-gradient-blob-pulse.d.ts +62 -0
- package/dist/s-gradient-blob-pulse/s-gradient-blob-pulse.js +236 -0
- package/dist/s-gradient-icon/index.d.ts +1 -1
- package/dist/s-gradient-icon/s-gradient-icon.d.ts +4 -4
- package/dist/s-gradient-icon/s-gradient-icon.js +2 -2
- package/dist/s-icon-button/s-icon-button.d.ts +6 -2
- package/dist/s-interactive-card/index.d.ts +3 -0
- package/dist/s-interactive-card/index.js +2 -0
- package/dist/s-interactive-card/s-interactive-card.d.ts +57 -0
- package/dist/s-interactive-card/s-interactive-card.js +150 -0
- package/dist/s-language-switcher/s-language-switcher.js +66 -71
- package/dist/s-list-action-item/index.d.ts +2 -0
- package/dist/s-list-action-item/index.js +2 -0
- package/dist/s-list-action-item/s-list-action-item.d.ts +89 -0
- package/dist/s-list-action-item/s-list-action-item.js +149 -0
- package/dist/s-mega-menu/index.d.ts +3 -0
- package/dist/s-mega-menu/index.js +2 -0
- package/dist/s-mega-menu/mega-menu-panel.d.ts +38 -0
- package/dist/s-mega-menu/mega-menu-panel.js +251 -0
- package/dist/s-mega-menu/mega-menu-slots.d.ts +65 -0
- package/dist/s-mega-menu/mega-menu-slots.js +232 -0
- package/dist/s-mega-menu/mega-menu-trigger.d.ts +35 -0
- package/dist/s-mega-menu/mega-menu-trigger.js +49 -0
- package/dist/s-mega-menu/s-mega-menu.d.ts +23 -0
- package/dist/s-mega-menu/s-mega-menu.js +225 -0
- package/dist/s-mega-menu/types.d.ts +188 -0
- package/dist/s-mega-menu/types.js +0 -0
- package/dist/s-mega-menu/utils.d.ts +51 -0
- package/dist/s-mega-menu/utils.js +51 -0
- package/dist/s-mobile-dock/index.d.ts +3 -0
- package/dist/s-mobile-dock/index.js +2 -0
- package/dist/s-mobile-dock/s-mobile-dock.d.ts +96 -0
- package/dist/s-mobile-dock/s-mobile-dock.js +145 -0
- package/dist/s-nav-item/index.d.ts +1 -1
- package/dist/s-nav-item/s-nav-item.d.ts +35 -16
- package/dist/s-nav-item/s-nav-item.js +55 -77
- package/dist/s-nav-items/s-nav-items.js +68 -112
- package/dist/s-number-range/index.d.ts +3 -0
- package/dist/s-number-range/index.js +2 -0
- package/dist/s-number-range/s-number-range.d.ts +109 -0
- package/dist/s-number-range/s-number-range.js +250 -0
- package/dist/s-popover/index.d.ts +5 -0
- package/dist/s-popover/index.js +3 -0
- package/dist/s-popover/placement.d.ts +14 -0
- package/dist/s-popover/placement.js +65 -0
- package/dist/s-popover/s-popover-content.d.ts +22 -0
- package/dist/s-popover/s-popover-content.js +21 -0
- package/dist/s-popover/s-popover.d.ts +59 -0
- package/dist/s-popover/s-popover.js +66 -0
- package/dist/s-product-card/index.d.ts +3 -0
- package/dist/s-product-card/index.js +2 -0
- package/dist/s-product-card/s-product-card.d.ts +216 -0
- package/dist/s-product-card/s-product-card.js +499 -0
- package/dist/s-product-gallery/index.d.ts +3 -0
- package/dist/s-product-gallery/index.js +2 -0
- package/dist/s-product-gallery/s-product-gallery.d.ts +116 -0
- package/dist/s-product-gallery/s-product-gallery.js +427 -0
- package/dist/s-scroll-to-top/s-scroll-to-top.d.ts +1 -1
- package/dist/s-segmented-control/index.d.ts +3 -0
- package/dist/s-segmented-control/index.js +2 -0
- package/dist/s-segmented-control/s-segmented-control.d.ts +94 -0
- package/dist/s-segmented-control/s-segmented-control.js +298 -0
- package/dist/s-stepper/index.d.ts +3 -0
- package/dist/s-stepper/index.js +2 -0
- package/dist/s-stepper/s-stepper.d.ts +90 -0
- package/dist/s-stepper/s-stepper.js +102 -0
- package/dist/s-swatch/index.d.ts +3 -0
- package/dist/s-swatch/index.js +2 -0
- package/dist/s-swatch/s-swatch.d.ts +235 -0
- package/dist/s-swatch/s-swatch.js +218 -0
- package/dist/s-text-editor/s-text-editor-toolbar.js +105 -108
- package/dist/s-tool-item/s-tool-item.d.ts +10 -6
- package/dist/s-tool-item/s-tool-item.js +12 -12
- package/dist/theme/component-augmentation.d.ts +65 -1
- package/dist/theme/components/drawer.d.ts +1 -0
- package/dist/theme/components/drawer.js +4 -1
- package/dist/theme/components/slider.js +18 -1
- package/dist/theme/components/step-connector.d.ts +0 -3
- package/dist/theme/components/step-connector.js +1 -6
- package/dist/theme/components/step-icon.d.ts +3 -12
- package/dist/theme/components/step-icon.js +3 -14
- package/package.json +7 -2
- package/dist/theme/components/components.d.ts +0 -2
- package/dist/theme/components/slider.d.ts +0 -34
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { BoxProps, SliderProps, SxProps, Theme } from '@mui/material';
|
|
2
|
+
import { STextFieldProps } from '../s-text-field';
|
|
3
|
+
import { OwnerStateSlotProps as MuiOwnerStateSlotProps } from '../utils/slots';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/** Inclusive `[minimum, maximum]` pair emitted by the control. */
|
|
6
|
+
export type SNumberRangeValue = readonly [number, number];
|
|
7
|
+
/** Density of the slider and the two numeric inputs. */
|
|
8
|
+
export type SNumberRangeSize = 'small' | 'medium';
|
|
9
|
+
/** Theme color shared by the slider and the focus state of both inputs. */
|
|
10
|
+
export type SNumberRangeColor = NonNullable<SliderProps['color']>;
|
|
11
|
+
type SNumberRangeFieldsetProps = Omit<React.ComponentPropsWithoutRef<'fieldset'>, 'children' | 'color' | 'defaultValue' | 'onChange' | 'value'> & {
|
|
12
|
+
sx?: SxProps<Theme>;
|
|
13
|
+
};
|
|
14
|
+
type SNumberRangeLegendProps = Omit<React.ComponentPropsWithoutRef<'legend'>, 'children'> & {
|
|
15
|
+
sx?: SxProps<Theme>;
|
|
16
|
+
};
|
|
17
|
+
export interface SNumberRangeSlots {
|
|
18
|
+
/** Row wrapping the two numeric inputs and the separator. */
|
|
19
|
+
inputs?: React.ElementType;
|
|
20
|
+
/** Optional group label rendered as the fieldset legend. */
|
|
21
|
+
label?: React.ElementType;
|
|
22
|
+
/** Numeric input bound to `value[1]`. */
|
|
23
|
+
maxInput?: React.ElementType;
|
|
24
|
+
/** Numeric input bound to `value[0]`. */
|
|
25
|
+
minInput?: React.ElementType;
|
|
26
|
+
/** Outer fieldset. */
|
|
27
|
+
root?: React.ElementType;
|
|
28
|
+
/** Element rendered between the two numeric inputs. */
|
|
29
|
+
separator?: React.ElementType;
|
|
30
|
+
/** Dual-thumb range slider. */
|
|
31
|
+
slider?: React.ElementType;
|
|
32
|
+
}
|
|
33
|
+
export interface SNumberRangeSlotProps {
|
|
34
|
+
/** Props or owner-state callback for the inputs row. */
|
|
35
|
+
inputs?: MuiOwnerStateSlotProps<Omit<BoxProps, 'children'>, SNumberRangeOwnerState>;
|
|
36
|
+
/** Props or owner-state callback for the group label. */
|
|
37
|
+
label?: MuiOwnerStateSlotProps<SNumberRangeLegendProps, SNumberRangeOwnerState>;
|
|
38
|
+
/** Props or owner-state callback for the maximum input. */
|
|
39
|
+
maxInput?: MuiOwnerStateSlotProps<Omit<STextFieldProps, 'color' | 'defaultValue' | 'disabled' | 'error' | 'size' | 'type' | 'value'>, SNumberRangeOwnerState>;
|
|
40
|
+
/** Props or owner-state callback for the minimum input. */
|
|
41
|
+
minInput?: MuiOwnerStateSlotProps<Omit<STextFieldProps, 'color' | 'defaultValue' | 'disabled' | 'error' | 'size' | 'type' | 'value'>, SNumberRangeOwnerState>;
|
|
42
|
+
/** Props or owner-state callback for the root slot. */
|
|
43
|
+
root?: MuiOwnerStateSlotProps<Omit<SNumberRangeFieldsetProps, 'disabled'>, SNumberRangeOwnerState>;
|
|
44
|
+
/** Props or owner-state callback for the separator slot. */
|
|
45
|
+
separator?: MuiOwnerStateSlotProps<Omit<BoxProps, 'children'>, SNumberRangeOwnerState>;
|
|
46
|
+
/** Props or owner-state callback for the slider slot. */
|
|
47
|
+
slider?: MuiOwnerStateSlotProps<Omit<SliderProps, 'color' | 'defaultValue' | 'disableSwap' | 'disabled' | 'getAriaLabel' | 'getAriaValueText' | 'max' | 'min' | 'onChange' | 'onChangeCommitted' | 'size' | 'step' | 'value'>, SNumberRangeOwnerState>;
|
|
48
|
+
}
|
|
49
|
+
/** Props for a dual-thumb numeric range with synchronized min/max text inputs. */
|
|
50
|
+
export interface SNumberRangeProps extends SNumberRangeFieldsetProps {
|
|
51
|
+
/** Theme color shared by the slider and the focus state of both inputs. */
|
|
52
|
+
color?: SNumberRangeColor;
|
|
53
|
+
/** Initial range when the control is uncontrolled. Defaults to `[min, max]`. */
|
|
54
|
+
defaultValue?: SNumberRangeValue;
|
|
55
|
+
/** Disables the slider and both inputs. */
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
/** Accessible text formatter for each slider thumb. */
|
|
58
|
+
getAriaValueText?: SliderProps['getAriaValueText'];
|
|
59
|
+
/** Helper text shown while a typed draft is empty, out of range, or inverted. */
|
|
60
|
+
invalidRangeText?: React.ReactNode;
|
|
61
|
+
/** Optional visible label for the whole range group. */
|
|
62
|
+
label?: React.ReactNode;
|
|
63
|
+
/** Upper bound of the range. */
|
|
64
|
+
max?: number;
|
|
65
|
+
/** Accessible name of the upper thumb and the maximum input. */
|
|
66
|
+
maxLabel?: string;
|
|
67
|
+
/** Lower bound of the range. */
|
|
68
|
+
min?: number;
|
|
69
|
+
/** Accessible name of the lower thumb and the minimum input. */
|
|
70
|
+
minLabel?: string;
|
|
71
|
+
/** Called for every valid change while dragging or typing. */
|
|
72
|
+
onChange?: (event: Event | React.SyntheticEvent, value: SNumberRangeValue) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Called once the interaction settles: on slider release and when an input is
|
|
75
|
+
* blurred or committed with Enter. Use this as the persist/apply signal.
|
|
76
|
+
*/
|
|
77
|
+
onChangeCommitted?: (event: Event | React.SyntheticEvent, value: SNumberRangeValue) => void;
|
|
78
|
+
/** Content rendered between the two numeric inputs. */
|
|
79
|
+
separator?: React.ReactNode;
|
|
80
|
+
/** Density of the slider and the two numeric inputs. */
|
|
81
|
+
size?: SNumberRangeSize;
|
|
82
|
+
/** Props or owner-state callbacks for internal structural slots. */
|
|
83
|
+
slotProps?: SNumberRangeSlotProps;
|
|
84
|
+
/** Components used for internal structural slots. */
|
|
85
|
+
slots?: SNumberRangeSlots;
|
|
86
|
+
/** Granularity passed to the slider and both native number inputs. */
|
|
87
|
+
step?: number;
|
|
88
|
+
/** Controlled range. */
|
|
89
|
+
value?: SNumberRangeValue;
|
|
90
|
+
/** Formats the visual value label rendered above each slider thumb. */
|
|
91
|
+
valueLabelFormat?: SliderProps['valueLabelFormat'];
|
|
92
|
+
}
|
|
93
|
+
export interface SNumberRangeOwnerState extends SNumberRangeProps {
|
|
94
|
+
color: SNumberRangeColor;
|
|
95
|
+
disabled: boolean;
|
|
96
|
+
/** True when either numeric input renders a visible field label above the box. */
|
|
97
|
+
hasInputLabel: boolean;
|
|
98
|
+
max: number;
|
|
99
|
+
/** True while the maximum input holds an invalid draft. */
|
|
100
|
+
maxInvalid: boolean;
|
|
101
|
+
min: number;
|
|
102
|
+
/** True while the minimum input holds an invalid draft. */
|
|
103
|
+
minInvalid: boolean;
|
|
104
|
+
size: SNumberRangeSize;
|
|
105
|
+
step: number;
|
|
106
|
+
value: SNumberRangeValue;
|
|
107
|
+
}
|
|
108
|
+
export declare const SNumberRange: React.ForwardRefExoticComponent<SNumberRangeProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
109
|
+
export default SNumberRange;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { toSxArray as e } from "../utils/sx.js";
|
|
2
|
+
import { resolveOwnerStateSlotProps as t } from "../utils/slots.js";
|
|
3
|
+
import { STextField as n } from "../s-text-field/s-text-field.js";
|
|
4
|
+
import * as r from "react";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import { Box as o, Slider as s, styled as c, useThemeProps as ee } from "@mui/material";
|
|
7
|
+
import { mergeSlotProps as l, useControlled as te, useEventCallback as u, useForkRef as ne } from "@mui/material/utils";
|
|
8
|
+
import d from "@mui/utils/appendOwnerState";
|
|
9
|
+
import { sliderClasses as f } from "@mui/material/Slider";
|
|
10
|
+
//#region lib/s-number-range/s-number-range.tsx
|
|
11
|
+
var p = (e, t, n) => Math.min(Math.max(e, t), n), m = (e, t, n) => {
|
|
12
|
+
let r = p(e[0], t, n), i = p(e[1], t, n);
|
|
13
|
+
return r <= i ? [r, i] : [i, r];
|
|
14
|
+
}, h = (e) => {
|
|
15
|
+
if (e.trim() === "") return null;
|
|
16
|
+
let t = Number(e);
|
|
17
|
+
return Number.isFinite(t) ? t : null;
|
|
18
|
+
}, g = (e) => e != null && e !== !1 && e !== "", _ = (e, t, n, r) => e >= n && e <= r && t >= n && t <= r && e <= t, re = (e, t, n) => {
|
|
19
|
+
if (!Number.isFinite(e) || !Number.isFinite(t) || e >= t) throw RangeError("SNumberRange: `min` and `max` must be finite numbers and `min` must be less than `max`.");
|
|
20
|
+
if (!Number.isFinite(n) || n <= 0) throw RangeError("SNumberRange: `step` must be a finite number greater than 0.");
|
|
21
|
+
}, ie = c("fieldset", {
|
|
22
|
+
name: "SNumberRange",
|
|
23
|
+
slot: "Root",
|
|
24
|
+
shouldForwardProp: (e) => e !== "ownerState"
|
|
25
|
+
})(({ theme: e }) => ({
|
|
26
|
+
border: 0,
|
|
27
|
+
display: "flex",
|
|
28
|
+
flexDirection: "column",
|
|
29
|
+
gap: e.spacing(1),
|
|
30
|
+
margin: 0,
|
|
31
|
+
minWidth: 0,
|
|
32
|
+
padding: 0,
|
|
33
|
+
width: "100%"
|
|
34
|
+
})), ae = c("legend", {
|
|
35
|
+
name: "SNumberRange",
|
|
36
|
+
slot: "Label",
|
|
37
|
+
shouldForwardProp: (e) => e !== "ownerState"
|
|
38
|
+
})(({ theme: e }) => ({
|
|
39
|
+
...e.typography.body2,
|
|
40
|
+
color: (e.vars ?? e).palette.text.primary,
|
|
41
|
+
fontWeight: 600,
|
|
42
|
+
margin: 0,
|
|
43
|
+
padding: 0
|
|
44
|
+
})), oe = c(s, {
|
|
45
|
+
name: "SNumberRange",
|
|
46
|
+
slot: "Slider",
|
|
47
|
+
shouldForwardProp: (e) => e !== "ownerState"
|
|
48
|
+
})(({ theme: e, ownerState: t }) => {
|
|
49
|
+
let n = t.size === "small";
|
|
50
|
+
return {
|
|
51
|
+
color: (e.vars ?? e).palette[t.color].main,
|
|
52
|
+
height: n ? 2 : 3,
|
|
53
|
+
padding: e.spacing(n ? 1 : 1.5, 0),
|
|
54
|
+
[`& .${f.rail}`]: {
|
|
55
|
+
backgroundColor: (e.vars ?? e).palette.action.selected,
|
|
56
|
+
opacity: 1
|
|
57
|
+
},
|
|
58
|
+
[`& .${f.track}`]: { border: 0 },
|
|
59
|
+
[`& .${f.thumb}`]: {
|
|
60
|
+
border: `2px solid ${(e.vars ?? e).palette.background.paper}`,
|
|
61
|
+
boxShadow: `0 0 0 1px ${(e.vars ?? e).palette[t.color].main}`,
|
|
62
|
+
height: n ? 14 : 18,
|
|
63
|
+
width: n ? 14 : 18,
|
|
64
|
+
[`&:hover, &.${f.focusVisible}`]: { boxShadow: `0 0 0 6px ${(e.vars ?? e).palette.action.selected}` }
|
|
65
|
+
},
|
|
66
|
+
[`& .${f.mark}`]: {
|
|
67
|
+
backgroundColor: (e.vars ?? e).palette[t.color].main,
|
|
68
|
+
borderRadius: e.radius.sm,
|
|
69
|
+
height: n ? 8 : 10,
|
|
70
|
+
opacity: 1,
|
|
71
|
+
width: n ? 3 : 4
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}), se = c(o, {
|
|
75
|
+
name: "SNumberRange",
|
|
76
|
+
slot: "Inputs",
|
|
77
|
+
shouldForwardProp: (e) => e !== "ownerState"
|
|
78
|
+
})(({ theme: e }) => ({
|
|
79
|
+
alignItems: "flex-start",
|
|
80
|
+
display: "flex",
|
|
81
|
+
gap: e.spacing(1)
|
|
82
|
+
})), ce = c(n, {
|
|
83
|
+
name: "SNumberRange",
|
|
84
|
+
slot: "MinInput",
|
|
85
|
+
shouldForwardProp: (e) => e !== "ownerState"
|
|
86
|
+
})({
|
|
87
|
+
flex: "1 1 0",
|
|
88
|
+
minWidth: 0
|
|
89
|
+
}), le = c(n, {
|
|
90
|
+
name: "SNumberRange",
|
|
91
|
+
slot: "MaxInput",
|
|
92
|
+
shouldForwardProp: (e) => e !== "ownerState"
|
|
93
|
+
})({
|
|
94
|
+
flex: "1 1 0",
|
|
95
|
+
minWidth: 0
|
|
96
|
+
}), ue = c(o, {
|
|
97
|
+
name: "SNumberRange",
|
|
98
|
+
slot: "Separator",
|
|
99
|
+
shouldForwardProp: (e) => e !== "ownerState"
|
|
100
|
+
})(({ theme: e, ownerState: t }) => ({
|
|
101
|
+
alignItems: "center",
|
|
102
|
+
color: (e.vars ?? e).palette.text.secondary,
|
|
103
|
+
display: "inline-flex",
|
|
104
|
+
flex: "0 0 auto",
|
|
105
|
+
height: t.size === "small" ? 36 : 40,
|
|
106
|
+
marginTop: t.hasInputLabel ? "1.4375em" : 0,
|
|
107
|
+
paddingInline: e.spacing(.5),
|
|
108
|
+
userSelect: "none"
|
|
109
|
+
})), v = r.forwardRef(function(n, o) {
|
|
110
|
+
let s = ee({
|
|
111
|
+
props: n,
|
|
112
|
+
name: "SNumberRange"
|
|
113
|
+
}), { color: c = "primary", defaultValue: f, disabled: v = !1, getAriaValueText: de, invalidRangeText: y = "Enter a value inside the allowed range", label: b, max: x = 100, maxLabel: S = "Maximum", min: C = 0, minLabel: w = "Minimum", onChange: fe, onChangeCommitted: T, separator: pe = "–", size: E = "medium", slotProps: D, slots: O, step: k = 1, sx: me, value: he, valueLabelFormat: A, ...ge } = s;
|
|
114
|
+
re(C, x, k);
|
|
115
|
+
let [_e, ve] = te({
|
|
116
|
+
controlled: he,
|
|
117
|
+
default: f ?? [C, x],
|
|
118
|
+
name: "SNumberRange",
|
|
119
|
+
state: "value"
|
|
120
|
+
}), [ye, j] = r.useState(null), M = m(_e, C, x), N = M[0], P = M[1], F = ye ?? [String(M[0]), String(M[1])], I = h(F[0]), L = h(F[1]), be = I !== null && L !== null && _(I, L, C, x), R = I === null || I < C || I > x || L !== null && I > L, z = L === null || L < C || L > x || I !== null && L < I;
|
|
121
|
+
r.useEffect(() => {
|
|
122
|
+
j(null);
|
|
123
|
+
}, [
|
|
124
|
+
x,
|
|
125
|
+
C,
|
|
126
|
+
P,
|
|
127
|
+
N
|
|
128
|
+
]);
|
|
129
|
+
let B = {
|
|
130
|
+
...s,
|
|
131
|
+
color: c,
|
|
132
|
+
disabled: v,
|
|
133
|
+
hasInputLabel: !1,
|
|
134
|
+
max: x,
|
|
135
|
+
maxInvalid: z,
|
|
136
|
+
min: C,
|
|
137
|
+
minInvalid: R,
|
|
138
|
+
size: E,
|
|
139
|
+
step: k,
|
|
140
|
+
value: M
|
|
141
|
+
}, V = t(D?.minInput, B), H = t(D?.maxInput, B), U = {
|
|
142
|
+
...B,
|
|
143
|
+
hasInputLabel: g(V?.label) || g(H?.label)
|
|
144
|
+
}, W = u((e, t) => {
|
|
145
|
+
let n = m(t, C, x);
|
|
146
|
+
return n[0] === M[0] && n[1] === M[1] ? n : (ve(n), fe?.(e, n), n);
|
|
147
|
+
}), xe = u((e, t) => {
|
|
148
|
+
Array.isArray(t) && (j(null), W(e, [t[0], t[1]]));
|
|
149
|
+
}), Se = u((e, t) => {
|
|
150
|
+
Array.isArray(t) && T?.(e, m([t[0], t[1]], C, x));
|
|
151
|
+
}), Ce = (e) => (t) => {
|
|
152
|
+
if (t.defaultPrevented) return;
|
|
153
|
+
let n = t.target.value, r = e === 0 ? [n, F[1]] : [F[0], n];
|
|
154
|
+
j(r);
|
|
155
|
+
let i = h(r[0]), a = h(r[1]);
|
|
156
|
+
i !== null && a !== null && _(i, a, C, x) && (j(null), W(t, [i, a]));
|
|
157
|
+
}, we = (e) => (t) => {
|
|
158
|
+
if (t.defaultPrevented) return;
|
|
159
|
+
let n = h(F[e]), r = n === null ? M : e === 0 ? [p(n, C, M[1]), M[1]] : [M[0], p(n, M[0], x)];
|
|
160
|
+
j(null);
|
|
161
|
+
let i = W(t, r);
|
|
162
|
+
T?.(t, i);
|
|
163
|
+
}, Te = (e) => {
|
|
164
|
+
if (e.defaultPrevented) return;
|
|
165
|
+
let t = e.target;
|
|
166
|
+
if (t.tagName === "INPUT") {
|
|
167
|
+
if (e.key === "Escape") {
|
|
168
|
+
e.preventDefault(), j(null);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
e.key === "Enter" && (e.preventDefault(), t.blur());
|
|
172
|
+
}
|
|
173
|
+
}, G = O?.root ?? ie, K = O?.label ?? ae, q = O?.slider ?? oe, J = O?.inputs ?? se, Y = O?.minInput ?? ce, X = O?.maxInput ?? le, Z = O?.separator ?? ue, { ref: Ee, sx: De, ...Oe } = d(G, l(t(D?.root, U), {
|
|
174
|
+
"aria-disabled": v || void 0,
|
|
175
|
+
...ge
|
|
176
|
+
}), U), ke = ne(Ee, o), Ae = d(K, t(D?.label, U) ?? {}, U), je = d(q, {
|
|
177
|
+
...l(t(D?.slider, U), { valueLabelDisplay: "auto" }),
|
|
178
|
+
color: c,
|
|
179
|
+
disableSwap: !0,
|
|
180
|
+
disabled: v,
|
|
181
|
+
getAriaLabel: (e) => e === 0 ? w : S,
|
|
182
|
+
getAriaValueText: de,
|
|
183
|
+
max: x,
|
|
184
|
+
min: C,
|
|
185
|
+
size: E,
|
|
186
|
+
step: k,
|
|
187
|
+
...A !== void 0 && { valueLabelFormat: A }
|
|
188
|
+
}, U), Q = d(J, t(D?.inputs, U) ?? {}, U), Me = d(Z, {
|
|
189
|
+
"aria-hidden": !0,
|
|
190
|
+
component: "span",
|
|
191
|
+
...t(D?.separator, U) ?? {}
|
|
192
|
+
}, U), $ = (e) => {
|
|
193
|
+
let { slotProps: t, ...n } = (e === 0 ? V : H) ?? {}, r = l(t?.htmlInput, { "aria-label": e === 0 ? w : S }), i = l({
|
|
194
|
+
inputMode: "decimal",
|
|
195
|
+
max: x,
|
|
196
|
+
min: C,
|
|
197
|
+
step: k
|
|
198
|
+
}, r), a = l(n, {
|
|
199
|
+
helperText: (e === 0 ? R : !R && z) ? y : void 0,
|
|
200
|
+
onBlur: we(e),
|
|
201
|
+
onChange: Ce(e),
|
|
202
|
+
onKeyDown: Te
|
|
203
|
+
});
|
|
204
|
+
return d(e === 0 ? Y : X, {
|
|
205
|
+
...a,
|
|
206
|
+
color: c,
|
|
207
|
+
disabled: v,
|
|
208
|
+
error: e === 0 ? R : z,
|
|
209
|
+
size: E,
|
|
210
|
+
slotProps: {
|
|
211
|
+
...t,
|
|
212
|
+
htmlInput: i
|
|
213
|
+
},
|
|
214
|
+
type: "number",
|
|
215
|
+
value: F[e]
|
|
216
|
+
}, U);
|
|
217
|
+
}, Ne = $(0), Pe = $(1);
|
|
218
|
+
return /* @__PURE__ */ a(G, {
|
|
219
|
+
...Oe,
|
|
220
|
+
ref: ke,
|
|
221
|
+
sx: [...e(me), ...e(De)],
|
|
222
|
+
"data-invalid": be ? void 0 : "",
|
|
223
|
+
children: [
|
|
224
|
+
b != null && /* @__PURE__ */ i(K, {
|
|
225
|
+
...Ae,
|
|
226
|
+
children: b
|
|
227
|
+
}),
|
|
228
|
+
/* @__PURE__ */ i(q, {
|
|
229
|
+
...je,
|
|
230
|
+
onChange: xe,
|
|
231
|
+
onChangeCommitted: Se,
|
|
232
|
+
value: [M[0], M[1]]
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ a(J, {
|
|
235
|
+
...Q,
|
|
236
|
+
children: [
|
|
237
|
+
/* @__PURE__ */ i(Y, { ...Ne }),
|
|
238
|
+
/* @__PURE__ */ i(Z, {
|
|
239
|
+
...Me,
|
|
240
|
+
children: pe
|
|
241
|
+
}),
|
|
242
|
+
/* @__PURE__ */ i(X, { ...Pe })
|
|
243
|
+
]
|
|
244
|
+
})
|
|
245
|
+
]
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
v.displayName = "SNumberRange";
|
|
249
|
+
//#endregion
|
|
250
|
+
export { v as SNumberRange, v as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default, default as SPopover } from './s-popover';
|
|
2
|
+
export type { SPopoverOwnerState, SPopoverPlacement, SPopoverProps, SPopoverSlotProps, SPopoverSlots, } from './s-popover';
|
|
3
|
+
export { default as SPopoverContent } from './s-popover-content';
|
|
4
|
+
export type { SPopoverContentProps, SPopoverContentTypeMap } from './s-popover-content';
|
|
5
|
+
export type {} from '../theme/component-augmentation';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PopoverOrigin } from '@mui/material/Popover';
|
|
2
|
+
/** Anchor edge/corner the popover surface is attached to. */
|
|
3
|
+
export type SPopoverPlacement = 'bottom' | 'bottom-end' | 'bottom-start' | 'top' | 'top-end' | 'top-start';
|
|
4
|
+
/**
|
|
5
|
+
* Shared placement vocabulary for every anchored surface in the kit.
|
|
6
|
+
*
|
|
7
|
+
* Lives outside `s-popover.tsx` so components that anchor a MUI `Menu` (which
|
|
8
|
+
* cannot be swapped for `SPopover`) can reuse the same origin pairs without
|
|
9
|
+
* pulling the `SPopover` component into their bundle.
|
|
10
|
+
*/
|
|
11
|
+
export declare const placementOrigins: Record<SPopoverPlacement, {
|
|
12
|
+
anchorOrigin: PopoverOrigin;
|
|
13
|
+
transformOrigin: PopoverOrigin;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region lib/s-popover/placement.ts
|
|
2
|
+
var e = {
|
|
3
|
+
bottom: {
|
|
4
|
+
anchorOrigin: {
|
|
5
|
+
horizontal: "center",
|
|
6
|
+
vertical: "bottom"
|
|
7
|
+
},
|
|
8
|
+
transformOrigin: {
|
|
9
|
+
horizontal: "center",
|
|
10
|
+
vertical: "top"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"bottom-end": {
|
|
14
|
+
anchorOrigin: {
|
|
15
|
+
horizontal: "right",
|
|
16
|
+
vertical: "bottom"
|
|
17
|
+
},
|
|
18
|
+
transformOrigin: {
|
|
19
|
+
horizontal: "right",
|
|
20
|
+
vertical: "top"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"bottom-start": {
|
|
24
|
+
anchorOrigin: {
|
|
25
|
+
horizontal: "left",
|
|
26
|
+
vertical: "bottom"
|
|
27
|
+
},
|
|
28
|
+
transformOrigin: {
|
|
29
|
+
horizontal: "left",
|
|
30
|
+
vertical: "top"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
top: {
|
|
34
|
+
anchorOrigin: {
|
|
35
|
+
horizontal: "center",
|
|
36
|
+
vertical: "top"
|
|
37
|
+
},
|
|
38
|
+
transformOrigin: {
|
|
39
|
+
horizontal: "center",
|
|
40
|
+
vertical: "bottom"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"top-end": {
|
|
44
|
+
anchorOrigin: {
|
|
45
|
+
horizontal: "right",
|
|
46
|
+
vertical: "top"
|
|
47
|
+
},
|
|
48
|
+
transformOrigin: {
|
|
49
|
+
horizontal: "right",
|
|
50
|
+
vertical: "bottom"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"top-start": {
|
|
54
|
+
anchorOrigin: {
|
|
55
|
+
horizontal: "left",
|
|
56
|
+
vertical: "top"
|
|
57
|
+
},
|
|
58
|
+
transformOrigin: {
|
|
59
|
+
horizontal: "left",
|
|
60
|
+
vertical: "bottom"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { e as placementOrigins };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OverridableComponent, OverrideProps } from '@mui/material/OverridableComponent';
|
|
2
|
+
import { Theme } from '@mui/material/styles';
|
|
3
|
+
import { BoxTypeMap } from '@mui/system';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
export interface SPopoverContentTypeMap<AdditionalProps = object, RootComponent extends React.ElementType = 'div'> {
|
|
6
|
+
props: AdditionalProps & BoxTypeMap<object, RootComponent, Theme>['props'];
|
|
7
|
+
defaultComponent: RootComponent;
|
|
8
|
+
}
|
|
9
|
+
export type SPopoverContentProps<RootComponent extends React.ElementType = SPopoverContentTypeMap['defaultComponent'], AdditionalProps = object> = OverrideProps<SPopoverContentTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
|
|
10
|
+
component?: React.ElementType;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Padded content region for SPopover.
|
|
14
|
+
*
|
|
15
|
+
* Use one or more content regions when a popover mixes padded sections with
|
|
16
|
+
* edge-to-edge elements such as lists and dividers. The default 16px padding
|
|
17
|
+
* can be customized through `sx` or the `SPopoverContent` theme entry.
|
|
18
|
+
*/
|
|
19
|
+
export declare const SPopoverContent: OverridableComponent<SPopoverContentTypeMap<object, "div">> & {
|
|
20
|
+
displayName: string;
|
|
21
|
+
};
|
|
22
|
+
export default SPopoverContent;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { styled as e, useThemeProps as t } from "@mui/material/styles";
|
|
2
|
+
import * as n from "react";
|
|
3
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
+
import i from "@mui/material/Box";
|
|
5
|
+
//#region lib/s-popover/s-popover-content.tsx
|
|
6
|
+
var a = e(i, {
|
|
7
|
+
name: "SPopoverContent",
|
|
8
|
+
slot: "Root"
|
|
9
|
+
})(({ theme: e }) => ({ padding: e.spacing(2) })), o = Object.assign(n.forwardRef(function(e, n) {
|
|
10
|
+
let i = t({
|
|
11
|
+
props: e,
|
|
12
|
+
name: "SPopoverContent"
|
|
13
|
+
});
|
|
14
|
+
return /* @__PURE__ */ r(a, {
|
|
15
|
+
...i,
|
|
16
|
+
ownerState: i,
|
|
17
|
+
ref: n
|
|
18
|
+
});
|
|
19
|
+
}), { displayName: "SPopoverContent" });
|
|
20
|
+
//#endregion
|
|
21
|
+
export { o as SPopoverContent, o as default };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { PaperProps } from '@mui/material/Paper';
|
|
2
|
+
import { PopoverProps, PopoverSlots } from '@mui/material/Popover';
|
|
3
|
+
import { OwnerStateSlotProps } from '../utils/slots';
|
|
4
|
+
import { SPopoverPlacement } from './placement';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
export type { SPopoverPlacement } from './placement';
|
|
7
|
+
type PopoverSlotProps = NonNullable<PopoverProps['slotProps']>;
|
|
8
|
+
export interface SPopoverSlots extends Partial<Pick<PopoverSlots, 'backdrop' | 'transition'>> {
|
|
9
|
+
/** Surface rendered inside the popover, defaults to a themed MUI Paper. */
|
|
10
|
+
paper?: React.ElementType;
|
|
11
|
+
/** Popover element itself, defaults to MUI Popover. */
|
|
12
|
+
root?: React.ElementType;
|
|
13
|
+
}
|
|
14
|
+
type SPopoverRootSlotProps = Omit<PopoverProps, 'anchorOrigin' | 'children' | 'open' | 'slotProps' | 'slots' | 'transformOrigin'>;
|
|
15
|
+
export interface SPopoverSlotProps extends Pick<PopoverSlotProps, 'backdrop' | 'transition'> {
|
|
16
|
+
/** Props or owner-state callback for the popover surface. */
|
|
17
|
+
paper?: OwnerStateSlotProps<PaperProps, SPopoverOwnerState>;
|
|
18
|
+
/** Props or owner-state callback for the popover root. */
|
|
19
|
+
root?: OwnerStateSlotProps<SPopoverRootSlotProps, SPopoverOwnerState>;
|
|
20
|
+
}
|
|
21
|
+
/** Props for a themed MUI Popover with placement-based origin mapping. */
|
|
22
|
+
export interface SPopoverProps extends Omit<PopoverProps, 'anchorOrigin' | 'slotProps' | 'slots' | 'transformOrigin'> {
|
|
23
|
+
/** Element, virtual element, or getter the surface is positioned against. */
|
|
24
|
+
anchorEl?: PopoverProps['anchorEl'];
|
|
25
|
+
/** Popover content. Use SPopoverContent for a standard padded content region. */
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
/** Called when the popover requests to close (backdrop click or Escape). */
|
|
28
|
+
onClose?: PopoverProps['onClose'];
|
|
29
|
+
/** If `true`, the popover is shown. */
|
|
30
|
+
open: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Anchor edge/corner the surface attaches to. Resolves the matching
|
|
33
|
+
* `anchorOrigin`/`transformOrigin` pair on MUI Popover.
|
|
34
|
+
*/
|
|
35
|
+
placement?: SPopoverPlacement;
|
|
36
|
+
/** Components used for internal structural slots. */
|
|
37
|
+
slots?: SPopoverSlots;
|
|
38
|
+
/** Props or owner-state callbacks for internal structural slots. */
|
|
39
|
+
slotProps?: SPopoverSlotProps;
|
|
40
|
+
/** Stacking order of the popover. Defaults to `theme.zIndex.modal`. */
|
|
41
|
+
zIndex?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface SPopoverOwnerState extends SPopoverProps {
|
|
44
|
+
placement: SPopoverPlacement;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Themed MUI Popover with a `placement` API.
|
|
48
|
+
*
|
|
49
|
+
* Replaces the `anchorOrigin`/`transformOrigin` pair with a single `placement`
|
|
50
|
+
* token resolved from the kit's shared origin map, and applies the flat surface
|
|
51
|
+
* treatment used by every anchored panel in the system: `background.paper`,
|
|
52
|
+
* a 1px `divider` border and `radius.md`, with no elevation shadow.
|
|
53
|
+
* Compose with SPopoverContent when the content needs the standard 16px inset.
|
|
54
|
+
*
|
|
55
|
+
* The MUI `backdrop` and `transition` slots stay reachable through `slots` /
|
|
56
|
+
* `slotProps`; `root` targets the Popover itself rather than the inner Modal.
|
|
57
|
+
*/
|
|
58
|
+
export declare const SPopover: React.ForwardRefExoticComponent<Omit<SPopoverProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
59
|
+
export default SPopover;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { toSxArray as e } from "../utils/sx.js";
|
|
2
|
+
import { resolveOwnerStateSlotProps as t } from "../utils/slots.js";
|
|
3
|
+
import { placementOrigins as n } from "./placement.js";
|
|
4
|
+
import { styled as r, useThemeProps as i } from "@mui/material/styles";
|
|
5
|
+
import * as a from "react";
|
|
6
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
7
|
+
import { mergeSlotProps as s, useForkRef as c } from "@mui/material/utils";
|
|
8
|
+
import l from "@mui/utils/appendOwnerState";
|
|
9
|
+
import u, { PopoverPaper as d } from "@mui/material/Popover";
|
|
10
|
+
//#region lib/s-popover/s-popover.tsx
|
|
11
|
+
var f = .5, p = r(u, {
|
|
12
|
+
name: "SPopover",
|
|
13
|
+
slot: "Root",
|
|
14
|
+
shouldForwardProp: (e) => e !== "ownerState"
|
|
15
|
+
})(({ theme: e }) => ({ zIndex: e.zIndex.modal })), m = r(d, {
|
|
16
|
+
name: "SPopover",
|
|
17
|
+
slot: "Paper",
|
|
18
|
+
shouldForwardProp: (e) => e !== "ownerState"
|
|
19
|
+
})(({ theme: e }) => ({
|
|
20
|
+
border: "1px solid",
|
|
21
|
+
borderColor: (e.vars ?? e).palette.divider,
|
|
22
|
+
borderRadius: e.radius.md,
|
|
23
|
+
marginTop: 0,
|
|
24
|
+
variants: [{
|
|
25
|
+
props: ({ ownerState: e }) => e?.placement?.startsWith("bottom") ?? !1,
|
|
26
|
+
style: { marginTop: e.spacing(f) }
|
|
27
|
+
}, {
|
|
28
|
+
props: ({ ownerState: e }) => e?.placement?.startsWith("top") ?? !1,
|
|
29
|
+
style: { marginTop: e.spacing(-f) }
|
|
30
|
+
}]
|
|
31
|
+
})), h = a.forwardRef(function(r, a) {
|
|
32
|
+
let u = i({
|
|
33
|
+
props: r,
|
|
34
|
+
name: "SPopover"
|
|
35
|
+
}), { placement: d = "bottom-end", slotProps: f, slots: h, sx: g, zIndex: _, ...v } = u, y = {
|
|
36
|
+
...u,
|
|
37
|
+
placement: d
|
|
38
|
+
}, { anchorOrigin: b, transformOrigin: x } = n[d], S = h?.root ?? p, C = h?.paper ?? m, { ref: w, sx: T, ...E } = l(S, s(t(f?.root, y), v), y), D = c(w, a), { sx: O, ...k } = l(C, t(f?.paper, y) ?? {}, y);
|
|
39
|
+
return /* @__PURE__ */ o(S, {
|
|
40
|
+
...E,
|
|
41
|
+
ref: D,
|
|
42
|
+
anchorOrigin: b,
|
|
43
|
+
slots: {
|
|
44
|
+
backdrop: h?.backdrop,
|
|
45
|
+
paper: C,
|
|
46
|
+
transition: h?.transition
|
|
47
|
+
},
|
|
48
|
+
slotProps: {
|
|
49
|
+
backdrop: f?.backdrop,
|
|
50
|
+
paper: {
|
|
51
|
+
...k,
|
|
52
|
+
sx: e(O)
|
|
53
|
+
},
|
|
54
|
+
transition: f?.transition
|
|
55
|
+
},
|
|
56
|
+
sx: [
|
|
57
|
+
..._ === void 0 ? [] : [{ zIndex: _ }],
|
|
58
|
+
...e(T),
|
|
59
|
+
...e(g)
|
|
60
|
+
],
|
|
61
|
+
transformOrigin: x
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
h.displayName = "SPopover";
|
|
65
|
+
//#endregion
|
|
66
|
+
export { h as SPopover, h as default };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default, default as SProductCard } from './s-product-card';
|
|
2
|
+
export type { SProductCardBadgePlacement, SProductCardLinkProps, SProductCardOwnerState, SProductCardProps, SProductCardRootProps, SProductCardSlotProps, SProductCardSlots, SProductCardSwatch, SProductCardVariant, } from './s-product-card';
|
|
3
|
+
export type {} from '../theme/component-augmentation';
|