@ymjin/ui-native 0.1.0 → 0.2.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/README.md +11 -1
- package/dist/chunk-LHWLG5RR.js +9 -0
- package/dist/chunk-LHWLG5RR.js.map +1 -0
- package/dist/date-picker.cjs +103 -0
- package/dist/date-picker.cjs.map +1 -0
- package/dist/date-picker.d.cts +22 -0
- package/dist/date-picker.d.ts +22 -0
- package/dist/date-picker.js +63 -0
- package/dist/date-picker.js.map +1 -0
- package/dist/index.cjs +42 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -38
- package/dist/index.d.ts +7 -38
- package/dist/index.js +41 -130
- package/dist/index.js.map +1 -1
- package/dist/slider.cjs +85 -0
- package/dist/slider.cjs.map +1 -0
- package/dist/slider.d.cts +21 -0
- package/dist/slider.d.ts +21 -0
- package/dist/slider.js +45 -0
- package/dist/slider.js.map +1 -0
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -16,7 +16,17 @@ so `bg-primary-500` is the identical value on web and native.
|
|
|
16
16
|
| `Modal` | RN `Modal` | dimmed backdrop, tap-to-close |
|
|
17
17
|
| `Badge` / `Card` (+ Header/Body/Footer) / `Spinner` | `View`/`Text`/`ActivityIndicator` | display |
|
|
18
18
|
|
|
19
|
-
Phase 2 (community-lib wrappers): `Select`, `
|
|
19
|
+
Phase 2 (community-lib wrappers): `Select`, `RadioGroup`, `Toast` from the main
|
|
20
|
+
entry, plus two components on **subpaths** because their libraries are optional
|
|
21
|
+
peers — install the peer only if you use the component:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Slider } from "@ymjin/ui-native/slider"; // needs @react-native-community/slider
|
|
25
|
+
import { DatePicker } from "@ymjin/ui-native/date-picker"; // needs @react-native-community/datetimepicker
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The build emits `nativewind/jsx-runtime`, so kit components' `className`
|
|
29
|
+
works with no Metro `resolveRequest` override.
|
|
20
30
|
|
|
21
31
|
## Setup
|
|
22
32
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/cx.ts"],"sourcesContent":["/** Join truthy class-name parts with spaces (NativeWind className composition). */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(\" \");\n}\n"],"mappings":";AACO,SAAS,MAAM,OAAyD;AAC7E,SAAO,MAAM,OAAO,OAAO,EAAE,KAAK,GAAG;AACvC;","names":[]}
|
|
@@ -0,0 +1,103 @@
|
|
|
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/date-picker.ts
|
|
31
|
+
var date_picker_exports = {};
|
|
32
|
+
__export(date_picker_exports, {
|
|
33
|
+
DatePicker: () => DatePicker
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(date_picker_exports);
|
|
36
|
+
|
|
37
|
+
// src/components/DatePicker.tsx
|
|
38
|
+
var import_react = require("react");
|
|
39
|
+
var import_datetimepicker = __toESM(require("@react-native-community/datetimepicker"), 1);
|
|
40
|
+
var import_react_native = require("react-native");
|
|
41
|
+
|
|
42
|
+
// src/utils/cx.ts
|
|
43
|
+
function cx(...parts) {
|
|
44
|
+
return parts.filter(Boolean).join(" ");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/components/DatePicker.tsx
|
|
48
|
+
var import_jsx_runtime = require("nativewind/jsx-runtime");
|
|
49
|
+
function DatePicker({
|
|
50
|
+
label,
|
|
51
|
+
value,
|
|
52
|
+
onChange,
|
|
53
|
+
mode = "date",
|
|
54
|
+
placeholder = "\uB0A0\uC9DC \uC120\uD0DD",
|
|
55
|
+
minimumDate,
|
|
56
|
+
maximumDate,
|
|
57
|
+
disabled,
|
|
58
|
+
className
|
|
59
|
+
}) {
|
|
60
|
+
const [show, setShow] = (0, import_react.useState)(false);
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native.View, { className: cx("gap-1.5", className), children: [
|
|
62
|
+
label != null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { className: "text-sm font-medium text-neutral-800", children: label }),
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
+
import_react_native.Pressable,
|
|
65
|
+
{
|
|
66
|
+
accessibilityRole: "button",
|
|
67
|
+
onPress: () => setShow(true),
|
|
68
|
+
disabled,
|
|
69
|
+
className: cx(
|
|
70
|
+
"rounded-md border border-neutral-300 bg-white px-3 py-2",
|
|
71
|
+
disabled && "opacity-50"
|
|
72
|
+
),
|
|
73
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { className: cx("text-base", value ? "text-neutral-900" : "text-neutral-400"), children: value ? formatDate(value, mode) : placeholder })
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
show && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
77
|
+
import_datetimepicker.default,
|
|
78
|
+
{
|
|
79
|
+
value: value ?? /* @__PURE__ */ new Date(),
|
|
80
|
+
mode,
|
|
81
|
+
minimumDate,
|
|
82
|
+
maximumDate,
|
|
83
|
+
onChange: (event, date) => {
|
|
84
|
+
setShow(import_react_native.Platform.OS === "ios");
|
|
85
|
+
if (event.type !== "dismissed" && date) onChange?.(date);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] });
|
|
90
|
+
}
|
|
91
|
+
function formatDate(d, mode) {
|
|
92
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
93
|
+
const date = `${d.getFullYear()}.${pad(d.getMonth() + 1)}.${pad(d.getDate())}`;
|
|
94
|
+
const time = `${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
95
|
+
if (mode === "time") return time;
|
|
96
|
+
if (mode === "datetime") return `${date} ${time}`;
|
|
97
|
+
return date;
|
|
98
|
+
}
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
DatePicker
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=date-picker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/date-picker.ts","../src/components/DatePicker.tsx","../src/utils/cx.ts"],"sourcesContent":["/**\n * `@ymjin/ui-native/date-picker` — kept out of the main entry so apps that\n * don't install the optional peer `@react-native-community/datetimepicker`\n * still bundle.\n */\nexport { DatePicker } from \"./components/DatePicker.js\";\nexport type { DatePickerProps } from \"./components/DatePicker.js\";\n","import { useState } from \"react\";\nimport DateTimePicker from \"@react-native-community/datetimepicker\";\nimport { Platform, Pressable, Text, View } from \"react-native\";\nimport { cx } from \"../utils/cx.js\";\n\nexport interface DatePickerProps {\n label?: string;\n value?: Date;\n onChange?: (date: Date) => void;\n /** `\"date\"` (default), `\"time\"`, or `\"datetime\"`. */\n mode?: \"date\" | \"time\" | \"datetime\";\n placeholder?: string;\n minimumDate?: Date;\n maximumDate?: Date;\n disabled?: boolean;\n className?: string;\n}\n\n/**\n * A date/time picker wrapping `@react-native-community/datetimepicker` — the\n * platform-native wheel (iOS) / dialog (Android), which is the preferred mobile\n * date UX. Requires that package as a peer dependency.\n */\nexport function DatePicker({\n label,\n value,\n onChange,\n mode = \"date\",\n placeholder = \"날짜 선택\",\n minimumDate,\n maximumDate,\n disabled,\n className,\n}: DatePickerProps) {\n const [show, setShow] = useState(false);\n\n return (\n <View className={cx(\"gap-1.5\", className)}>\n {label != null && <Text className=\"text-sm font-medium text-neutral-800\">{label}</Text>}\n <Pressable\n accessibilityRole=\"button\"\n onPress={() => setShow(true)}\n disabled={disabled}\n className={cx(\n \"rounded-md border border-neutral-300 bg-white px-3 py-2\",\n disabled && \"opacity-50\",\n )}\n >\n <Text className={cx(\"text-base\", value ? \"text-neutral-900\" : \"text-neutral-400\")}>\n {value ? formatDate(value, mode) : placeholder}\n </Text>\n </Pressable>\n {show && (\n <DateTimePicker\n value={value ?? new Date()}\n mode={mode}\n minimumDate={minimumDate}\n maximumDate={maximumDate}\n onChange={(event, date) => {\n // Android dismisses on selection; iOS stays inline.\n setShow(Platform.OS === \"ios\");\n if (event.type !== \"dismissed\" && date) onChange?.(date);\n }}\n />\n )}\n </View>\n );\n}\n\nfunction formatDate(d: Date, mode: \"date\" | \"time\" | \"datetime\"): string {\n const pad = (n: number) => String(n).padStart(2, \"0\");\n const date = `${d.getFullYear()}.${pad(d.getMonth() + 1)}.${pad(d.getDate())}`;\n const time = `${pad(d.getHours())}:${pad(d.getMinutes())}`;\n if (mode === \"time\") return time;\n if (mode === \"datetime\") return `${date} ${time}`;\n return date;\n}\n","/** Join truthy class-name parts with spaces (NativeWind className composition). */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(\" \");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyB;AACzB,4BAA2B;AAC3B,0BAAgD;;;ACDzC,SAAS,MAAM,OAAyD;AAC7E,SAAO,MAAM,OAAO,OAAO,EAAE,KAAK,GAAG;AACvC;;;ADkCI;AAdG,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAoB;AAClB,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AAEtC,SACE,6CAAC,4BAAK,WAAW,GAAG,WAAW,SAAS,GACrC;AAAA,aAAS,QAAQ,4CAAC,4BAAK,WAAU,wCAAwC,iBAAM;AAAA,IAChF;AAAA,MAAC;AAAA;AAAA,QACC,mBAAkB;AAAA,QAClB,SAAS,MAAM,QAAQ,IAAI;AAAA,QAC3B;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA,YAAY;AAAA,QACd;AAAA,QAEA,sDAAC,4BAAK,WAAW,GAAG,aAAa,QAAQ,qBAAqB,kBAAkB,GAC7E,kBAAQ,WAAW,OAAO,IAAI,IAAI,aACrC;AAAA;AAAA,IACF;AAAA,IACC,QACC;AAAA,MAAC,sBAAAA;AAAA,MAAA;AAAA,QACC,OAAO,SAAS,oBAAI,KAAK;AAAA,QACzB;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU,CAAC,OAAO,SAAS;AAEzB,kBAAQ,6BAAS,OAAO,KAAK;AAC7B,cAAI,MAAM,SAAS,eAAe,KAAM,YAAW,IAAI;AAAA,QACzD;AAAA;AAAA,IACF;AAAA,KAEJ;AAEJ;AAEA,SAAS,WAAW,GAAS,MAA4C;AACvE,QAAM,MAAM,CAAC,MAAc,OAAO,CAAC,EAAE,SAAS,GAAG,GAAG;AACpD,QAAM,OAAO,GAAG,EAAE,YAAY,CAAC,IAAI,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC5E,QAAM,OAAO,GAAG,IAAI,EAAE,SAAS,CAAC,CAAC,IAAI,IAAI,EAAE,WAAW,CAAC,CAAC;AACxD,MAAI,SAAS,OAAQ,QAAO;AAC5B,MAAI,SAAS,WAAY,QAAO,GAAG,IAAI,IAAI,IAAI;AAC/C,SAAO;AACT;","names":["DateTimePicker"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
interface DatePickerProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
value?: Date;
|
|
6
|
+
onChange?: (date: Date) => void;
|
|
7
|
+
/** `"date"` (default), `"time"`, or `"datetime"`. */
|
|
8
|
+
mode?: "date" | "time" | "datetime";
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
minimumDate?: Date;
|
|
11
|
+
maximumDate?: Date;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A date/time picker wrapping `@react-native-community/datetimepicker` — the
|
|
17
|
+
* platform-native wheel (iOS) / dialog (Android), which is the preferred mobile
|
|
18
|
+
* date UX. Requires that package as a peer dependency.
|
|
19
|
+
*/
|
|
20
|
+
declare function DatePicker({ label, value, onChange, mode, placeholder, minimumDate, maximumDate, disabled, className, }: DatePickerProps): react.JSX.Element;
|
|
21
|
+
|
|
22
|
+
export { DatePicker, type DatePickerProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
interface DatePickerProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
value?: Date;
|
|
6
|
+
onChange?: (date: Date) => void;
|
|
7
|
+
/** `"date"` (default), `"time"`, or `"datetime"`. */
|
|
8
|
+
mode?: "date" | "time" | "datetime";
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
minimumDate?: Date;
|
|
11
|
+
maximumDate?: Date;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A date/time picker wrapping `@react-native-community/datetimepicker` — the
|
|
17
|
+
* platform-native wheel (iOS) / dialog (Android), which is the preferred mobile
|
|
18
|
+
* date UX. Requires that package as a peer dependency.
|
|
19
|
+
*/
|
|
20
|
+
declare function DatePicker({ label, value, onChange, mode, placeholder, minimumDate, maximumDate, disabled, className, }: DatePickerProps): react.JSX.Element;
|
|
21
|
+
|
|
22
|
+
export { DatePicker, type DatePickerProps };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cx
|
|
3
|
+
} from "./chunk-LHWLG5RR.js";
|
|
4
|
+
|
|
5
|
+
// src/components/DatePicker.tsx
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import DateTimePicker from "@react-native-community/datetimepicker";
|
|
8
|
+
import { Platform, Pressable, Text, View } from "react-native";
|
|
9
|
+
import { jsx, jsxs } from "nativewind/jsx-runtime";
|
|
10
|
+
function DatePicker({
|
|
11
|
+
label,
|
|
12
|
+
value,
|
|
13
|
+
onChange,
|
|
14
|
+
mode = "date",
|
|
15
|
+
placeholder = "\uB0A0\uC9DC \uC120\uD0DD",
|
|
16
|
+
minimumDate,
|
|
17
|
+
maximumDate,
|
|
18
|
+
disabled,
|
|
19
|
+
className
|
|
20
|
+
}) {
|
|
21
|
+
const [show, setShow] = useState(false);
|
|
22
|
+
return /* @__PURE__ */ jsxs(View, { className: cx("gap-1.5", className), children: [
|
|
23
|
+
label != null && /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-neutral-800", children: label }),
|
|
24
|
+
/* @__PURE__ */ jsx(
|
|
25
|
+
Pressable,
|
|
26
|
+
{
|
|
27
|
+
accessibilityRole: "button",
|
|
28
|
+
onPress: () => setShow(true),
|
|
29
|
+
disabled,
|
|
30
|
+
className: cx(
|
|
31
|
+
"rounded-md border border-neutral-300 bg-white px-3 py-2",
|
|
32
|
+
disabled && "opacity-50"
|
|
33
|
+
),
|
|
34
|
+
children: /* @__PURE__ */ jsx(Text, { className: cx("text-base", value ? "text-neutral-900" : "text-neutral-400"), children: value ? formatDate(value, mode) : placeholder })
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
show && /* @__PURE__ */ jsx(
|
|
38
|
+
DateTimePicker,
|
|
39
|
+
{
|
|
40
|
+
value: value ?? /* @__PURE__ */ new Date(),
|
|
41
|
+
mode,
|
|
42
|
+
minimumDate,
|
|
43
|
+
maximumDate,
|
|
44
|
+
onChange: (event, date) => {
|
|
45
|
+
setShow(Platform.OS === "ios");
|
|
46
|
+
if (event.type !== "dismissed" && date) onChange?.(date);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
] });
|
|
51
|
+
}
|
|
52
|
+
function formatDate(d, mode) {
|
|
53
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
54
|
+
const date = `${d.getFullYear()}.${pad(d.getMonth() + 1)}.${pad(d.getDate())}`;
|
|
55
|
+
const time = `${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
56
|
+
if (mode === "time") return time;
|
|
57
|
+
if (mode === "datetime") return `${date} ${time}`;
|
|
58
|
+
return date;
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
DatePicker
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=date-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/DatePicker.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport DateTimePicker from \"@react-native-community/datetimepicker\";\nimport { Platform, Pressable, Text, View } from \"react-native\";\nimport { cx } from \"../utils/cx.js\";\n\nexport interface DatePickerProps {\n label?: string;\n value?: Date;\n onChange?: (date: Date) => void;\n /** `\"date\"` (default), `\"time\"`, or `\"datetime\"`. */\n mode?: \"date\" | \"time\" | \"datetime\";\n placeholder?: string;\n minimumDate?: Date;\n maximumDate?: Date;\n disabled?: boolean;\n className?: string;\n}\n\n/**\n * A date/time picker wrapping `@react-native-community/datetimepicker` — the\n * platform-native wheel (iOS) / dialog (Android), which is the preferred mobile\n * date UX. Requires that package as a peer dependency.\n */\nexport function DatePicker({\n label,\n value,\n onChange,\n mode = \"date\",\n placeholder = \"날짜 선택\",\n minimumDate,\n maximumDate,\n disabled,\n className,\n}: DatePickerProps) {\n const [show, setShow] = useState(false);\n\n return (\n <View className={cx(\"gap-1.5\", className)}>\n {label != null && <Text className=\"text-sm font-medium text-neutral-800\">{label}</Text>}\n <Pressable\n accessibilityRole=\"button\"\n onPress={() => setShow(true)}\n disabled={disabled}\n className={cx(\n \"rounded-md border border-neutral-300 bg-white px-3 py-2\",\n disabled && \"opacity-50\",\n )}\n >\n <Text className={cx(\"text-base\", value ? \"text-neutral-900\" : \"text-neutral-400\")}>\n {value ? formatDate(value, mode) : placeholder}\n </Text>\n </Pressable>\n {show && (\n <DateTimePicker\n value={value ?? new Date()}\n mode={mode}\n minimumDate={minimumDate}\n maximumDate={maximumDate}\n onChange={(event, date) => {\n // Android dismisses on selection; iOS stays inline.\n setShow(Platform.OS === \"ios\");\n if (event.type !== \"dismissed\" && date) onChange?.(date);\n }}\n />\n )}\n </View>\n );\n}\n\nfunction formatDate(d: Date, mode: \"date\" | \"time\" | \"datetime\"): string {\n const pad = (n: number) => String(n).padStart(2, \"0\");\n const date = `${d.getFullYear()}.${pad(d.getMonth() + 1)}.${pad(d.getDate())}`;\n const time = `${pad(d.getHours())}:${pad(d.getMinutes())}`;\n if (mode === \"time\") return time;\n if (mode === \"datetime\") return `${date} ${time}`;\n return date;\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AACzB,OAAO,oBAAoB;AAC3B,SAAS,UAAU,WAAW,MAAM,YAAY;AAmC5C,SACoB,KADpB;AAdG,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAoB;AAClB,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AAEtC,SACE,qBAAC,QAAK,WAAW,GAAG,WAAW,SAAS,GACrC;AAAA,aAAS,QAAQ,oBAAC,QAAK,WAAU,wCAAwC,iBAAM;AAAA,IAChF;AAAA,MAAC;AAAA;AAAA,QACC,mBAAkB;AAAA,QAClB,SAAS,MAAM,QAAQ,IAAI;AAAA,QAC3B;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA,YAAY;AAAA,QACd;AAAA,QAEA,8BAAC,QAAK,WAAW,GAAG,aAAa,QAAQ,qBAAqB,kBAAkB,GAC7E,kBAAQ,WAAW,OAAO,IAAI,IAAI,aACrC;AAAA;AAAA,IACF;AAAA,IACC,QACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,SAAS,oBAAI,KAAK;AAAA,QACzB;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU,CAAC,OAAO,SAAS;AAEzB,kBAAQ,SAAS,OAAO,KAAK;AAC7B,cAAI,MAAM,SAAS,eAAe,KAAM,YAAW,IAAI;AAAA,QACzD;AAAA;AAAA,IACF;AAAA,KAEJ;AAEJ;AAEA,SAAS,WAAW,GAAS,MAA4C;AACvE,QAAM,MAAM,CAAC,MAAc,OAAO,CAAC,EAAE,SAAS,GAAG,GAAG;AACpD,QAAM,OAAO,GAAG,EAAE,YAAY,CAAC,IAAI,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC5E,QAAM,OAAO,GAAG,IAAI,EAAE,SAAS,CAAC,CAAC,IAAI,IAAI,EAAE,WAAW,CAAC,CAAC;AACxD,MAAI,SAAS,OAAQ,QAAO;AAC5B,MAAI,SAAS,WAAY,QAAO,GAAG,IAAI,IAAI,IAAI;AAC/C,SAAO;AACT;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -37,12 +27,10 @@ __export(index_exports, {
|
|
|
37
27
|
CardFooter: () => CardFooter,
|
|
38
28
|
CardHeader: () => CardHeader,
|
|
39
29
|
Checkbox: () => Checkbox,
|
|
40
|
-
DatePicker: () => DatePicker,
|
|
41
30
|
Modal: () => Modal,
|
|
42
31
|
Radio: () => Radio,
|
|
43
32
|
RadioGroup: () => RadioGroup,
|
|
44
33
|
Select: () => Select,
|
|
45
|
-
Slider: () => Slider,
|
|
46
34
|
Spinner: () => Spinner,
|
|
47
35
|
Switch: () => Switch,
|
|
48
36
|
TextField: () => TextField,
|
|
@@ -61,7 +49,7 @@ function cx(...parts) {
|
|
|
61
49
|
}
|
|
62
50
|
|
|
63
51
|
// src/components/Button.tsx
|
|
64
|
-
var import_jsx_runtime = require("
|
|
52
|
+
var import_jsx_runtime = require("nativewind/jsx-runtime");
|
|
65
53
|
var VARIANT = {
|
|
66
54
|
primary: { container: "bg-primary-500 active:bg-primary-700", text: "text-white" },
|
|
67
55
|
secondary: { container: "bg-neutral-100 active:bg-neutral-300", text: "text-neutral-900" },
|
|
@@ -106,7 +94,7 @@ function Button({
|
|
|
106
94
|
// src/components/TextField.tsx
|
|
107
95
|
var import_react_native2 = require("react-native");
|
|
108
96
|
var import_tokens = require("@ymjin/tokens");
|
|
109
|
-
var import_jsx_runtime2 = require("
|
|
97
|
+
var import_jsx_runtime2 = require("nativewind/jsx-runtime");
|
|
110
98
|
function TextField({
|
|
111
99
|
label,
|
|
112
100
|
placeholder,
|
|
@@ -148,7 +136,7 @@ function TextField({
|
|
|
148
136
|
// src/components/Switch.tsx
|
|
149
137
|
var import_react_native3 = require("react-native");
|
|
150
138
|
var import_tokens2 = require("@ymjin/tokens");
|
|
151
|
-
var import_jsx_runtime3 = require("
|
|
139
|
+
var import_jsx_runtime3 = require("nativewind/jsx-runtime");
|
|
152
140
|
function Switch({ value, onValueChange, label, disabled, className }) {
|
|
153
141
|
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
142
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -167,7 +155,7 @@ function Switch({ value, onValueChange, label, disabled, className }) {
|
|
|
167
155
|
|
|
168
156
|
// src/components/Checkbox.tsx
|
|
169
157
|
var import_react_native4 = require("react-native");
|
|
170
|
-
var import_jsx_runtime4 = require("
|
|
158
|
+
var import_jsx_runtime4 = require("nativewind/jsx-runtime");
|
|
171
159
|
function Checkbox({ value, onValueChange, label, disabled, className }) {
|
|
172
160
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
173
161
|
import_react_native4.Pressable,
|
|
@@ -196,24 +184,34 @@ function Checkbox({ value, onValueChange, label, disabled, className }) {
|
|
|
196
184
|
|
|
197
185
|
// src/components/Modal.tsx
|
|
198
186
|
var import_react_native5 = require("react-native");
|
|
199
|
-
var import_jsx_runtime5 = require("
|
|
187
|
+
var import_jsx_runtime5 = require("nativewind/jsx-runtime");
|
|
200
188
|
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)(
|
|
189
|
+
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)(
|
|
202
190
|
import_react_native5.Pressable,
|
|
203
191
|
{
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
192
|
+
accessible: false,
|
|
193
|
+
onPress: onClose,
|
|
194
|
+
className: "flex-1 items-center justify-center bg-black/40 p-4",
|
|
195
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
196
|
+
import_react_native5.Pressable,
|
|
197
|
+
{
|
|
198
|
+
accessible: false,
|
|
199
|
+
accessibilityViewIsModal: true,
|
|
200
|
+
onPress: () => void 0,
|
|
201
|
+
className: cx("w-full max-w-md rounded-xl bg-white p-6", className),
|
|
202
|
+
children: [
|
|
203
|
+
title != null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.Text, { accessibilityRole: "header", className: "mb-3 text-xl font-semibold text-neutral-900", children: title }),
|
|
204
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.View, { children })
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
)
|
|
210
208
|
}
|
|
211
|
-
) })
|
|
209
|
+
) });
|
|
212
210
|
}
|
|
213
211
|
|
|
214
212
|
// src/components/Badge.tsx
|
|
215
213
|
var import_react_native6 = require("react-native");
|
|
216
|
-
var import_jsx_runtime6 = require("
|
|
214
|
+
var import_jsx_runtime6 = require("nativewind/jsx-runtime");
|
|
217
215
|
var CONTAINER = {
|
|
218
216
|
neutral: "bg-neutral-100",
|
|
219
217
|
primary: "bg-primary-100",
|
|
@@ -234,7 +232,7 @@ function Badge({ variant = "neutral", children, className }) {
|
|
|
234
232
|
|
|
235
233
|
// src/components/Card.tsx
|
|
236
234
|
var import_react_native7 = require("react-native");
|
|
237
|
-
var import_jsx_runtime7 = require("
|
|
235
|
+
var import_jsx_runtime7 = require("nativewind/jsx-runtime");
|
|
238
236
|
function Card({ children, className }) {
|
|
239
237
|
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
238
|
}
|
|
@@ -251,7 +249,7 @@ function CardFooter({ children, className }) {
|
|
|
251
249
|
// src/components/Spinner.tsx
|
|
252
250
|
var import_react_native8 = require("react-native");
|
|
253
251
|
var import_tokens3 = require("@ymjin/tokens");
|
|
254
|
-
var import_jsx_runtime8 = require("
|
|
252
|
+
var import_jsx_runtime8 = require("nativewind/jsx-runtime");
|
|
255
253
|
function Spinner({ size = "md", color: tint, className }) {
|
|
256
254
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
257
255
|
import_react_native8.ActivityIndicator,
|
|
@@ -266,7 +264,7 @@ function Spinner({ size = "md", color: tint, className }) {
|
|
|
266
264
|
// src/components/RadioGroup.tsx
|
|
267
265
|
var import_react = require("react");
|
|
268
266
|
var import_react_native9 = require("react-native");
|
|
269
|
-
var import_jsx_runtime9 = require("
|
|
267
|
+
var import_jsx_runtime9 = require("nativewind/jsx-runtime");
|
|
270
268
|
var RadioContext = (0, import_react.createContext)({});
|
|
271
269
|
function RadioGroup({
|
|
272
270
|
value,
|
|
@@ -313,7 +311,7 @@ function Radio({ value, label, disabled, className }) {
|
|
|
313
311
|
// src/components/Select.tsx
|
|
314
312
|
var import_react2 = require("react");
|
|
315
313
|
var import_react_native10 = require("react-native");
|
|
316
|
-
var import_jsx_runtime10 = require("
|
|
314
|
+
var import_jsx_runtime10 = require("nativewind/jsx-runtime");
|
|
317
315
|
function Select({
|
|
318
316
|
label,
|
|
319
317
|
placeholder = "\uC120\uD0DD\uD558\uC138\uC694",
|
|
@@ -370,105 +368,11 @@ function Select({
|
|
|
370
368
|
] });
|
|
371
369
|
}
|
|
372
370
|
|
|
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
371
|
// src/components/Toast.tsx
|
|
468
|
-
var
|
|
469
|
-
var
|
|
470
|
-
var
|
|
471
|
-
var ToastContext = (0,
|
|
372
|
+
var import_react3 = require("react");
|
|
373
|
+
var import_react_native11 = require("react-native");
|
|
374
|
+
var import_jsx_runtime11 = require("nativewind/jsx-runtime");
|
|
375
|
+
var ToastContext = (0, import_react3.createContext)(null);
|
|
472
376
|
var BORDER = {
|
|
473
377
|
info: "border-l-primary-500",
|
|
474
378
|
success: "border-l-success-500",
|
|
@@ -476,12 +380,12 @@ var BORDER = {
|
|
|
476
380
|
danger: "border-l-danger-500"
|
|
477
381
|
};
|
|
478
382
|
function ToastProvider({ children, duration = 4e3 }) {
|
|
479
|
-
const [toasts, setToasts] = (0,
|
|
480
|
-
const seq = (0,
|
|
481
|
-
const dismiss = (0,
|
|
383
|
+
const [toasts, setToasts] = (0, import_react3.useState)([]);
|
|
384
|
+
const seq = (0, import_react3.useRef)(0);
|
|
385
|
+
const dismiss = (0, import_react3.useCallback)((id) => {
|
|
482
386
|
setToasts((list) => list.filter((t) => t.id !== id));
|
|
483
387
|
}, []);
|
|
484
|
-
const toast = (0,
|
|
388
|
+
const toast = (0, import_react3.useCallback)(
|
|
485
389
|
(options) => {
|
|
486
390
|
const opts = typeof options === "string" ? { description: options } : options;
|
|
487
391
|
seq.current += 1;
|
|
@@ -496,10 +400,10 @@ function ToastProvider({ children, duration = 4e3 }) {
|
|
|
496
400
|
},
|
|
497
401
|
[duration, dismiss]
|
|
498
402
|
);
|
|
499
|
-
return /* @__PURE__ */ (0,
|
|
403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(ToastContext.Provider, { value: { toast, dismiss }, children: [
|
|
500
404
|
children,
|
|
501
|
-
/* @__PURE__ */ (0,
|
|
502
|
-
|
|
405
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { pointerEvents: "box-none", className: "absolute inset-x-0 bottom-0 gap-2 p-4", children: toasts.map((t) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
406
|
+
import_react_native11.View,
|
|
503
407
|
{
|
|
504
408
|
accessibilityRole: "alert",
|
|
505
409
|
className: cx(
|
|
@@ -507,8 +411,8 @@ function ToastProvider({ children, duration = 4e3 }) {
|
|
|
507
411
|
BORDER[t.variant]
|
|
508
412
|
),
|
|
509
413
|
children: [
|
|
510
|
-
t.title != null && /* @__PURE__ */ (0,
|
|
511
|
-
t.description != null && /* @__PURE__ */ (0,
|
|
414
|
+
t.title != null && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.Text, { className: "text-sm font-semibold text-neutral-900", children: t.title }),
|
|
415
|
+
t.description != null && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.Text, { className: "text-sm text-neutral-600", children: t.description })
|
|
512
416
|
]
|
|
513
417
|
},
|
|
514
418
|
t.id
|
|
@@ -516,7 +420,7 @@ function ToastProvider({ children, duration = 4e3 }) {
|
|
|
516
420
|
] });
|
|
517
421
|
}
|
|
518
422
|
function useToast() {
|
|
519
|
-
const ctx = (0,
|
|
423
|
+
const ctx = (0, import_react3.useContext)(ToastContext);
|
|
520
424
|
if (!ctx) {
|
|
521
425
|
throw new Error("[@ymjin/ui-native] useToast must be used inside a <ToastProvider>.");
|
|
522
426
|
}
|
|
@@ -531,12 +435,10 @@ function useToast() {
|
|
|
531
435
|
CardFooter,
|
|
532
436
|
CardHeader,
|
|
533
437
|
Checkbox,
|
|
534
|
-
DatePicker,
|
|
535
438
|
Modal,
|
|
536
439
|
Radio,
|
|
537
440
|
RadioGroup,
|
|
538
441
|
Select,
|
|
539
|
-
Slider,
|
|
540
442
|
Spinner,
|
|
541
443
|
Switch,
|
|
542
444
|
TextField,
|