@k3-universe/react-kit 0.0.37 → 0.0.39
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3163 -889
- package/dist/kit/components/keyboard/Keyboard.d.ts +28 -0
- package/dist/kit/components/keyboard/Keyboard.d.ts.map +1 -0
- package/dist/kit/components/keyboard/index.d.ts +5 -0
- package/dist/kit/components/keyboard/index.d.ts.map +1 -0
- package/dist/kit/components/numpad/Numpad.d.ts +26 -0
- package/dist/kit/components/numpad/Numpad.d.ts.map +1 -0
- package/dist/kit/components/numpad/index.d.ts +5 -0
- package/dist/kit/components/numpad/index.d.ts.map +1 -0
- package/dist/kit/themes/base.css +1 -1
- package/dist/kit/themes/clean-slate.css +161 -1
- package/dist/kit/themes/default.css +161 -1
- package/dist/kit/themes/minimal-modern.css +161 -1
- package/dist/kit/themes/spotify.css +161 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/kit/components/keyboard/Keyboard.tsx +916 -0
- package/src/kit/components/keyboard/index.ts +4 -0
- package/src/kit/components/numpad/Numpad.tsx +377 -0
- package/src/kit/components/numpad/index.ts +4 -0
- package/src/shadcn/ui/calendar.tsx +1 -1
- package/src/stories/kit/components/Keyboard.stories.tsx +263 -0
- package/src/stories/kit/components/Numpad.stories.tsx +195 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Numpad } from "../../../kit/components/numpad/Numpad";
|
|
4
|
+
import { Input } from "../../../shadcn/ui/input";
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Numpad> = {
|
|
7
|
+
title: "Kit/Components/Numpad",
|
|
8
|
+
component: Numpad,
|
|
9
|
+
parameters: {
|
|
10
|
+
controls: { expanded: true },
|
|
11
|
+
backgrounds: { disable: true },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
type Story = StoryObj<typeof Numpad>;
|
|
18
|
+
|
|
19
|
+
export const FullNumpad: Story = {
|
|
20
|
+
name: "Full Numpad",
|
|
21
|
+
render: (args) => {
|
|
22
|
+
const [value, setValue] = React.useState("");
|
|
23
|
+
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="p-6 space-y-4">
|
|
27
|
+
<div>
|
|
28
|
+
<div className="text-sm text-muted-foreground mb-2">Amount</div>
|
|
29
|
+
<Input
|
|
30
|
+
ref={inputRef}
|
|
31
|
+
type="text"
|
|
32
|
+
value={value ? Number(value).toLocaleString("id-ID") : ""}
|
|
33
|
+
onChange={(e) => {
|
|
34
|
+
const numValue = (e.target as any).value.replace(/[^\d]/g, "");
|
|
35
|
+
setValue(numValue);
|
|
36
|
+
}}
|
|
37
|
+
placeholder="0"
|
|
38
|
+
className="text-2xl font-bold text-right"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
<Numpad
|
|
42
|
+
{...args}
|
|
43
|
+
value={value}
|
|
44
|
+
onChange={setValue}
|
|
45
|
+
inputRef={inputRef}
|
|
46
|
+
allowDoubleZero
|
|
47
|
+
showBackspaceButton
|
|
48
|
+
showSubmitButton
|
|
49
|
+
showClearButton
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Disabled: Story = {
|
|
57
|
+
name: "Disabled",
|
|
58
|
+
render: (args) => {
|
|
59
|
+
const [value, setValue] = React.useState("12345");
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div className="p-6 space-y-4">
|
|
63
|
+
<div>
|
|
64
|
+
<div className="text-sm text-muted-foreground mb-2">Amount</div>
|
|
65
|
+
<Input
|
|
66
|
+
type="text"
|
|
67
|
+
value={value ? Number(value).toLocaleString("id-ID") : ""}
|
|
68
|
+
onChange={(e) => {
|
|
69
|
+
const numValue = (e.target as any).value.replace(/[^\d]/g, "");
|
|
70
|
+
setValue(numValue);
|
|
71
|
+
}}
|
|
72
|
+
placeholder="0"
|
|
73
|
+
disabled
|
|
74
|
+
className="text-lg font-medium"
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
<Numpad
|
|
78
|
+
{...args}
|
|
79
|
+
value={value}
|
|
80
|
+
onChange={setValue}
|
|
81
|
+
showSubmitButton
|
|
82
|
+
disabled
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const CustomStyling: Story = {
|
|
90
|
+
name: "Custom Styling",
|
|
91
|
+
render: (args) => {
|
|
92
|
+
const [value, setValue] = React.useState("");
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className="p-6 space-y-4">
|
|
96
|
+
<div>
|
|
97
|
+
<div className="text-sm text-muted-foreground mb-2">Amount</div>
|
|
98
|
+
<Input
|
|
99
|
+
type="text"
|
|
100
|
+
value={value ? Number(value).toLocaleString("id-ID") : ""}
|
|
101
|
+
onChange={(e) => {
|
|
102
|
+
const numValue = (e.target as any).value.replace(/[^\d]/g, "");
|
|
103
|
+
setValue(numValue);
|
|
104
|
+
}}
|
|
105
|
+
placeholder="0"
|
|
106
|
+
className="text-lg font-medium"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
<Numpad
|
|
110
|
+
{...args}
|
|
111
|
+
value={value}
|
|
112
|
+
onChange={setValue}
|
|
113
|
+
allowDoubleZero
|
|
114
|
+
customKeyStyle={{ width: "90px", height: "90px" }}
|
|
115
|
+
customKeyClassName="text-3xl font-bold"
|
|
116
|
+
showSubmitButton
|
|
117
|
+
customSubmitStyle={{ width: "90px" }}
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const MultipleInputs: Story = {
|
|
125
|
+
name: "Multiple Inputs (Focused)",
|
|
126
|
+
render: (args) => {
|
|
127
|
+
const [value1, setValue1] = React.useState("");
|
|
128
|
+
const [value2, setValue2] = React.useState("");
|
|
129
|
+
const [focusedInput, setFocusedInput] = React.useState<"input1" | "input2">("input1");
|
|
130
|
+
|
|
131
|
+
const input1Ref = React.useRef<HTMLInputElement>(null);
|
|
132
|
+
const input2Ref = React.useRef<HTMLInputElement>(null);
|
|
133
|
+
|
|
134
|
+
const refs = {
|
|
135
|
+
input1: input1Ref,
|
|
136
|
+
input2: input2Ref,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const currentValue = focusedInput === "input1" ? value1 : value2;
|
|
140
|
+
const setCurrentValue = focusedInput === "input1" ? setValue1 : setValue2;
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<div className="p-6 space-y-4">
|
|
144
|
+
<div className="space-y-2">
|
|
145
|
+
<div>
|
|
146
|
+
<div className="text-sm text-muted-foreground mb-2">Amount 1</div>
|
|
147
|
+
<Input
|
|
148
|
+
ref={input1Ref}
|
|
149
|
+
type="text"
|
|
150
|
+
value={value1 ? Number(value1).toLocaleString("id-ID") : ""}
|
|
151
|
+
onChange={(e) => {
|
|
152
|
+
const numValue = (e.target as any).value.replace(/[^\d]/g, "");
|
|
153
|
+
setValue1(numValue);
|
|
154
|
+
}}
|
|
155
|
+
placeholder="0"
|
|
156
|
+
className="text-lg font-medium"
|
|
157
|
+
onFocus={() => setFocusedInput("input1")}
|
|
158
|
+
/>
|
|
159
|
+
{focusedInput === "input1" && (
|
|
160
|
+
<div className="text-xs text-teal-600 mt-1">✓ Connected</div>
|
|
161
|
+
)}
|
|
162
|
+
</div>
|
|
163
|
+
<div>
|
|
164
|
+
<div className="text-sm text-muted-foreground mb-2">Amount 2</div>
|
|
165
|
+
<Input
|
|
166
|
+
ref={input2Ref}
|
|
167
|
+
type="text"
|
|
168
|
+
value={value2 ? Number(value2).toLocaleString("id-ID") : ""}
|
|
169
|
+
onChange={(e) => {
|
|
170
|
+
const numValue = (e.target as any).value.replace(/[^\d]/g, "");
|
|
171
|
+
setValue2(numValue);
|
|
172
|
+
}}
|
|
173
|
+
placeholder="0"
|
|
174
|
+
className="text-lg font-medium"
|
|
175
|
+
onFocus={() => setFocusedInput("input2")}
|
|
176
|
+
/>
|
|
177
|
+
{focusedInput === "input2" && (
|
|
178
|
+
<div className="text-xs text-teal-600 mt-1">✓ Connected</div>
|
|
179
|
+
)}
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
<Numpad
|
|
183
|
+
{...args}
|
|
184
|
+
value={currentValue}
|
|
185
|
+
onChange={setCurrentValue}
|
|
186
|
+
inputRef={refs[focusedInput]}
|
|
187
|
+
allowDoubleZero
|
|
188
|
+
showBackspaceButton
|
|
189
|
+
showClearButton
|
|
190
|
+
showSubmitButton
|
|
191
|
+
/>
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
},
|
|
195
|
+
};
|