@ymjin/ui-native 0.1.0
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/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/index.cjs +547 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +219 -0
- package/dist/index.d.ts +219 -0
- package/dist/index.js +498 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ymjin (kitforge)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @ymjin/ui-native
|
|
2
|
+
|
|
3
|
+
React Native components styled with `@ymjin/tokens` via **NativeWind** — the
|
|
4
|
+
native counterpart to `@ymjin/ui` (web). Same `variant`/`size` API; the
|
|
5
|
+
styling resolves through the **same token Tailwind preset** the web build uses,
|
|
6
|
+
so `bg-primary-500` is the identical value on web and native.
|
|
7
|
+
|
|
8
|
+
## Phase 1 components
|
|
9
|
+
|
|
10
|
+
| Component | Built on | Notes |
|
|
11
|
+
|-----------|----------|-------|
|
|
12
|
+
| `Button` | `Pressable` | variants (primary/secondary/outline/ghost/danger), sizes, `onPress` |
|
|
13
|
+
| `TextField` | `TextInput` | label, description, error |
|
|
14
|
+
| `Switch` | RN `Switch` | token track/thumb colors |
|
|
15
|
+
| `Checkbox` | `Pressable` | custom indicator |
|
|
16
|
+
| `Modal` | RN `Modal` | dimmed backdrop, tap-to-close |
|
|
17
|
+
| `Badge` / `Card` (+ Header/Body/Footer) / `Spinner` | `View`/`Text`/`ActivityIndicator` | display |
|
|
18
|
+
|
|
19
|
+
Phase 2 (community-lib wrappers): `Select`, `DatePicker`, `RadioGroup`, `Slider`, `Toast`.
|
|
20
|
+
|
|
21
|
+
## Setup
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm i @ymjin/ui-native @ymjin/tokens nativewind react-native
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
// tailwind.config.js — layer the kitforge token preset on top of NativeWind
|
|
29
|
+
module.exports = {
|
|
30
|
+
presets: [require("nativewind/preset"), require("@ymjin/tokens/tailwind")],
|
|
31
|
+
content: [
|
|
32
|
+
"./node_modules/@ymjin/ui-native/dist/**/*.js",
|
|
33
|
+
"./app/**/*.{tsx,jsx}",
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Add `nativewind/babel` to your Babel config and import your `global.css`
|
|
39
|
+
(NativeWind v4 setup). Then:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { Button, TextField, Switch, Modal } from "@ymjin/ui-native";
|
|
43
|
+
|
|
44
|
+
function Form() {
|
|
45
|
+
const [open, setOpen] = useState(false);
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<TextField label="이메일" placeholder="you@company.com" />
|
|
49
|
+
<Switch label="알림 받기" value={on} onValueChange={setOn} />
|
|
50
|
+
<Button variant="primary" onPress={() => setOpen(true)}>제출</Button>
|
|
51
|
+
<Modal visible={open} onClose={() => setOpen(false)} title="확인">
|
|
52
|
+
<Button variant="ghost" onPress={() => setOpen(false)}>닫기</Button>
|
|
53
|
+
</Modal>
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Design notes
|
|
60
|
+
|
|
61
|
+
- **API parity, native events:** props mirror `@ymjin/ui` (`variant`, `size`),
|
|
62
|
+
but events use RN conventions (`onPress`, `onValueChange`).
|
|
63
|
+
- **Tokens as JS values:** where a class can't apply (RN `trackColor`,
|
|
64
|
+
`placeholderTextColor`, `ActivityIndicator` color), the component imports the
|
|
65
|
+
token value from `@ymjin/tokens` — still one source of truth.
|
|
66
|
+
- **Shadows/fonts:** Tailwind shadows map partially on RN; custom fonts must be
|
|
67
|
+
loaded by your app. Phase 1 uses system fonts.
|
|
68
|
+
- **Web stays on `@ymjin/ui`** (React Aria) — best-in-class web a11y; this
|
|
69
|
+
package is for React Native only.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
Badge: () => Badge,
|
|
34
|
+
Button: () => Button,
|
|
35
|
+
Card: () => Card,
|
|
36
|
+
CardBody: () => CardBody,
|
|
37
|
+
CardFooter: () => CardFooter,
|
|
38
|
+
CardHeader: () => CardHeader,
|
|
39
|
+
Checkbox: () => Checkbox,
|
|
40
|
+
DatePicker: () => DatePicker,
|
|
41
|
+
Modal: () => Modal,
|
|
42
|
+
Radio: () => Radio,
|
|
43
|
+
RadioGroup: () => RadioGroup,
|
|
44
|
+
Select: () => Select,
|
|
45
|
+
Slider: () => Slider,
|
|
46
|
+
Spinner: () => Spinner,
|
|
47
|
+
Switch: () => Switch,
|
|
48
|
+
TextField: () => TextField,
|
|
49
|
+
ToastProvider: () => ToastProvider,
|
|
50
|
+
cx: () => cx,
|
|
51
|
+
useToast: () => useToast
|
|
52
|
+
});
|
|
53
|
+
module.exports = __toCommonJS(index_exports);
|
|
54
|
+
|
|
55
|
+
// src/components/Button.tsx
|
|
56
|
+
var import_react_native = require("react-native");
|
|
57
|
+
|
|
58
|
+
// src/utils/cx.ts
|
|
59
|
+
function cx(...parts) {
|
|
60
|
+
return parts.filter(Boolean).join(" ");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/components/Button.tsx
|
|
64
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
65
|
+
var VARIANT = {
|
|
66
|
+
primary: { container: "bg-primary-500 active:bg-primary-700", text: "text-white" },
|
|
67
|
+
secondary: { container: "bg-neutral-100 active:bg-neutral-300", text: "text-neutral-900" },
|
|
68
|
+
outline: { container: "border border-neutral-300 active:bg-neutral-100", text: "text-neutral-900" },
|
|
69
|
+
ghost: { container: "active:bg-neutral-100", text: "text-neutral-900" },
|
|
70
|
+
danger: { container: "bg-danger-500 active:bg-danger-700", text: "text-white" }
|
|
71
|
+
};
|
|
72
|
+
var SIZE = {
|
|
73
|
+
sm: { container: "px-2.5 py-1", text: "text-sm" },
|
|
74
|
+
md: { container: "px-4 py-2", text: "text-base" },
|
|
75
|
+
lg: { container: "px-5 py-3", text: "text-lg" }
|
|
76
|
+
};
|
|
77
|
+
function Button({
|
|
78
|
+
variant = "primary",
|
|
79
|
+
size = "md",
|
|
80
|
+
onPress,
|
|
81
|
+
disabled,
|
|
82
|
+
children,
|
|
83
|
+
className
|
|
84
|
+
}) {
|
|
85
|
+
const v = VARIANT[variant];
|
|
86
|
+
const s = SIZE[size];
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
88
|
+
import_react_native.Pressable,
|
|
89
|
+
{
|
|
90
|
+
accessibilityRole: "button",
|
|
91
|
+
accessibilityState: { disabled },
|
|
92
|
+
onPress,
|
|
93
|
+
disabled,
|
|
94
|
+
className: cx(
|
|
95
|
+
"flex-row items-center justify-center rounded-md",
|
|
96
|
+
v.container,
|
|
97
|
+
s.container,
|
|
98
|
+
disabled && "opacity-50",
|
|
99
|
+
className
|
|
100
|
+
),
|
|
101
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { className: cx("font-medium", v.text, s.text), children })
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/components/TextField.tsx
|
|
107
|
+
var import_react_native2 = require("react-native");
|
|
108
|
+
var import_tokens = require("@ymjin/tokens");
|
|
109
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
110
|
+
function TextField({
|
|
111
|
+
label,
|
|
112
|
+
placeholder,
|
|
113
|
+
value,
|
|
114
|
+
onChangeText,
|
|
115
|
+
description,
|
|
116
|
+
errorMessage,
|
|
117
|
+
secureTextEntry,
|
|
118
|
+
keyboardType,
|
|
119
|
+
autoCapitalize,
|
|
120
|
+
editable,
|
|
121
|
+
className
|
|
122
|
+
}) {
|
|
123
|
+
const invalid = errorMessage != null;
|
|
124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.View, { className: cx("gap-1.5", className), children: [
|
|
125
|
+
label != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { className: "text-sm font-medium text-neutral-800", children: label }),
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
127
|
+
import_react_native2.TextInput,
|
|
128
|
+
{
|
|
129
|
+
value,
|
|
130
|
+
onChangeText,
|
|
131
|
+
placeholder,
|
|
132
|
+
placeholderTextColor: import_tokens.color.neutral[400],
|
|
133
|
+
secureTextEntry,
|
|
134
|
+
keyboardType,
|
|
135
|
+
autoCapitalize,
|
|
136
|
+
editable,
|
|
137
|
+
className: cx(
|
|
138
|
+
"rounded-md border px-3 py-2 text-base text-neutral-900",
|
|
139
|
+
invalid ? "border-danger-500" : "border-neutral-300"
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
description != null && !invalid && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { className: "text-xs text-neutral-500", children: description }),
|
|
144
|
+
invalid && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { className: "text-xs text-danger-600", children: errorMessage })
|
|
145
|
+
] });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// src/components/Switch.tsx
|
|
149
|
+
var import_react_native3 = require("react-native");
|
|
150
|
+
var import_tokens2 = require("@ymjin/tokens");
|
|
151
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
152
|
+
function Switch({ value, onValueChange, label, disabled, className }) {
|
|
153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native3.View, { className: cx("flex-row items-center gap-2", disabled && "opacity-50", className), children: [
|
|
154
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
155
|
+
import_react_native3.Switch,
|
|
156
|
+
{
|
|
157
|
+
value,
|
|
158
|
+
onValueChange,
|
|
159
|
+
disabled,
|
|
160
|
+
trackColor: { false: import_tokens2.color.neutral[300], true: import_tokens2.color.primary[500] },
|
|
161
|
+
thumbColor: import_tokens2.color.white
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
label != null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { className: "text-base text-neutral-900", children: label })
|
|
165
|
+
] });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// src/components/Checkbox.tsx
|
|
169
|
+
var import_react_native4 = require("react-native");
|
|
170
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
171
|
+
function Checkbox({ value, onValueChange, label, disabled, className }) {
|
|
172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
173
|
+
import_react_native4.Pressable,
|
|
174
|
+
{
|
|
175
|
+
accessibilityRole: "checkbox",
|
|
176
|
+
accessibilityState: { checked: value, disabled },
|
|
177
|
+
onPress: () => onValueChange?.(!value),
|
|
178
|
+
disabled,
|
|
179
|
+
className: cx("flex-row items-center gap-2", disabled && "opacity-50", className),
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
182
|
+
import_react_native4.View,
|
|
183
|
+
{
|
|
184
|
+
className: cx(
|
|
185
|
+
"h-5 w-5 items-center justify-center rounded border-2",
|
|
186
|
+
value ? "border-primary-500 bg-primary-500" : "border-neutral-300 bg-white"
|
|
187
|
+
),
|
|
188
|
+
children: value && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.Text, { className: "text-xs text-white", children: "\u2713" })
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
label != null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.Text, { className: "text-base text-neutral-900", children: label })
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/components/Modal.tsx
|
|
198
|
+
var import_react_native5 = require("react-native");
|
|
199
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
200
|
+
function Modal({ visible, onClose, title, children, className }) {
|
|
201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.Modal, { visible, transparent: true, animationType: "fade", onRequestClose: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.Pressable, { onPress: onClose, className: "flex-1 items-center justify-center bg-black/40 p-4", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
202
|
+
import_react_native5.Pressable,
|
|
203
|
+
{
|
|
204
|
+
onPress: () => void 0,
|
|
205
|
+
className: cx("w-full max-w-md rounded-xl bg-white p-6", className),
|
|
206
|
+
children: [
|
|
207
|
+
title != null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.Text, { className: "mb-3 text-xl font-semibold text-neutral-900", children: title }),
|
|
208
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.View, { children })
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
) }) });
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/components/Badge.tsx
|
|
215
|
+
var import_react_native6 = require("react-native");
|
|
216
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
217
|
+
var CONTAINER = {
|
|
218
|
+
neutral: "bg-neutral-100",
|
|
219
|
+
primary: "bg-primary-100",
|
|
220
|
+
success: "bg-success-100",
|
|
221
|
+
warning: "bg-warning-100",
|
|
222
|
+
danger: "bg-danger-100"
|
|
223
|
+
};
|
|
224
|
+
var TEXT = {
|
|
225
|
+
neutral: "text-neutral-700",
|
|
226
|
+
primary: "text-primary-700",
|
|
227
|
+
success: "text-success-700",
|
|
228
|
+
warning: "text-warning-700",
|
|
229
|
+
danger: "text-danger-700"
|
|
230
|
+
};
|
|
231
|
+
function Badge({ variant = "neutral", children, className }) {
|
|
232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.View, { className: cx("self-start rounded-full px-2 py-0.5", CONTAINER[variant], className), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.Text, { className: cx("text-xs font-medium", TEXT[variant]), children }) });
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/components/Card.tsx
|
|
236
|
+
var import_react_native7 = require("react-native");
|
|
237
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
238
|
+
function Card({ children, className }) {
|
|
239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native7.View, { className: cx("overflow-hidden rounded-lg border border-neutral-200 bg-white", className), children });
|
|
240
|
+
}
|
|
241
|
+
function CardHeader({ children, className }) {
|
|
242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native7.View, { className: cx("border-b border-neutral-100 px-5 py-4", className), children });
|
|
243
|
+
}
|
|
244
|
+
function CardBody({ children, className }) {
|
|
245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native7.View, { className: cx("p-5", className), children });
|
|
246
|
+
}
|
|
247
|
+
function CardFooter({ children, className }) {
|
|
248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native7.View, { className: cx("border-t border-neutral-100 px-5 py-4", className), children });
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// src/components/Spinner.tsx
|
|
252
|
+
var import_react_native8 = require("react-native");
|
|
253
|
+
var import_tokens3 = require("@ymjin/tokens");
|
|
254
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
255
|
+
function Spinner({ size = "md", color: tint, className }) {
|
|
256
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
257
|
+
import_react_native8.ActivityIndicator,
|
|
258
|
+
{
|
|
259
|
+
size: size === "lg" ? "large" : "small",
|
|
260
|
+
color: tint ?? import_tokens3.color.primary[500],
|
|
261
|
+
className
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// src/components/RadioGroup.tsx
|
|
267
|
+
var import_react = require("react");
|
|
268
|
+
var import_react_native9 = require("react-native");
|
|
269
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
270
|
+
var RadioContext = (0, import_react.createContext)({});
|
|
271
|
+
function RadioGroup({
|
|
272
|
+
value,
|
|
273
|
+
onValueChange,
|
|
274
|
+
label,
|
|
275
|
+
disabled,
|
|
276
|
+
children,
|
|
277
|
+
className
|
|
278
|
+
}) {
|
|
279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native9.View, { className: cx("gap-1.5", className), children: [
|
|
280
|
+
label != null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native9.Text, { className: "text-sm font-medium text-neutral-800", children: label }),
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RadioContext.Provider, { value: { value, onChange: onValueChange, disabled }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native9.View, { className: "gap-2", children }) })
|
|
282
|
+
] });
|
|
283
|
+
}
|
|
284
|
+
function Radio({ value, label, disabled, className }) {
|
|
285
|
+
const ctx = (0, import_react.useContext)(RadioContext);
|
|
286
|
+
const selected = ctx.value === value;
|
|
287
|
+
const isDisabled = disabled || ctx.disabled;
|
|
288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
289
|
+
import_react_native9.Pressable,
|
|
290
|
+
{
|
|
291
|
+
accessibilityRole: "radio",
|
|
292
|
+
accessibilityState: { selected, disabled: isDisabled },
|
|
293
|
+
onPress: () => ctx.onChange?.(value),
|
|
294
|
+
disabled: isDisabled,
|
|
295
|
+
className: cx("flex-row items-center gap-2", isDisabled && "opacity-50", className),
|
|
296
|
+
children: [
|
|
297
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
298
|
+
import_react_native9.View,
|
|
299
|
+
{
|
|
300
|
+
className: cx(
|
|
301
|
+
"h-5 w-5 items-center justify-center rounded-full border-2",
|
|
302
|
+
selected ? "border-primary-500" : "border-neutral-300"
|
|
303
|
+
),
|
|
304
|
+
children: selected && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native9.View, { className: "h-2.5 w-2.5 rounded-full bg-primary-500" })
|
|
305
|
+
}
|
|
306
|
+
),
|
|
307
|
+
label != null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native9.Text, { className: "text-base text-neutral-900", children: label })
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// src/components/Select.tsx
|
|
314
|
+
var import_react2 = require("react");
|
|
315
|
+
var import_react_native10 = require("react-native");
|
|
316
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
317
|
+
function Select({
|
|
318
|
+
label,
|
|
319
|
+
placeholder = "\uC120\uD0DD\uD558\uC138\uC694",
|
|
320
|
+
value,
|
|
321
|
+
onValueChange,
|
|
322
|
+
options,
|
|
323
|
+
disabled,
|
|
324
|
+
className
|
|
325
|
+
}) {
|
|
326
|
+
const [open, setOpen] = (0, import_react2.useState)(false);
|
|
327
|
+
const selected = options.find((o) => o.value === value);
|
|
328
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native10.View, { className: cx("gap-1.5", className), children: [
|
|
329
|
+
label != null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.Text, { className: "text-sm font-medium text-neutral-800", children: label }),
|
|
330
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
331
|
+
import_react_native10.Pressable,
|
|
332
|
+
{
|
|
333
|
+
accessibilityRole: "button",
|
|
334
|
+
onPress: () => setOpen(true),
|
|
335
|
+
disabled,
|
|
336
|
+
className: cx(
|
|
337
|
+
"flex-row items-center justify-between rounded-md border border-neutral-300 bg-white px-3 py-2",
|
|
338
|
+
disabled && "opacity-50"
|
|
339
|
+
),
|
|
340
|
+
children: [
|
|
341
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.Text, { className: cx("text-base", selected ? "text-neutral-900" : "text-neutral-400"), children: selected ? selected.label : placeholder }),
|
|
342
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.Text, { className: "text-neutral-500", children: "\u25BE" })
|
|
343
|
+
]
|
|
344
|
+
}
|
|
345
|
+
),
|
|
346
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Modal, { visible: open, onClose: () => setOpen(false), title: label, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.View, { className: "gap-1", children: options.map((o) => {
|
|
347
|
+
const isSelected = o.value === value;
|
|
348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
349
|
+
import_react_native10.Pressable,
|
|
350
|
+
{
|
|
351
|
+
onPress: () => {
|
|
352
|
+
onValueChange?.(o.value);
|
|
353
|
+
setOpen(false);
|
|
354
|
+
},
|
|
355
|
+
className: cx("rounded px-2 py-3", isSelected && "bg-primary-50"),
|
|
356
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
357
|
+
import_react_native10.Text,
|
|
358
|
+
{
|
|
359
|
+
className: cx(
|
|
360
|
+
"text-base",
|
|
361
|
+
isSelected ? "text-primary-700" : "text-neutral-900"
|
|
362
|
+
),
|
|
363
|
+
children: o.label
|
|
364
|
+
}
|
|
365
|
+
)
|
|
366
|
+
},
|
|
367
|
+
o.value
|
|
368
|
+
);
|
|
369
|
+
}) }) })
|
|
370
|
+
] });
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// src/components/Slider.tsx
|
|
374
|
+
var import_slider = __toESM(require("@react-native-community/slider"), 1);
|
|
375
|
+
var import_react_native11 = require("react-native");
|
|
376
|
+
var import_tokens4 = require("@ymjin/tokens");
|
|
377
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
378
|
+
function Slider({
|
|
379
|
+
value,
|
|
380
|
+
onValueChange,
|
|
381
|
+
minimumValue = 0,
|
|
382
|
+
maximumValue = 100,
|
|
383
|
+
step,
|
|
384
|
+
label,
|
|
385
|
+
showValue = true,
|
|
386
|
+
disabled,
|
|
387
|
+
className
|
|
388
|
+
}) {
|
|
389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native11.View, { className: cx("gap-2", className), children: [
|
|
390
|
+
(label != null || showValue) && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native11.View, { className: "flex-row items-center justify-between", children: [
|
|
391
|
+
label != null ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.Text, { className: "text-sm font-medium text-neutral-800", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, {}),
|
|
392
|
+
showValue && value != null && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.Text, { className: "text-sm text-neutral-600", children: value })
|
|
393
|
+
] }),
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
395
|
+
import_slider.default,
|
|
396
|
+
{
|
|
397
|
+
value,
|
|
398
|
+
onValueChange,
|
|
399
|
+
minimumValue,
|
|
400
|
+
maximumValue,
|
|
401
|
+
step,
|
|
402
|
+
disabled,
|
|
403
|
+
minimumTrackTintColor: import_tokens4.color.primary[500],
|
|
404
|
+
maximumTrackTintColor: import_tokens4.color.neutral[200],
|
|
405
|
+
thumbTintColor: import_tokens4.color.primary[500]
|
|
406
|
+
}
|
|
407
|
+
)
|
|
408
|
+
] });
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// src/components/DatePicker.tsx
|
|
412
|
+
var import_react3 = require("react");
|
|
413
|
+
var import_datetimepicker = __toESM(require("@react-native-community/datetimepicker"), 1);
|
|
414
|
+
var import_react_native12 = require("react-native");
|
|
415
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
416
|
+
function DatePicker({
|
|
417
|
+
label,
|
|
418
|
+
value,
|
|
419
|
+
onChange,
|
|
420
|
+
mode = "date",
|
|
421
|
+
placeholder = "\uB0A0\uC9DC \uC120\uD0DD",
|
|
422
|
+
minimumDate,
|
|
423
|
+
maximumDate,
|
|
424
|
+
disabled,
|
|
425
|
+
className
|
|
426
|
+
}) {
|
|
427
|
+
const [show, setShow] = (0, import_react3.useState)(false);
|
|
428
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native12.View, { className: cx("gap-1.5", className), children: [
|
|
429
|
+
label != null && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native12.Text, { className: "text-sm font-medium text-neutral-800", children: label }),
|
|
430
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
431
|
+
import_react_native12.Pressable,
|
|
432
|
+
{
|
|
433
|
+
accessibilityRole: "button",
|
|
434
|
+
onPress: () => setShow(true),
|
|
435
|
+
disabled,
|
|
436
|
+
className: cx(
|
|
437
|
+
"rounded-md border border-neutral-300 bg-white px-3 py-2",
|
|
438
|
+
disabled && "opacity-50"
|
|
439
|
+
),
|
|
440
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native12.Text, { className: cx("text-base", value ? "text-neutral-900" : "text-neutral-400"), children: value ? formatDate(value, mode) : placeholder })
|
|
441
|
+
}
|
|
442
|
+
),
|
|
443
|
+
show && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
444
|
+
import_datetimepicker.default,
|
|
445
|
+
{
|
|
446
|
+
value: value ?? /* @__PURE__ */ new Date(),
|
|
447
|
+
mode,
|
|
448
|
+
minimumDate,
|
|
449
|
+
maximumDate,
|
|
450
|
+
onChange: (event, date) => {
|
|
451
|
+
setShow(import_react_native12.Platform.OS === "ios");
|
|
452
|
+
if (event.type !== "dismissed" && date) onChange?.(date);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
)
|
|
456
|
+
] });
|
|
457
|
+
}
|
|
458
|
+
function formatDate(d, mode) {
|
|
459
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
460
|
+
const date = `${d.getFullYear()}.${pad(d.getMonth() + 1)}.${pad(d.getDate())}`;
|
|
461
|
+
const time = `${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
462
|
+
if (mode === "time") return time;
|
|
463
|
+
if (mode === "datetime") return `${date} ${time}`;
|
|
464
|
+
return date;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// src/components/Toast.tsx
|
|
468
|
+
var import_react4 = require("react");
|
|
469
|
+
var import_react_native13 = require("react-native");
|
|
470
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
471
|
+
var ToastContext = (0, import_react4.createContext)(null);
|
|
472
|
+
var BORDER = {
|
|
473
|
+
info: "border-l-primary-500",
|
|
474
|
+
success: "border-l-success-500",
|
|
475
|
+
warning: "border-l-warning-500",
|
|
476
|
+
danger: "border-l-danger-500"
|
|
477
|
+
};
|
|
478
|
+
function ToastProvider({ children, duration = 4e3 }) {
|
|
479
|
+
const [toasts, setToasts] = (0, import_react4.useState)([]);
|
|
480
|
+
const seq = (0, import_react4.useRef)(0);
|
|
481
|
+
const dismiss = (0, import_react4.useCallback)((id) => {
|
|
482
|
+
setToasts((list) => list.filter((t) => t.id !== id));
|
|
483
|
+
}, []);
|
|
484
|
+
const toast = (0, import_react4.useCallback)(
|
|
485
|
+
(options) => {
|
|
486
|
+
const opts = typeof options === "string" ? { description: options } : options;
|
|
487
|
+
seq.current += 1;
|
|
488
|
+
const id = `kf-toast-${seq.current}`;
|
|
489
|
+
setToasts((list) => [
|
|
490
|
+
...list,
|
|
491
|
+
{ id, title: opts.title, description: opts.description, variant: opts.variant ?? "info" }
|
|
492
|
+
]);
|
|
493
|
+
const ms = opts.duration ?? duration;
|
|
494
|
+
if (ms > 0) setTimeout(() => dismiss(id), ms);
|
|
495
|
+
return id;
|
|
496
|
+
},
|
|
497
|
+
[duration, dismiss]
|
|
498
|
+
);
|
|
499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(ToastContext.Provider, { value: { toast, dismiss }, children: [
|
|
500
|
+
children,
|
|
501
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native13.View, { pointerEvents: "box-none", className: "absolute inset-x-0 bottom-0 gap-2 p-4", children: toasts.map((t) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
502
|
+
import_react_native13.View,
|
|
503
|
+
{
|
|
504
|
+
accessibilityRole: "alert",
|
|
505
|
+
className: cx(
|
|
506
|
+
"rounded-lg border border-neutral-200 border-l-4 bg-white px-4 py-3",
|
|
507
|
+
BORDER[t.variant]
|
|
508
|
+
),
|
|
509
|
+
children: [
|
|
510
|
+
t.title != null && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native13.Text, { className: "text-sm font-semibold text-neutral-900", children: t.title }),
|
|
511
|
+
t.description != null && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native13.Text, { className: "text-sm text-neutral-600", children: t.description })
|
|
512
|
+
]
|
|
513
|
+
},
|
|
514
|
+
t.id
|
|
515
|
+
)) })
|
|
516
|
+
] });
|
|
517
|
+
}
|
|
518
|
+
function useToast() {
|
|
519
|
+
const ctx = (0, import_react4.useContext)(ToastContext);
|
|
520
|
+
if (!ctx) {
|
|
521
|
+
throw new Error("[@ymjin/ui-native] useToast must be used inside a <ToastProvider>.");
|
|
522
|
+
}
|
|
523
|
+
return ctx;
|
|
524
|
+
}
|
|
525
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
526
|
+
0 && (module.exports = {
|
|
527
|
+
Badge,
|
|
528
|
+
Button,
|
|
529
|
+
Card,
|
|
530
|
+
CardBody,
|
|
531
|
+
CardFooter,
|
|
532
|
+
CardHeader,
|
|
533
|
+
Checkbox,
|
|
534
|
+
DatePicker,
|
|
535
|
+
Modal,
|
|
536
|
+
Radio,
|
|
537
|
+
RadioGroup,
|
|
538
|
+
Select,
|
|
539
|
+
Slider,
|
|
540
|
+
Spinner,
|
|
541
|
+
Switch,
|
|
542
|
+
TextField,
|
|
543
|
+
ToastProvider,
|
|
544
|
+
cx,
|
|
545
|
+
useToast
|
|
546
|
+
});
|
|
547
|
+
//# sourceMappingURL=index.cjs.map
|