@devup-ui/components 0.1.32 → 0.1.33
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,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),u=require("@devup-ui/react"),m=require("clsx"),d=require("react"),b=require("../Button/index.cjs"),g=require("../Input/index.cjs"),h=require("./IconMinus.cjs"),I=require("./IconPlus.cjs"),S=d.createContext(null),c=()=>{const e=d.useContext(S);if(!e)throw new Error("useStepper must be used within a StepperProvider");return e};function f({children:e,defaultValue:t,value:r,onValueChange:s,min:n=0,max:i=100,type:a="input"}){const[l,p]=d.useState(t??0),v=F=>{const x=Math.min(Math.max(F,n),i);if(s){s(x);return}p(x)};return o.jsx(S.Provider,{value:{value:r??l,setValue:v,min:n,max:i,type:a},children:e})}function C(e){return o.jsx(u.Flex,{alignItems:"center",gap:"8px",styleOrder:1,...e})}function j({...e}){const{value:t,setValue:r,min:s}=c(),n=t<=s;return o.jsx(b.Button,{"aria-label":"Decrease button",className:u.css({p:"0",boxSize:"28px",borderRadius:"4px"}),disabled:n,onClick:()=>r(t-1),...e,children:o.jsx(h.IconMinus,{className:u.css({color:n?"var(--base10, light-dark(#0000001A,#FFFFFF1A))":"var(--text, light-dark(#272727, #F6F6F6))"})})})}function y({...e}){const{value:t,setValue:r,max:s}=c(),n=t>=s;return o.jsx(b.Button,{"aria-label":"Increase button",className:u.css({p:"0",boxSize:"28px",borderRadius:"4px",selectors:{"&>div>div":{}}}),disabled:n,onClick:()=>r(t+1),...e,children:o.jsx(I.IconPlus,{className:u.css({color:n?"var(--base10, light-dark(#0000001A,#FFFFFF1A))":"var(--text, light-dark(#272727, #F6F6F6))"})})})}function k({className:e,...t}){const{value:r,setValue:s,type:n}=c(),i=u.css({p:"0",border:"none",w:"fit-content",h:"fit-content",styleOrder:3}),a=n==="input",l=a?g.Input:"div";return a&&Object.assign(t,{allowClear:!1}),o.jsx(l,{"aria-label":"Stepper value",className:m(u.css({styleOrder:2,w:"60px",textAlign:"center",borderRadius:"6px",selectors:{"&::-webkit-outer-spin-button, &::-webkit-inner-spin-button":{display:"none"}}}),!a&&i,e),dangerouslySetInnerHTML:a?void 0:{__html:Number(r).toString()},"data-value":r,onChange:p=>{s(Number(p.target.value))},readOnly:!a,type:"number",value:r.toString(),...t})}exports.Stepper=f;exports.StepperContainer=C;exports.StepperDecreaseButton=j;exports.StepperIncreaseButton=y;exports.StepperInput=k;exports.useStepper=c;
|
|
@@ -22,9 +22,7 @@ declare function Stepper({ children, defaultValue, value: valueProp, onValueChan
|
|
|
22
22
|
declare function StepperContainer(props: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
declare function StepperDecreaseButton({ ...props }: ComponentProps<typeof Button>): import("react/jsx-runtime").JSX.Element;
|
|
24
24
|
declare function StepperIncreaseButton({ ...props }: ComponentProps<typeof Button>): import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
|
|
26
|
-
editable?: boolean;
|
|
27
|
-
}
|
|
25
|
+
type StepperInputProps = ComponentProps<typeof Input>;
|
|
28
26
|
declare function StepperInput({ className, ...props }: StepperInputProps): import("react/jsx-runtime").JSX.Element;
|
|
29
27
|
export { Stepper, StepperContainer, StepperDecreaseButton, StepperIncreaseButton, StepperInput, };
|
|
30
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAuC,MAAM,OAAO,CAAA;AAE3E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAIhC,KAA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ACrB,YAAY,GACb,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { Flex as
|
|
4
|
-
import
|
|
2
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
3
|
+
import { Flex as f, css as i } from "@devup-ui/react";
|
|
4
|
+
import F from "clsx";
|
|
5
5
|
import { useState as S, createContext as h, useContext as g } from "react";
|
|
6
6
|
import { Button as m } from "../Button/index.js";
|
|
7
7
|
import { Input as C } from "../Input/index.js";
|
|
8
|
-
import { IconMinus as
|
|
9
|
-
import { IconPlus as
|
|
10
|
-
const b = h(null),
|
|
8
|
+
import { IconMinus as I } from "./IconMinus.js";
|
|
9
|
+
import { IconPlus as k } from "./IconPlus.js";
|
|
10
|
+
const b = h(null), c = () => {
|
|
11
11
|
const e = g(b);
|
|
12
12
|
if (!e)
|
|
13
13
|
throw new Error("useStepper must be used within a StepperProvider");
|
|
@@ -15,41 +15,41 @@ const b = h(null), p = () => {
|
|
|
15
15
|
};
|
|
16
16
|
function B({
|
|
17
17
|
children: e,
|
|
18
|
-
defaultValue:
|
|
18
|
+
defaultValue: t,
|
|
19
19
|
value: n,
|
|
20
20
|
onValueChange: o,
|
|
21
|
-
min:
|
|
21
|
+
min: r = 0,
|
|
22
22
|
max: l = 100,
|
|
23
|
-
type:
|
|
23
|
+
type: a = "input"
|
|
24
24
|
}) {
|
|
25
|
-
const [
|
|
26
|
-
const d = Math.min(Math.max(
|
|
25
|
+
const [u, p] = S(t ?? 0), v = (x) => {
|
|
26
|
+
const d = Math.min(Math.max(x, r), l);
|
|
27
27
|
if (o) {
|
|
28
28
|
o(d);
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
p(d);
|
|
32
32
|
};
|
|
33
|
-
return /* @__PURE__ */
|
|
33
|
+
return /* @__PURE__ */ s(
|
|
34
34
|
b.Provider,
|
|
35
35
|
{
|
|
36
36
|
value: {
|
|
37
|
-
value: n ??
|
|
38
|
-
setValue:
|
|
39
|
-
min:
|
|
37
|
+
value: n ?? u,
|
|
38
|
+
setValue: v,
|
|
39
|
+
min: r,
|
|
40
40
|
max: l,
|
|
41
|
-
type:
|
|
41
|
+
type: a
|
|
42
42
|
},
|
|
43
43
|
children: e
|
|
44
44
|
}
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
function P(e) {
|
|
48
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ s(f, { alignItems: "center", gap: "8px", styleOrder: 1, ...e });
|
|
49
49
|
}
|
|
50
50
|
function R({ ...e }) {
|
|
51
|
-
const { value:
|
|
52
|
-
return /* @__PURE__ */
|
|
51
|
+
const { value: t, setValue: n, min: o } = c(), r = t <= o;
|
|
52
|
+
return /* @__PURE__ */ s(
|
|
53
53
|
m,
|
|
54
54
|
{
|
|
55
55
|
"aria-label": "Decrease button",
|
|
@@ -58,23 +58,23 @@ function R({ ...e }) {
|
|
|
58
58
|
boxSize: "28px",
|
|
59
59
|
borderRadius: "4px"
|
|
60
60
|
}),
|
|
61
|
-
disabled:
|
|
62
|
-
onClick: () => n(
|
|
61
|
+
disabled: r,
|
|
62
|
+
onClick: () => n(t - 1),
|
|
63
63
|
...e,
|
|
64
|
-
children: /* @__PURE__ */
|
|
65
|
-
|
|
64
|
+
children: /* @__PURE__ */ s(
|
|
65
|
+
I,
|
|
66
66
|
{
|
|
67
67
|
className: i({
|
|
68
|
-
color:
|
|
68
|
+
color: r ? "var(--base10, light-dark(#0000001A,#FFFFFF1A))" : "var(--text, light-dark(#272727, #F6F6F6))"
|
|
69
69
|
})
|
|
70
70
|
}
|
|
71
71
|
)
|
|
72
72
|
}
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
const { value:
|
|
77
|
-
return /* @__PURE__ */
|
|
75
|
+
function j({ ...e }) {
|
|
76
|
+
const { value: t, setValue: n, max: o } = c(), r = t >= o;
|
|
77
|
+
return /* @__PURE__ */ s(
|
|
78
78
|
m,
|
|
79
79
|
{
|
|
80
80
|
"aria-label": "Increase button",
|
|
@@ -86,34 +86,33 @@ function D({ ...e }) {
|
|
|
86
86
|
"&>div>div": {}
|
|
87
87
|
}
|
|
88
88
|
}),
|
|
89
|
-
disabled:
|
|
90
|
-
onClick: () => n(
|
|
89
|
+
disabled: r,
|
|
90
|
+
onClick: () => n(t + 1),
|
|
91
91
|
...e,
|
|
92
|
-
children: /* @__PURE__ */
|
|
93
|
-
|
|
92
|
+
children: /* @__PURE__ */ s(
|
|
93
|
+
k,
|
|
94
94
|
{
|
|
95
95
|
className: i({
|
|
96
|
-
color:
|
|
96
|
+
color: r ? "var(--base10, light-dark(#0000001A,#FFFFFF1A))" : "var(--text, light-dark(#272727, #F6F6F6))"
|
|
97
97
|
})
|
|
98
98
|
}
|
|
99
99
|
)
|
|
100
100
|
}
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
const { value: n, setValue: o, type:
|
|
103
|
+
function D({ className: e, ...t }) {
|
|
104
|
+
const { value: n, setValue: o, type: r } = c(), l = i({
|
|
105
105
|
p: "0",
|
|
106
106
|
border: "none",
|
|
107
107
|
w: "fit-content",
|
|
108
108
|
h: "fit-content",
|
|
109
109
|
styleOrder: 3
|
|
110
|
-
}),
|
|
111
|
-
return /* @__PURE__ */
|
|
112
|
-
|
|
110
|
+
}), a = r === "input", u = a ? C : "div";
|
|
111
|
+
return a && Object.assign(t, { allowClear: !1 }), /* @__PURE__ */ s(
|
|
112
|
+
u,
|
|
113
113
|
{
|
|
114
|
-
allowClear: !1,
|
|
115
114
|
"aria-label": "Stepper value",
|
|
116
|
-
className:
|
|
115
|
+
className: F(
|
|
117
116
|
i({
|
|
118
117
|
styleOrder: 2,
|
|
119
118
|
w: "60px",
|
|
@@ -125,16 +124,18 @@ function E({ className: e, ...r }) {
|
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
}),
|
|
128
|
-
!
|
|
127
|
+
!a && l,
|
|
129
128
|
e
|
|
130
129
|
),
|
|
131
|
-
dangerouslySetInnerHTML:
|
|
130
|
+
dangerouslySetInnerHTML: a ? void 0 : { __html: Number(n).toString() },
|
|
132
131
|
"data-value": n,
|
|
133
|
-
onChange: (
|
|
134
|
-
|
|
132
|
+
onChange: (p) => {
|
|
133
|
+
o(Number(p.target.value));
|
|
134
|
+
},
|
|
135
|
+
readOnly: !a,
|
|
135
136
|
type: "number",
|
|
136
|
-
value: n,
|
|
137
|
-
...
|
|
137
|
+
value: n.toString(),
|
|
138
|
+
...t
|
|
138
139
|
}
|
|
139
140
|
);
|
|
140
141
|
}
|
|
@@ -142,7 +143,7 @@ export {
|
|
|
142
143
|
B as Stepper,
|
|
143
144
|
P as StepperContainer,
|
|
144
145
|
R as StepperDecreaseButton,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
j as StepperIncreaseButton,
|
|
147
|
+
D as StepperInput,
|
|
148
|
+
c as useStepper
|
|
148
149
|
};
|