@ecohouse/ui 0.1.25 → 0.1.26
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.cjs +142 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +142 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DatePicker/DatePicker.stories.tsx +34 -0
- package/src/components/DatePicker/DatePicker.tsx +165 -11
- package/src/components/DatePicker/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/theme/colors.ts +1 -0
- package/src/theme/typography.ts +21 -0
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ var colors = {
|
|
|
37
37
|
black: "#000000",
|
|
38
38
|
white: "#ffffff",
|
|
39
39
|
whiteAlpha86: "#FFFFFFDB",
|
|
40
|
+
whiteAlpha60: "#FFFFFF99",
|
|
40
41
|
whiteAlpha40: "#FFFFFF66",
|
|
41
42
|
whiteAlpha20: "#FFFFFF33",
|
|
42
43
|
whiteAlpha6: "#FFFFFF0F",
|
|
@@ -236,6 +237,27 @@ var datePickerTypography = {
|
|
|
236
237
|
lineHeight: 12,
|
|
237
238
|
letterSpacing: 0.36
|
|
238
239
|
},
|
|
240
|
+
rangeLabel: {
|
|
241
|
+
fontFamily: fonts.sans,
|
|
242
|
+
fontSize: 13,
|
|
243
|
+
fontWeight: "500",
|
|
244
|
+
lineHeight: 13,
|
|
245
|
+
letterSpacing: 0
|
|
246
|
+
},
|
|
247
|
+
rangeDate: {
|
|
248
|
+
fontFamily: fonts.sans,
|
|
249
|
+
fontSize: 16,
|
|
250
|
+
fontWeight: "500",
|
|
251
|
+
lineHeight: 16,
|
|
252
|
+
letterSpacing: 0
|
|
253
|
+
},
|
|
254
|
+
rangeTime: {
|
|
255
|
+
fontFamily: fonts.sans,
|
|
256
|
+
fontSize: 14,
|
|
257
|
+
fontWeight: "400",
|
|
258
|
+
lineHeight: 14,
|
|
259
|
+
letterSpacing: 0
|
|
260
|
+
},
|
|
239
261
|
/** Calendar month/year heading — Bold, centered, White. */
|
|
240
262
|
monthHeading: {
|
|
241
263
|
fontFamily: fonts.sans,
|
|
@@ -3034,6 +3056,7 @@ var DEFAULT_MONTH_NAMES = [
|
|
|
3034
3056
|
var DEFAULT_WEEKDAY_LABELS = ["\u0535\u0550", "\u0535\u0554", "\u0549\u0550", "\u0540\u0546", "\u0548\u0552\u0550", "\u0547\u0532", "\u053F\u0550"];
|
|
3035
3057
|
var EMPTY_RANGE = { start: null, end: null };
|
|
3036
3058
|
var DEFAULT_WIDTH = 380;
|
|
3059
|
+
var RANGE_TRIGGER_WIDTH = 382;
|
|
3037
3060
|
var TRIGGER_HEIGHT = 44;
|
|
3038
3061
|
var TRIGGER_RADIUS = 60;
|
|
3039
3062
|
var MENU_RADIUS2 = 20;
|
|
@@ -3041,10 +3064,33 @@ var ICON_SIZE7 = 20;
|
|
|
3041
3064
|
var NAV_ICON_SIZE = 20;
|
|
3042
3065
|
var DAY_CELL_HEIGHT = 44;
|
|
3043
3066
|
var DAY_CIRCLE_SIZE = 44;
|
|
3067
|
+
function RangeTriggerField({
|
|
3068
|
+
label,
|
|
3069
|
+
value,
|
|
3070
|
+
time
|
|
3071
|
+
}) {
|
|
3072
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles12.rangeField, children: [
|
|
3073
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: styles12.rangeLabel, children: label }),
|
|
3074
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles12.rangeValueRow, children: [
|
|
3075
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: styles12.rangeDate, children: value }),
|
|
3076
|
+
time ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles12.rangeTimeWrap, children: [
|
|
3077
|
+
/* @__PURE__ */ jsxRuntime.jsx(ClockFilledIcon, { color: colors.lightGrey, size: 16 }),
|
|
3078
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles12.rangeTime, children: time })
|
|
3079
|
+
] }) : null
|
|
3080
|
+
] })
|
|
3081
|
+
] });
|
|
3082
|
+
}
|
|
3044
3083
|
var DatePicker = react.forwardRef(
|
|
3045
3084
|
function DatePicker2(props, forwardedRef) {
|
|
3046
3085
|
const {
|
|
3047
3086
|
placeholder = "Select date",
|
|
3087
|
+
variant = "default",
|
|
3088
|
+
startLabel = "Start",
|
|
3089
|
+
endLabel = "End",
|
|
3090
|
+
startTime,
|
|
3091
|
+
endTime,
|
|
3092
|
+
startPlaceholder = placeholder,
|
|
3093
|
+
endPlaceholder = placeholder,
|
|
3048
3094
|
open: openProp,
|
|
3049
3095
|
defaultOpen = false,
|
|
3050
3096
|
onOpenChange,
|
|
@@ -3182,18 +3228,28 @@ var DatePicker = react.forwardRef(
|
|
|
3182
3228
|
const today = react.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
|
|
3183
3229
|
const hasValue = isRange ? rangeValue.start != null : singleValue != null;
|
|
3184
3230
|
const triggerLabel = isRange ? rangeValue.start && rangeValue.end ? `${formatValue(rangeValue.start)} - ${formatValue(rangeValue.end)}` : rangeValue.start ? `${formatValue(rangeValue.start)} - ...` : placeholder : singleValue ? formatValue(singleValue) : placeholder;
|
|
3185
|
-
const
|
|
3231
|
+
const usesRangeTrigger = isRange && variant !== "default";
|
|
3232
|
+
const usesVerticalRangeTrigger = usesRangeTrigger && variant === "range-vertical";
|
|
3233
|
+
const triggerBorderColor = usesRangeTrigger ? isOpen ? colors.primary : colors.grey500 : isOpen ? colors.primaryMuted : colors.grey700;
|
|
3186
3234
|
const triggerTextColor = hasValue ? colors.white : colors.grey100;
|
|
3235
|
+
const startValue = rangeValue.start ? formatValue(rangeValue.start) : startPlaceholder;
|
|
3236
|
+
const endValue = rangeValue.end ? formatValue(rangeValue.end) : endPlaceholder;
|
|
3187
3237
|
const resolvedAccessibilityLabel = accessibilityLabel ?? placeholder;
|
|
3188
3238
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3189
3239
|
reactNative.View,
|
|
3190
3240
|
{
|
|
3191
3241
|
...rest,
|
|
3192
3242
|
ref: setRootRef,
|
|
3193
|
-
style: [
|
|
3243
|
+
style: [
|
|
3244
|
+
styles12.root,
|
|
3245
|
+
usesRangeTrigger && styles12.rangeRoot,
|
|
3246
|
+
isOpen && styles12.rootOpen,
|
|
3247
|
+
disabled && styles12.disabled,
|
|
3248
|
+
style
|
|
3249
|
+
],
|
|
3194
3250
|
accessibilityState: { disabled, expanded: isOpen },
|
|
3195
3251
|
children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles12.triggerWrap, isOpen && styles12.triggerWrapOpen], children: [
|
|
3196
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3252
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3197
3253
|
reactNative.Pressable,
|
|
3198
3254
|
{
|
|
3199
3255
|
ref: triggerRef,
|
|
@@ -3204,15 +3260,29 @@ var DatePicker = react.forwardRef(
|
|
|
3204
3260
|
accessibilityState: { disabled, expanded: isOpen },
|
|
3205
3261
|
style: [
|
|
3206
3262
|
styles12.trigger,
|
|
3207
|
-
|
|
3263
|
+
usesRangeTrigger && styles12.rangeTrigger,
|
|
3264
|
+
usesRangeTrigger && (usesVerticalRangeTrigger ? styles12.rangeTriggerVertical : styles12.rangeTriggerHorizontal),
|
|
3265
|
+
{
|
|
3266
|
+
borderColor: triggerBorderColor,
|
|
3267
|
+
backgroundColor: usesRangeTrigger ? colors.grey800 : colors.grey700
|
|
3268
|
+
}
|
|
3208
3269
|
],
|
|
3209
|
-
children: [
|
|
3270
|
+
children: usesRangeTrigger ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3271
|
+
/* @__PURE__ */ jsxRuntime.jsx(RangeTriggerField, { label: startLabel, time: startTime, value: startValue }),
|
|
3272
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3273
|
+
reactNative.View,
|
|
3274
|
+
{
|
|
3275
|
+
style: usesVerticalRangeTrigger ? styles12.rangeDividerVertical : styles12.rangeDividerHorizontal
|
|
3276
|
+
}
|
|
3277
|
+
),
|
|
3278
|
+
/* @__PURE__ */ jsxRuntime.jsx(RangeTriggerField, { label: endLabel, time: endTime, value: endValue })
|
|
3279
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3210
3280
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles12.triggerText, { color: triggerTextColor }], numberOfLines: 1, children: triggerLabel }),
|
|
3211
3281
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles12.iconSlot, children: /* @__PURE__ */ jsxRuntime.jsx(CalendarOutlineIcon, { size: ICON_SIZE7, color: colors.grey100 }) })
|
|
3212
|
-
]
|
|
3282
|
+
] })
|
|
3213
3283
|
}
|
|
3214
3284
|
),
|
|
3215
|
-
isOpen ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles12.menu, calendarStyle], children: [
|
|
3285
|
+
isOpen ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles12.menu, usesRangeTrigger && styles12.rangeMenu, calendarStyle], children: [
|
|
3216
3286
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles12.calendarHeader, children: [
|
|
3217
3287
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3218
3288
|
reactNative.Pressable,
|
|
@@ -3355,6 +3425,9 @@ var styles12 = reactNative.StyleSheet.create({
|
|
|
3355
3425
|
rootOpen: {
|
|
3356
3426
|
zIndex: 30
|
|
3357
3427
|
},
|
|
3428
|
+
rangeRoot: {
|
|
3429
|
+
width: RANGE_TRIGGER_WIDTH
|
|
3430
|
+
},
|
|
3358
3431
|
disabled: {
|
|
3359
3432
|
opacity: 0.6
|
|
3360
3433
|
},
|
|
@@ -3381,6 +3454,65 @@ var styles12 = reactNative.StyleSheet.create({
|
|
|
3381
3454
|
flex: 1,
|
|
3382
3455
|
minWidth: 0
|
|
3383
3456
|
},
|
|
3457
|
+
rangeTrigger: {
|
|
3458
|
+
paddingVertical: 0,
|
|
3459
|
+
paddingHorizontal: 0,
|
|
3460
|
+
borderRadius: 15,
|
|
3461
|
+
gap: 0
|
|
3462
|
+
},
|
|
3463
|
+
rangeTriggerHorizontal: {
|
|
3464
|
+
height: 78,
|
|
3465
|
+
flexDirection: "row"
|
|
3466
|
+
},
|
|
3467
|
+
rangeTriggerVertical: {
|
|
3468
|
+
height: 156,
|
|
3469
|
+
flexDirection: "column"
|
|
3470
|
+
},
|
|
3471
|
+
rangeField: {
|
|
3472
|
+
flex: 1,
|
|
3473
|
+
alignSelf: "stretch",
|
|
3474
|
+
minWidth: 0,
|
|
3475
|
+
justifyContent: "center",
|
|
3476
|
+
gap: 8,
|
|
3477
|
+
paddingVertical: 12,
|
|
3478
|
+
paddingHorizontal: 16
|
|
3479
|
+
},
|
|
3480
|
+
rangeLabel: {
|
|
3481
|
+
...datePickerTypography.rangeLabel,
|
|
3482
|
+
color: colors.whiteAlpha60
|
|
3483
|
+
},
|
|
3484
|
+
rangeValueRow: {
|
|
3485
|
+
minWidth: 0,
|
|
3486
|
+
flexDirection: "row",
|
|
3487
|
+
alignItems: "center",
|
|
3488
|
+
justifyContent: "space-between",
|
|
3489
|
+
gap: 12
|
|
3490
|
+
},
|
|
3491
|
+
rangeDate: {
|
|
3492
|
+
...datePickerTypography.rangeDate,
|
|
3493
|
+
flexShrink: 1,
|
|
3494
|
+
color: colors.white
|
|
3495
|
+
},
|
|
3496
|
+
rangeTimeWrap: {
|
|
3497
|
+
flexShrink: 0,
|
|
3498
|
+
flexDirection: "row",
|
|
3499
|
+
alignItems: "center",
|
|
3500
|
+
gap: 3
|
|
3501
|
+
},
|
|
3502
|
+
rangeTime: {
|
|
3503
|
+
...datePickerTypography.rangeTime,
|
|
3504
|
+
color: colors.lightGrey
|
|
3505
|
+
},
|
|
3506
|
+
rangeDividerHorizontal: {
|
|
3507
|
+
width: 1,
|
|
3508
|
+
alignSelf: "stretch",
|
|
3509
|
+
backgroundColor: colors.grey500
|
|
3510
|
+
},
|
|
3511
|
+
rangeDividerVertical: {
|
|
3512
|
+
height: 1,
|
|
3513
|
+
alignSelf: "stretch",
|
|
3514
|
+
backgroundColor: colors.grey500
|
|
3515
|
+
},
|
|
3384
3516
|
iconSlot: {
|
|
3385
3517
|
width: ICON_SIZE7,
|
|
3386
3518
|
height: ICON_SIZE7,
|
|
@@ -3408,6 +3540,9 @@ var styles12 = reactNative.StyleSheet.create({
|
|
|
3408
3540
|
}
|
|
3409
3541
|
})
|
|
3410
3542
|
},
|
|
3543
|
+
rangeMenu: {
|
|
3544
|
+
width: RANGE_TRIGGER_WIDTH
|
|
3545
|
+
},
|
|
3411
3546
|
calendarHeader: {
|
|
3412
3547
|
height: 36,
|
|
3413
3548
|
flexDirection: "row",
|