@janbox/storefront-ui 2.0.27 → 2.0.28

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.
@@ -1,5 +1,4 @@
1
1
  export * from './use-window-screen';
2
- export * from './use-ripple-effect';
3
2
  export * from './use-controllable-state';
4
3
  export * from './use-countdown-timer';
5
4
  export * from './use-query-params';
@@ -1,5 +1,4 @@
1
1
  import { useWindowScreen } from "./use-window-screen/index.js";
2
- import { useRippleEffect } from "./use-ripple-effect/index.js";
3
2
  import { useControllableState } from "./use-controllable-state.js";
4
3
  import { useCountdownTimer } from "./use-countdown-timer.js";
5
4
  import { useQueryParams } from "./use-query-params.js";
@@ -14,7 +13,6 @@ export {
14
13
  useFirstMountState,
15
14
  useFormatter,
16
15
  useQueryParams,
17
- useRippleEffect,
18
16
  useUpdateEffect,
19
17
  useWindowScreen
20
18
  };
package/dist/index.js CHANGED
@@ -77,6 +77,7 @@ import { PriceLabel } from "./lib/price-label/price-label.js";
77
77
  import { Primitive } from "./lib/primitive/primitive.js";
78
78
  import { Progress } from "./lib/progress/progress.js";
79
79
  import { RadioButton } from "./lib/radio-button/radio-button.js";
80
+ import { RippleEffect } from "./lib/ripple-effect/ripple-effect.js";
80
81
  import { Select } from "./lib/select/select.js";
81
82
  import { StarRating } from "./lib/star-rating/star-rating.js";
82
83
  import { Step } from "./lib/stepper/step.js";
@@ -223,6 +224,7 @@ export {
223
224
  Primitive,
224
225
  Progress,
225
226
  RadioButton,
227
+ RippleEffect,
226
228
  Select,
227
229
  StarRating,
228
230
  Step,
@@ -4,19 +4,17 @@ import { useMergeRefs } from "@floating-ui/react";
4
4
  import { isNil, isString } from "lodash-es";
5
5
  import { useNavigate, createPath } from "react-router";
6
6
  import { getButtonProps, getButtonCssBySize } from "./helpers.js";
7
- import { useRippleEffect } from "../../hooks/use-ripple-effect/index.js";
8
7
  import { truncateStyle, animateSpinStyle } from "../../constants/emotion.js";
9
8
  import LoadingIcon from "../../assets/svg/loading-waiting.svg.js";
10
9
  import { mediaQuery } from "../../theme/screens.js";
11
10
  import { getColorVar } from "../../theme/palette.js";
12
11
  import { getColorShadesByVariant, getSizeVariantState } from "../../utils/index.js";
13
12
  import { createSxInterpolation } from "../../utils/stylesheet.js";
14
- import { clsx } from "clsx";
13
+ import { RippleEffect } from "../ripple-effect/ripple-effect.js";
15
14
  import { Icon } from "../icon/icon.js";
16
15
  import { Primitive } from "../primitive/primitive.js";
17
16
  const Button = ({ children, ref, ..._props }) => {
18
17
  const buttonRef = useRef(null);
19
- const { className } = useRippleEffect(buttonRef);
20
18
  const mergedRef = useMergeRefs([ref, buttonRef]);
21
19
  const {
22
20
  color,
@@ -52,6 +50,7 @@ const Button = ({ children, ref, ..._props }) => {
52
50
  maxWidth: "100%",
53
51
  width: "fit-content",
54
52
  position: "relative",
53
+ overflow: "hidden",
55
54
  justifyContent: "center",
56
55
  alignItems: "center",
57
56
  whiteSpace: "nowrap",
@@ -142,83 +141,73 @@ const Button = ({ children, ref, ..._props }) => {
142
141
  }
143
142
  }
144
143
  };
145
- return /* @__PURE__ */ jsxs(
146
- "button",
147
- {
148
- css,
149
- disabled,
150
- ...rest,
151
- onClick,
152
- className: clsx(rest.className, className),
153
- ref: mergedRef,
154
- children: [
155
- prefix,
156
- !!startIcon && /* @__PURE__ */ jsx(
157
- Icon,
158
- {
159
- size: getSizeVariantState(size).iconSize,
160
- ...startIcon,
161
- sx: {
162
- flexShrink: 0,
163
- ...startIcon.sx
164
- },
165
- sm: {
166
- size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
167
- ...startIcon.sm
168
- },
169
- md: {
170
- size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
171
- ...startIcon.md
172
- },
173
- lg: {
174
- size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
175
- ...startIcon.lg
176
- }
177
- }
178
- ),
179
- /* @__PURE__ */ jsx(Fragment, { children: isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML, css: truncateStyle, children }) }),
180
- !!endIcon && /* @__PURE__ */ jsx(
181
- Icon,
182
- {
183
- size: getSizeVariantState(size).iconSize,
184
- ...endIcon,
185
- sx: {
186
- flexShrink: 0,
187
- ...endIcon.sx
188
- },
189
- sm: {
190
- size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
191
- ...endIcon.sm
192
- },
193
- md: {
194
- size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
195
- ...endIcon.md
196
- },
197
- lg: {
198
- size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
199
- ...endIcon.lg
200
- }
201
- }
202
- ),
203
- suffix,
204
- isLoading && /* @__PURE__ */ jsx(
205
- Primitive,
206
- {
207
- "data-loading": true,
208
- sx: {
209
- position: "absolute",
210
- inset: 0,
211
- display: "flex",
212
- alignItems: "center",
213
- justifyContent: "center"
214
- },
215
- as: "span",
216
- children: /* @__PURE__ */ jsx(Icon, { css: animateSpinStyle, source: LoadingIcon })
217
- }
218
- )
219
- ]
220
- }
221
- );
144
+ return /* @__PURE__ */ jsxs("button", { css, disabled, ...rest, onClick, ref: mergedRef, children: [
145
+ prefix,
146
+ !!startIcon && /* @__PURE__ */ jsx(
147
+ Icon,
148
+ {
149
+ size: getSizeVariantState(size).iconSize,
150
+ ...startIcon,
151
+ sx: {
152
+ flexShrink: 0,
153
+ ...startIcon.sx
154
+ },
155
+ sm: {
156
+ size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
157
+ ...startIcon.sm
158
+ },
159
+ md: {
160
+ size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
161
+ ...startIcon.md
162
+ },
163
+ lg: {
164
+ size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
165
+ ...startIcon.lg
166
+ }
167
+ }
168
+ ),
169
+ /* @__PURE__ */ jsx(Fragment, { children: isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML, css: truncateStyle, children }) }),
170
+ !!endIcon && /* @__PURE__ */ jsx(
171
+ Icon,
172
+ {
173
+ size: getSizeVariantState(size).iconSize,
174
+ ...endIcon,
175
+ sx: {
176
+ flexShrink: 0,
177
+ ...endIcon.sx
178
+ },
179
+ sm: {
180
+ size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
181
+ ...endIcon.sm
182
+ },
183
+ md: {
184
+ size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
185
+ ...endIcon.md
186
+ },
187
+ lg: {
188
+ size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
189
+ ...endIcon.lg
190
+ }
191
+ }
192
+ ),
193
+ suffix,
194
+ isLoading && /* @__PURE__ */ jsx(
195
+ Primitive,
196
+ {
197
+ "data-loading": true,
198
+ sx: {
199
+ position: "absolute",
200
+ inset: 0,
201
+ display: "flex",
202
+ alignItems: "center",
203
+ justifyContent: "center"
204
+ },
205
+ as: "span",
206
+ children: /* @__PURE__ */ jsx(Icon, { css: animateSpinStyle, source: LoadingIcon })
207
+ }
208
+ ),
209
+ /* @__PURE__ */ jsx(RippleEffect, {})
210
+ ] });
222
211
  };
223
212
  const createStyle = ({ size } = {}) => {
224
213
  return [getButtonCssBySize(size)];
@@ -1,17 +1,14 @@
1
1
  import { jsxs, jsx } from "@emotion/react/jsx-runtime";
2
- import { useRef } from "react";
3
- import { useMergeRefs } from "@floating-ui/react";
4
2
  import { getIconButtonProps } from "./helpers.js";
5
- import { useRippleEffect } from "../../hooks/use-ripple-effect/index.js";
6
3
  import { createSxInterpolation } from "../../utils/stylesheet.js";
7
4
  import LoadingIcon from "../../assets/svg/loading-waiting.svg.js";
8
5
  import { mediaQuery } from "../../theme/screens.js";
9
6
  import { getColorVar } from "../../theme/palette.js";
10
7
  import { getColorShadesByVariant, getSizeVariantState } from "../../utils/index.js";
11
8
  import { animateSpinStyle } from "../../constants/emotion.js";
12
- import clsx from "clsx";
13
9
  import { ensureBoolean } from "../../utils/common.js";
14
10
  import { Icon } from "../icon/icon.js";
11
+ import { RippleEffect } from "../ripple-effect/ripple-effect.js";
15
12
  const IconButton = ({ children, ref, ..._props }) => {
16
13
  const { size, color, variant, icon, isLoading, sx, sm, md, lg, ...rest } = getIconButtonProps(_props);
17
14
  const {
@@ -23,15 +20,13 @@ const IconButton = ({ children, ref, ..._props }) => {
23
20
  ariaDisabledSurface,
24
21
  ariaDisabledText
25
22
  } = getColorShadesByVariant(color);
26
- const buttonRef = useRef(null);
27
- const { className } = useRippleEffect(buttonRef);
28
- const mergedRef = useMergeRefs([ref, buttonRef]);
29
23
  const css = [
30
24
  {
31
25
  display: "flex",
32
26
  width: "fit-content",
33
27
  height: "fit-content",
34
28
  position: "relative",
29
+ overflow: "hidden",
35
30
  justifyContent: "center",
36
31
  alignItems: "center",
37
32
  pointerEvents: ensureBoolean(rest["aria-disabled"]) ? "none" : void 0,
@@ -102,7 +97,7 @@ const IconButton = ({ children, ref, ..._props }) => {
102
97
  var _a;
103
98
  (_a = rest.onClick) == null ? void 0 : _a.call(rest, e);
104
99
  };
105
- return /* @__PURE__ */ jsxs("button", { css, ...rest, className: clsx(rest.className, className), onClick, ref: mergedRef, children: [
100
+ return /* @__PURE__ */ jsxs("button", { css, ...rest, onClick, ref, children: [
106
101
  !!icon && /* @__PURE__ */ jsx(
107
102
  Icon,
108
103
  {
@@ -130,7 +125,8 @@ const IconButton = ({ children, ref, ..._props }) => {
130
125
  css: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center" },
131
126
  children: /* @__PURE__ */ jsx(Icon, { css: animateSpinStyle, source: LoadingIcon })
132
127
  }
133
- )
128
+ ),
129
+ /* @__PURE__ */ jsx(RippleEffect, {})
134
130
  ] });
135
131
  };
136
132
  const createStyle = ({ size } = {}) => {
@@ -60,3 +60,4 @@ export * from './primitive';
60
60
  export * from './price-label';
61
61
  export * from './avatar';
62
62
  export * from './suspense-query';
63
+ export * from './ripple-effect';
@@ -3,13 +3,11 @@ import { useRef, useState } from "react";
3
3
  import { useMergeRefs } from "@floating-ui/react";
4
4
  import { isString } from "lodash-es";
5
5
  import { getInputProps } from "./helpers.js";
6
- import classes from "./input.module.scss.js";
7
6
  import EyeHidden from "../../assets/svg/eye-hidden.svg.js";
8
7
  import EyeVisible from "../../assets/svg/eye-show-visible.svg.js";
9
8
  import { getSizeVariantState } from "../../utils/index.js";
10
- import "../../theme/palette.js";
9
+ import { getColorVar } from "../../theme/palette.js";
11
10
  import { getTypographyVar } from "../../theme/typography.js";
12
- import { clsx } from "clsx";
13
11
  import { FormHelperText } from "../form-helper-text/form-helper-text.js";
14
12
  import { Primitive } from "../primitive/primitive.js";
15
13
  import { Icon } from "../icon/icon.js";
@@ -25,7 +23,6 @@ const Input = ({ ref, ..._props }) => {
25
23
  suffix,
26
24
  containerProps,
27
25
  mainProps,
28
- className,
29
26
  helperText,
30
27
  error,
31
28
  startIcon,
@@ -91,113 +88,170 @@ const Input = ({ ref, ..._props }) => {
91
88
  e.stopPropagation();
92
89
  setShowPassword((prev) => !prev);
93
90
  };
94
- return /* @__PURE__ */ jsxs(Primitive, { className: clsx(classes.input__container, containerProps == null ? void 0 : containerProps.className), children: [
95
- /* @__PURE__ */ jsxs(
96
- Primitive,
97
- {
98
- ...mainProps,
99
- className: clsx(
100
- classes.input__main,
91
+ return /* @__PURE__ */ jsxs(
92
+ Primitive,
93
+ {
94
+ ...containerProps,
95
+ sx: {
96
+ position: "relative",
97
+ display: "flex",
98
+ flexDirection: "column",
99
+ width: "100%",
100
+ ...containerProps == null ? void 0 : containerProps.sx
101
+ },
102
+ children: [
103
+ /* @__PURE__ */ jsxs(
104
+ Primitive,
101
105
  {
102
- [classes.input__main_error]: error
103
- },
104
- mainProps == null ? void 0 : mainProps.className
105
- ),
106
- sx: {
107
- ...createStyle({ size }),
108
- ...mainProps == null ? void 0 : mainProps.sx,
109
- sm: {
110
- ...createStyle(sm),
111
- ...(_a = mainProps == null ? void 0 : mainProps.sx) == null ? void 0 : _a.sm
112
- },
113
- md: {
114
- ...createStyle(md),
115
- ...(_b = mainProps == null ? void 0 : mainProps.sx) == null ? void 0 : _b.md
116
- },
117
- lg: {
118
- ...createStyle(lg),
119
- ...(_c = mainProps == null ? void 0 : mainProps.sx) == null ? void 0 : _c.lg
120
- }
121
- },
122
- children: [
123
- prefix,
124
- !!startIcon && /* @__PURE__ */ jsx(
125
- Icon,
126
- {
127
- size: getSizeVariantState(size).iconSize,
128
- ...startIcon,
129
- sm: {
130
- size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
131
- ...startIcon.sm
106
+ ...mainProps,
107
+ sx: {
108
+ width: "100%",
109
+ display: "flex",
110
+ overflow: "hidden",
111
+ alignItems: "center",
112
+ gap: 8,
113
+ borderRadius: 8,
114
+ borderWidth: 1,
115
+ borderStyle: "solid",
116
+ backgroundColor: getColorVar("surface.default"),
117
+ "&:hover": {
118
+ borderColor: getColorVar("primary.300")
132
119
  },
133
- md: {
134
- size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
135
- ...startIcon.md
120
+ "&:has(input:focus:not(:read-only))": {
121
+ borderColor: getColorVar("primary.600"),
122
+ boxShadow: `0 1px 3px 0 ${getColorVar("primary.300")}, 0 1px 2px -1px ${getColorVar("primary.300")}`
136
123
  },
137
- lg: {
138
- size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
139
- ...startIcon.lg
140
- }
141
- }
142
- ),
143
- /* @__PURE__ */ jsx(
144
- Primitive,
145
- {
146
- "data-error": error,
147
- type: type === "password" && showPassword ? "text" : type,
148
- className: clsx(classes.input__control, className),
149
- ...rest,
150
- value: typingValue ?? value,
151
- ref: mergedRefs,
152
- onChange,
153
- onBlur,
154
- onFocus,
155
- as: "input"
156
- }
157
- ),
158
- !!endIcon && /* @__PURE__ */ jsx(
159
- Icon,
160
- {
161
- size: getSizeVariantState(size).iconSize,
162
- ...endIcon,
163
- sm: {
164
- size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
165
- ...endIcon.sm
124
+ "&:has(input:read-only)": {
125
+ pointerEvents: "none"
166
126
  },
167
- md: {
168
- size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
169
- ...endIcon.md
127
+ "&:has(input:disabled)": {
128
+ backgroundColor: getColorVar("neutral.300"),
129
+ color: getColorVar("neutral.500"),
130
+ borderColor: getColorVar("neutral.300"),
131
+ pointerEvents: "none"
170
132
  },
171
- lg: {
172
- size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
173
- ...endIcon.lg
174
- }
175
- }
176
- ),
177
- suffix,
178
- type === "password" && /* @__PURE__ */ jsx(
179
- Icon,
180
- {
181
- onClick: toggleShowPassword,
182
- sx: { cursor: "pointer" },
183
- size: getSizeVariantState(size).iconSize,
133
+ ...error && { borderColor: getColorVar("red.600") },
134
+ ...createStyle({ size }),
135
+ ...mainProps == null ? void 0 : mainProps.sx,
184
136
  sm: {
185
- size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize
137
+ ...createStyle(sm),
138
+ ...(_a = mainProps == null ? void 0 : mainProps.sx) == null ? void 0 : _a.sm
186
139
  },
187
140
  md: {
188
- size: getSizeVariantState(md == null ? void 0 : md.size).iconSize
141
+ ...createStyle(md),
142
+ ...(_b = mainProps == null ? void 0 : mainProps.sx) == null ? void 0 : _b.md
189
143
  },
190
144
  lg: {
191
- size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize
192
- },
193
- source: showPassword ? EyeVisible : EyeHidden
194
- }
195
- )
196
- ]
197
- }
198
- ),
199
- /* @__PURE__ */ jsx(FormHelperText, { error, children: helperText })
200
- ] });
145
+ ...createStyle(lg),
146
+ ...(_c = mainProps == null ? void 0 : mainProps.sx) == null ? void 0 : _c.lg
147
+ }
148
+ },
149
+ children: [
150
+ prefix,
151
+ !!startIcon && /* @__PURE__ */ jsx(
152
+ Icon,
153
+ {
154
+ size: getSizeVariantState(size).iconSize,
155
+ ...startIcon,
156
+ sm: {
157
+ size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
158
+ ...startIcon.sm
159
+ },
160
+ md: {
161
+ size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
162
+ ...startIcon.md
163
+ },
164
+ lg: {
165
+ size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
166
+ ...startIcon.lg
167
+ },
168
+ sx: {
169
+ flexShrink: 0,
170
+ ...startIcon == null ? void 0 : startIcon.sx
171
+ }
172
+ }
173
+ ),
174
+ /* @__PURE__ */ jsx(
175
+ Primitive,
176
+ {
177
+ "data-error": error,
178
+ type: type === "password" && showPassword ? "text" : type,
179
+ ...rest,
180
+ value: typingValue ?? value,
181
+ ref: mergedRefs,
182
+ onChange,
183
+ onBlur,
184
+ onFocus,
185
+ as: "input",
186
+ sx: {
187
+ flex: "1 1 0%",
188
+ width: "100%",
189
+ height: "100%",
190
+ overflow: "hidden",
191
+ textOverflow: "ellipsis",
192
+ whiteSpace: "nowrap",
193
+ backgroundColor: "transparent",
194
+ ":focus": {
195
+ outline: "none"
196
+ },
197
+ "::placeholder": {
198
+ color: getColorVar("neutral.400")
199
+ }
200
+ }
201
+ }
202
+ ),
203
+ !!endIcon && /* @__PURE__ */ jsx(
204
+ Icon,
205
+ {
206
+ size: getSizeVariantState(size).iconSize,
207
+ ...endIcon,
208
+ sm: {
209
+ size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
210
+ ...endIcon.sm
211
+ },
212
+ md: {
213
+ size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
214
+ ...endIcon.md
215
+ },
216
+ lg: {
217
+ size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
218
+ ...endIcon.lg
219
+ },
220
+ sx: {
221
+ flexShrink: 0,
222
+ ...endIcon == null ? void 0 : endIcon.sx
223
+ }
224
+ }
225
+ ),
226
+ suffix,
227
+ type === "password" && /* @__PURE__ */ jsx(
228
+ Icon,
229
+ {
230
+ onClick: toggleShowPassword,
231
+ size: getSizeVariantState(size).iconSize,
232
+ sm: {
233
+ size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize
234
+ },
235
+ md: {
236
+ size: getSizeVariantState(md == null ? void 0 : md.size).iconSize
237
+ },
238
+ lg: {
239
+ size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize
240
+ },
241
+ source: showPassword ? EyeVisible : EyeHidden,
242
+ sx: {
243
+ cursor: "pointer",
244
+ flexShrink: 0
245
+ }
246
+ }
247
+ )
248
+ ]
249
+ }
250
+ ),
251
+ /* @__PURE__ */ jsx(FormHelperText, { error, children: helperText })
252
+ ]
253
+ }
254
+ );
201
255
  };
202
256
  const createStyle = ({ size } = {}) => {
203
257
  const { inputPaddingX, inputSize, textVariant } = getSizeVariantState(size);
@@ -1,2 +1,2 @@
1
1
  import { InputRangeProps } from './types';
2
- export declare const InputRange: (_props: InputRangeProps) => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export declare const InputRange: ({ ref: _ref, ..._props }: InputRangeProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,16 +1,15 @@
1
- import { jsxs, jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useRef, Fragment } from "react";
3
3
  import { getInputRangeProps } from "./helpers.js";
4
- import classes from "./input-range.module.scss.js";
5
4
  import { getSizeVariantState } from "../../utils/index.js";
6
5
  import LongArrowRightIcon from "../../assets/svg/long-arrow-right.svg.js";
7
- import { mediaQuery } from "../../theme/screens.js";
8
- import "../../theme/palette.js";
9
- import { clsx } from "clsx";
6
+ import "lodash-es";
7
+ import { getColorVar } from "../../theme/palette.js";
10
8
  import { InputNumber } from "../input-number/input-number.js";
9
+ import { Primitive } from "../primitive/primitive.js";
11
10
  import { Icon } from "../icon/icon.js";
12
11
  import { FormHelperText } from "../form-helper-text/form-helper-text.js";
13
- const InputRange = (_props) => {
12
+ const InputRange = ({ ref: _ref, ..._props }) => {
14
13
  const {
15
14
  error,
16
15
  helperText,
@@ -52,114 +51,139 @@ const InputRange = (_props) => {
52
51
  onChange == null ? void 0 : onChange(e, edge);
53
52
  (_b = (_a = inputs == null ? void 0 : inputs.at(Number(e.currentTarget.dataset.index))) == null ? void 0 : _a.onChange) == null ? void 0 : _b.call(_a, e);
54
53
  };
55
- const css = [
56
- createStyle({ size }),
57
- {
58
- [mediaQuery("sm")]: createStyle(sm),
59
- [mediaQuery("md")]: createStyle(md),
60
- [mediaQuery("lg")]: createStyle(lg)
61
- }
62
- ];
63
- return /* @__PURE__ */ jsxs("div", { css: { width: "100%" }, children: [
64
- /* @__PURE__ */ jsxs("div", { css, className: clsx(classes.input_range, className), ...props, ref: containerRef, children: [
65
- prefix,
66
- !!startIcon && /* @__PURE__ */ jsx(
67
- Icon,
68
- {
69
- css: { flexShrink: 0 },
70
- size: getSizeVariantState(size).iconSize,
71
- ...startIcon,
54
+ return /* @__PURE__ */ jsxs(Primitive, { ...props, sx: { width: "100%", ...props.sx }, children: [
55
+ /* @__PURE__ */ jsxs(
56
+ Primitive,
57
+ {
58
+ ref: containerRef,
59
+ className,
60
+ sx: {
61
+ display: "flex",
62
+ alignItems: "center",
63
+ borderWidth: 1,
64
+ borderStyle: "solid",
65
+ borderRadius: "0.5rem",
66
+ gap: "0.5rem",
67
+ paddingLeft: getSizeVariantState(size).inputPaddingX,
68
+ paddingRight: getSizeVariantState(size).inputPaddingX,
69
+ "&:has(input:focus)": {
70
+ borderColor: getColorVar("primary.600"),
71
+ boxShadow: `0 1px 3px 0 ${getColorVar("primary.300")}, 0 1px 2px -1px ${getColorVar("primary.300")}`
72
+ },
73
+ ":hover": {
74
+ borderColor: getColorVar("primary.300")
75
+ },
72
76
  sm: {
73
- size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
74
- ...startIcon.sm
77
+ paddingLeft: getSizeVariantState(sm == null ? void 0 : sm.size).inputPaddingX,
78
+ paddingRight: getSizeVariantState(sm == null ? void 0 : sm.size).inputPaddingX
75
79
  },
76
80
  md: {
77
- size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
78
- ...startIcon.md
81
+ paddingLeft: getSizeVariantState(md == null ? void 0 : md.size).inputPaddingX,
82
+ paddingRight: getSizeVariantState(md == null ? void 0 : md.size).inputPaddingX
79
83
  },
80
84
  lg: {
81
- size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
82
- ...startIcon.lg
85
+ paddingLeft: getSizeVariantState(lg == null ? void 0 : lg.size).inputPaddingX,
86
+ paddingRight: getSizeVariantState(lg == null ? void 0 : lg.size).inputPaddingX
83
87
  }
84
- }
85
- ),
86
- ["from", "to"].map((edge, index, array) => {
87
- const inputProps = (inputs == null ? void 0 : inputs.at(index)) ?? {};
88
- return /* @__PURE__ */ jsxs(Fragment, { children: [
89
- /* @__PURE__ */ jsx(
90
- InputNumber,
88
+ },
89
+ children: [
90
+ prefix,
91
+ !!startIcon && /* @__PURE__ */ jsx(
92
+ Icon,
91
93
  {
92
- ref: (el) => {
93
- inputRefs.current[index] = el;
94
+ size: getSizeVariantState(size).iconSize,
95
+ ...startIcon,
96
+ sm: {
97
+ size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
98
+ ...startIcon.sm
99
+ },
100
+ md: {
101
+ size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
102
+ ...startIcon.md
94
103
  },
95
- "data-edge": edge,
96
- "data-index": index,
97
- css: { textAlign: "center" },
98
- mainProps: {
99
- style: {
100
- borderWidth: 0,
101
- boxShadow: "none",
102
- paddingLeft: 0,
103
- paddingRight: 0
104
- }
104
+ lg: {
105
+ size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
106
+ ...startIcon.lg
105
107
  },
106
- mode: "onBlur",
107
- ...inputProps,
108
- onChange: onInputChange,
109
- onFocus: onInputFocus,
110
- size,
108
+ sx: {
109
+ flexShrink: 0,
110
+ ...startIcon.sx
111
+ }
112
+ }
113
+ ),
114
+ ["from", "to"].map((edge, index, array) => {
115
+ const inputProps = (inputs == null ? void 0 : inputs.at(index)) ?? {};
116
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
117
+ /* @__PURE__ */ jsx(
118
+ InputNumber,
119
+ {
120
+ ref: (el) => {
121
+ inputRefs.current[index] = el;
122
+ },
123
+ "data-edge": edge,
124
+ "data-index": index,
125
+ mainProps: {
126
+ style: {
127
+ borderWidth: 0,
128
+ boxShadow: "none",
129
+ paddingLeft: 0,
130
+ paddingRight: 0
131
+ }
132
+ },
133
+ mode: "onBlur",
134
+ ...inputProps,
135
+ onChange: onInputChange,
136
+ onFocus: onInputFocus,
137
+ size,
138
+ sm: {
139
+ size: sm == null ? void 0 : sm.size,
140
+ ...inputProps.sm
141
+ },
142
+ md: {
143
+ size: md == null ? void 0 : md.size,
144
+ ...inputProps.md
145
+ },
146
+ lg: {
147
+ size: lg == null ? void 0 : lg.size,
148
+ ...inputProps.lg
149
+ },
150
+ sx: { textAlign: "center", ...inputProps.sx }
151
+ },
152
+ index
153
+ ),
154
+ index < array.length - 1 && /* @__PURE__ */ jsx(Icon, { ...iconProps, sx: { flexShrink: 0 }, source: LongArrowRightIcon })
155
+ ] }, index);
156
+ }),
157
+ !!endIcon && /* @__PURE__ */ jsx(
158
+ Icon,
159
+ {
160
+ size: getSizeVariantState(size).iconSize,
161
+ ...endIcon,
111
162
  sm: {
112
- size: sm == null ? void 0 : sm.size,
113
- ...inputProps.sm
163
+ size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
164
+ ...endIcon.sm
114
165
  },
115
166
  md: {
116
- size: md == null ? void 0 : md.size,
117
- ...inputProps.md
167
+ size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
168
+ ...endIcon.md
118
169
  },
119
170
  lg: {
120
- size: lg == null ? void 0 : lg.size,
121
- ...inputProps.lg
171
+ size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
172
+ ...endIcon.lg
173
+ },
174
+ sx: {
175
+ flexShrink: 0,
176
+ ...endIcon.sx
122
177
  }
123
- },
124
- index
178
+ }
125
179
  ),
126
- index < array.length - 1 && /* @__PURE__ */ jsx(Icon, { ...iconProps, css: { flexShrink: 0 }, source: LongArrowRightIcon })
127
- ] }, index);
128
- }),
129
- !!endIcon && /* @__PURE__ */ jsx(
130
- Icon,
131
- {
132
- size: getSizeVariantState(size).iconSize,
133
- ...endIcon,
134
- css: { flexShrink: 0 },
135
- sm: {
136
- size: getSizeVariantState(sm == null ? void 0 : sm.size).iconSize,
137
- ...endIcon.sm
138
- },
139
- md: {
140
- size: getSizeVariantState(md == null ? void 0 : md.size).iconSize,
141
- ...endIcon.md
142
- },
143
- lg: {
144
- size: getSizeVariantState(lg == null ? void 0 : lg.size).iconSize,
145
- ...endIcon.lg
146
- }
147
- }
148
- ),
149
- suffix
150
- ] }),
180
+ suffix
181
+ ]
182
+ }
183
+ ),
151
184
  /* @__PURE__ */ jsx(FormHelperText, { error, children: helperText })
152
185
  ] });
153
186
  };
154
- const createStyle = ({ size } = {}) => {
155
- const { inputPaddingX } = getSizeVariantState(size);
156
- return [
157
- {
158
- paddingLeft: inputPaddingX,
159
- paddingRight: inputPaddingX
160
- }
161
- ];
162
- };
163
187
  export {
164
188
  InputRange
165
189
  };
@@ -1,7 +1,8 @@
1
1
  import { JSX } from 'react';
2
2
  import { IconProps } from '../icon';
3
3
  import { InputNumberProps } from '../input-number/types';
4
- import { SizeVariant, ShallowMerge, ToResponsiveProps } from '../../types';
4
+ import { PrimitiveProps } from '../primitive';
5
+ import { ShallowMerge, SizeVariant, ToResponsiveProps } from '../../types';
5
6
  export interface InputRangeResponsiveProps {
6
7
  size?: SizeVariant;
7
8
  }
@@ -16,5 +17,5 @@ interface InputRangeExtendedProps extends ToResponsiveProps<InputRangeResponsive
16
17
  startIcon?: IconProps;
17
18
  endIcon?: IconProps;
18
19
  }
19
- export type InputRangeProps = ShallowMerge<JSX.IntrinsicElements['div'], InputRangeExtendedProps>;
20
+ export type InputRangeProps = PrimitiveProps<ShallowMerge<JSX.IntrinsicElements['div'], InputRangeExtendedProps>>;
20
21
  export {};
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './ripple-effect';
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { RippleEffectProps } from './types';
3
+ export declare const RippleEffect: FC<RippleEffectProps>;
@@ -0,0 +1,75 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useRef, useEffect } from "react";
3
+ import { Primitive } from "../primitive/primitive.js";
4
+ const RippleEffect = ({
5
+ enabled = true,
6
+ color = "currentColor",
7
+ duration = 400,
8
+ opacity = 0.2,
9
+ sizeMultiplier = 1
10
+ }) => {
11
+ const containerRef = useRef(null);
12
+ const activeRipplesRef = useRef(/* @__PURE__ */ new Set());
13
+ useEffect(() => {
14
+ if (!enabled) return;
15
+ const container = containerRef.current;
16
+ const parent = container == null ? void 0 : container.parentElement;
17
+ if (!container || !parent) return;
18
+ const activeRipples = activeRipplesRef.current;
19
+ const handlePointerDown = (e) => {
20
+ if (e.pointerType === "mouse" && e.button !== 0) return;
21
+ const { clientX, clientY } = e;
22
+ const { clientHeight, clientWidth } = parent;
23
+ const { left: offsetLeft, top: offsetTop } = parent.getBoundingClientRect();
24
+ const circleLeft = clientX - offsetLeft;
25
+ const circleTop = clientY - offsetTop;
26
+ const circleRight = offsetLeft + clientWidth - clientX;
27
+ const circleBottom = offsetTop + clientHeight - clientY;
28
+ const radius = Math.max(circleLeft, circleTop, circleRight, circleBottom) * sizeMultiplier;
29
+ const circle = document.createElement("div");
30
+ circle.style.position = "absolute";
31
+ circle.style.borderRadius = "9999px";
32
+ circle.style.backgroundColor = color;
33
+ circle.style.width = circle.style.height = `${radius * 2}px`;
34
+ circle.style.left = `${circleLeft - radius}px`;
35
+ circle.style.top = `${circleTop - radius}px`;
36
+ const animation = circle.animate(
37
+ [
38
+ { transform: "scale(0)", opacity },
39
+ { transform: "scale(1)", opacity: 0 }
40
+ ],
41
+ { duration, easing: "ease-in-out" }
42
+ );
43
+ animation.onfinish = () => {
44
+ circle.remove();
45
+ activeRipples.delete(circle);
46
+ };
47
+ activeRipples.add(circle);
48
+ container.appendChild(circle);
49
+ };
50
+ parent.addEventListener("pointerdown", handlePointerDown);
51
+ return () => {
52
+ parent.removeEventListener("pointerdown", handlePointerDown);
53
+ activeRipples.forEach((circle) => circle.remove());
54
+ activeRipples.clear();
55
+ };
56
+ }, [enabled, color, duration, opacity, sizeMultiplier]);
57
+ if (!enabled) return null;
58
+ return /* @__PURE__ */ jsx(
59
+ Primitive,
60
+ {
61
+ as: "span",
62
+ ref: containerRef,
63
+ sx: {
64
+ position: "absolute",
65
+ inset: 0,
66
+ pointerEvents: "none",
67
+ borderRadius: "inherit",
68
+ overflow: "hidden"
69
+ }
70
+ }
71
+ );
72
+ };
73
+ export {
74
+ RippleEffect
75
+ };
@@ -1,5 +1,4 @@
1
- import { RefObject } from 'react';
2
- type UseRippleEffectOptions = {
1
+ export type RippleEffectProps = {
3
2
  /**
4
3
  * Whether to enable the ripple effect
5
4
  * @default true
@@ -26,7 +25,3 @@ type UseRippleEffectOptions = {
26
25
  */
27
26
  sizeMultiplier?: number;
28
27
  };
29
- export declare const useRippleEffect: (ref: RefObject<HTMLElement | null>, { enabled, color, duration, opacity, sizeMultiplier, }?: UseRippleEffectOptions) => {
30
- className: string;
31
- };
32
- export {};
package/dist/style.css CHANGED
@@ -1,85 +1,4 @@
1
- @keyframes _ripple_1jvqm_7 {
2
- to {
3
- transform: scale(1);
4
- opacity: 0;
5
- }
6
- }
7
- ._ripple_effect_1jvqm_7 {
8
- position: relative;
9
- overflow: hidden;
10
- }
11
-
12
- ._ripple_effect__circle_1jvqm_12 {
13
- position: absolute;
14
- border-radius: 9999px;
15
- background-color: var(--ripple-color);
16
- opacity: var(--ripple-opacity);
17
- transform: scale(0);
18
- transform-origin: center;
19
- will-change: transform, opacity;
20
- backface-visibility: hidden;
21
- touch-action: none;
22
- animation: _ripple_1jvqm_7 var(--ripple-duration) ease-in-out;
23
- }
24
-
25
- @media (prefers-reduced-motion: reduce) {
26
- ._ripple_effect__circle_1jvqm_12 {
27
- animation-duration: calc(var(--ripple-duration) * 0.5);
28
- }
29
- }._input__container_1129f_1 {
30
- position: relative;
31
- display: flex;
32
- flex-direction: column;
33
- width: 100%;
34
- }
35
-
36
- ._input__main_1129f_8 {
37
- width: 100%;
38
- display: flex;
39
- overflow: hidden;
40
- align-items: center;
41
- gap: 0.5rem;
42
- border-radius: 0.5rem;
43
- border-width: 1px;
44
- border-style: solid;
45
- background-color: var(--color-surface-default);
46
- }
47
- ._input__main_1129f_8:hover {
48
- border-color: var(--color-primary-300);
49
- }
50
- ._input__main_1129f_8:has(input:focus:not(:read-only)) {
51
- border-color: var(--color-primary-600);
52
- box-shadow: 0 1px 3px 0 var(--color-primary-300), 0 1px 2px -1px var(--color-primary-300);
53
- }
54
- ._input__main_1129f_8:has(input:read-only) {
55
- pointer-events: none;
56
- }
57
- ._input__main_1129f_8:has(input:disabled) {
58
- background-color: var(--color-neutral-300);
59
- color: var(--color-neutral-500);
60
- border-color: var(--color-neutral-300);
61
- pointer-events: none;
62
- }
63
-
64
- ._input__main_error_1129f_36 {
65
- border-color: var(--color-red-600);
66
- }
67
-
68
- ._input__control_1129f_40 {
69
- flex: 1 1 0%;
70
- width: 100%;
71
- height: 100%;
72
- overflow: hidden;
73
- text-overflow: ellipsis;
74
- white-space: nowrap;
75
- background-color: transparent;
76
- }
77
- ._input__control_1129f_40:focus {
78
- outline: none;
79
- }
80
- ._input__control_1129f_40::placeholder {
81
- color: var(--color-neutral-400);
82
- }._checkbox__container_1rrv2_1 {
1
+ ._checkbox__container_1rrv2_1 {
83
2
  display: flex;
84
3
  align-items: center;
85
4
  gap: 0.5rem;
@@ -815,20 +734,6 @@
815
734
 
816
735
  ._radio_button__input_10dls_10:disabled + ._radio_button__checkmark_10dls_21 {
817
736
  color: var(--color-neutral-300);
818
- }._input_range_1yrkm_1 {
819
- display: flex;
820
- align-items: center;
821
- border-width: 1px;
822
- border-style: solid;
823
- border-radius: 0.5rem;
824
- gap: 0.5rem;
825
- }
826
- ._input_range_1yrkm_1:has(input:focus) {
827
- border-color: var(--color-primary-600);
828
- box-shadow: 0 1px 3px 0 var(--color-primary-300), 0 1px 2px -1px var(--color-primary-300);
829
- }
830
- ._input_range_1yrkm_1:hover {
831
- border-color: var(--color-primary-300);
832
737
  }._switch__container_19zrg_1 {
833
738
  display: flex;
834
739
  align-items: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janbox/storefront-ui",
3
- "version": "2.0.27",
3
+ "version": "2.0.28",
4
4
  "description": "Storefront UI component library for Janbox",
5
5
  "author": "Janbox",
6
6
  "keywords": [
@@ -1,69 +0,0 @@
1
- import { useCallback, useEffect, useMemo } from "react";
2
- import classes from "./use-ripple-effect.module.scss.js";
3
- const useRippleEffect = (ref, {
4
- enabled = true,
5
- color = "currentColor",
6
- duration = 400,
7
- opacity = 0.2,
8
- sizeMultiplier = 1
9
- } = {}) => {
10
- const createRippleCircle = useCallback(
11
- (event) => {
12
- const { currentTarget, clientX, clientY } = event;
13
- const { clientHeight, clientWidth } = currentTarget;
14
- const { left: offsetLeft, top: offsetTop } = currentTarget.getBoundingClientRect();
15
- const circleLeft = clientX - offsetLeft;
16
- const circleTop = clientY - offsetTop;
17
- const circleRight = offsetLeft + clientWidth - clientX;
18
- const circleBottom = offsetTop + clientHeight - clientY;
19
- const radius = Math.max(circleLeft, circleTop, circleRight, circleBottom) * sizeMultiplier;
20
- const circle = document.createElement("div");
21
- circle.style.width = circle.style.height = `${radius * 2}px`;
22
- circle.style.left = `${circleLeft - radius}px`;
23
- circle.style.top = `${circleTop - radius}px`;
24
- circle.classList.add(classes.ripple_effect__circle);
25
- circle.style.setProperty("--ripple-color", color);
26
- circle.style.setProperty("--ripple-duration", `${duration}ms`);
27
- circle.style.setProperty("--ripple-opacity", opacity.toString());
28
- return circle;
29
- },
30
- [color, duration, opacity, sizeMultiplier]
31
- );
32
- const start = useCallback(
33
- (event) => {
34
- var _a;
35
- if (!enabled) return;
36
- const circle = createRippleCircle(event);
37
- const handleAnimationEnd = (ev) => {
38
- if (!ev.target) return;
39
- ev.target.remove();
40
- };
41
- circle.addEventListener("animationend", handleAnimationEnd);
42
- (_a = ref.current) == null ? void 0 : _a.appendChild(circle);
43
- },
44
- [createRippleCircle, enabled, ref]
45
- );
46
- useEffect(() => {
47
- if (!enabled) return;
48
- const targetElement = ref.current;
49
- const handleClick = (e) => {
50
- start(e);
51
- };
52
- targetElement == null ? void 0 : targetElement.addEventListener("click", handleClick);
53
- return () => {
54
- targetElement == null ? void 0 : targetElement.removeEventListener("click", handleClick);
55
- Array.from((targetElement == null ? void 0 : targetElement.getElementsByClassName(classes.ripple_effect__circle)) ?? []).forEach(
56
- (circle) => circle.remove()
57
- );
58
- };
59
- }, [start, enabled, ref]);
60
- return useMemo(
61
- () => ({
62
- className: classes.ripple_effect
63
- }),
64
- []
65
- );
66
- };
67
- export {
68
- useRippleEffect
69
- };
@@ -1,11 +0,0 @@
1
- const ripple_effect = "_ripple_effect_1jvqm_7";
2
- const ripple_effect__circle = "_ripple_effect__circle_1jvqm_12";
3
- const classes = {
4
- ripple_effect,
5
- ripple_effect__circle
6
- };
7
- export {
8
- classes as default,
9
- ripple_effect,
10
- ripple_effect__circle
11
- };
@@ -1,17 +0,0 @@
1
- const input__container = "_input__container_1129f_1";
2
- const input__main = "_input__main_1129f_8";
3
- const input__main_error = "_input__main_error_1129f_36";
4
- const input__control = "_input__control_1129f_40";
5
- const classes = {
6
- input__container,
7
- input__main,
8
- input__main_error,
9
- input__control
10
- };
11
- export {
12
- classes as default,
13
- input__container,
14
- input__control,
15
- input__main,
16
- input__main_error
17
- };
@@ -1,8 +0,0 @@
1
- const input_range = "_input_range_1yrkm_1";
2
- const classes = {
3
- input_range
4
- };
5
- export {
6
- classes as default,
7
- input_range
8
- };