@crisp-ui-kit/crisp 0.8.0 → 0.9.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/dist/cjs/components/timepicker/index.js +17 -0
- package/dist/cjs/components/timepicker/timepicker.js +54 -0
- package/dist/cjs/index.js +1 -0
- package/dist/esm/components/timepicker/index.js +1 -0
- package/dist/esm/components/timepicker/timepicker.js +51 -0
- package/dist/esm/index.js +1 -0
- package/dist/types/components/timepicker/index.d.ts +1 -0
- package/dist/types/components/timepicker/timepicker.d.ts +15 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +7 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./timepicker"), exports);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TimePicker = TimePicker;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_time_picker_1 = require("@seed-design/react-time-picker");
|
|
7
|
+
const wheelpicker_1 = require("../wheelpicker");
|
|
8
|
+
const defaultLabels = {
|
|
9
|
+
period: "AM/PM",
|
|
10
|
+
hour: "Hour",
|
|
11
|
+
minute: "Minute",
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* An hour/minute wheel, driven by seed-design's headless engine so the column
|
|
15
|
+
* order, the 12- vs 24-hour split and the minute stepping are locale-correct by
|
|
16
|
+
* construction, and rendered with crisp's own `WheelPicker` so the pixels are
|
|
17
|
+
* the ones already measured for it.
|
|
18
|
+
*/
|
|
19
|
+
function TimePicker({ value, defaultValue, onValueChange, minuteStep, locale, disabled, labels, size = "medium", className, ...rest }) {
|
|
20
|
+
// The engine defaults `locale` to "ko-KR" — it is a Korean design system.
|
|
21
|
+
// crisp's other components are English-default, so the default is overridden
|
|
22
|
+
// here rather than inherited; a consumer's own `locale` still wins.
|
|
23
|
+
const api = (0, react_time_picker_1.useTimePicker)({
|
|
24
|
+
value,
|
|
25
|
+
defaultValue,
|
|
26
|
+
onValueChange,
|
|
27
|
+
minuteStep,
|
|
28
|
+
locale: locale ?? "en-US",
|
|
29
|
+
disabled,
|
|
30
|
+
});
|
|
31
|
+
const t = { ...defaultLabels, ...labels };
|
|
32
|
+
// `columnOrder` is locale-derived: en-US puts the period last ("3:30 PM"),
|
|
33
|
+
// ko-KR first, and a 24-hour locale omits it entirely.
|
|
34
|
+
const columns = api.columnOrder.map((type) => ({
|
|
35
|
+
key: type,
|
|
36
|
+
label: t[type],
|
|
37
|
+
options: api.columns[type].options.map((o) => ({
|
|
38
|
+
value: o.value,
|
|
39
|
+
label: o.label,
|
|
40
|
+
})),
|
|
41
|
+
}));
|
|
42
|
+
const selection = Object.fromEntries(api.columnOrder.map((type) => [type, api.columns[type].value]));
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)("div", { ...rest, className: className, children: (0, jsx_runtime_1.jsx)(wheelpicker_1.WheelPicker, { columns: columns, value: selection, size: size, onValueChange: (next) => {
|
|
44
|
+
// Route each wheel back to its OWN column, so the engine keeps
|
|
45
|
+
// ownership of rounding, looping and the 12-to-24-hour mapping.
|
|
46
|
+
// Sending them all to one column silently makes the period wheel
|
|
47
|
+
// set the hour.
|
|
48
|
+
for (const type of api.columnOrder) {
|
|
49
|
+
const v = next[type];
|
|
50
|
+
if (v != null)
|
|
51
|
+
api.columns[type].onValueChange(v);
|
|
52
|
+
}
|
|
53
|
+
} }) }));
|
|
54
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -61,6 +61,7 @@ __exportStar(require("./components/table"), exports);
|
|
|
61
61
|
__exportStar(require("./components/tabletoolbar"), exports);
|
|
62
62
|
__exportStar(require("./components/tabs"), exports);
|
|
63
63
|
__exportStar(require("./components/textarea"), exports);
|
|
64
|
+
__exportStar(require("./components/timepicker"), exports);
|
|
64
65
|
__exportStar(require("./components/toast"), exports);
|
|
65
66
|
__exportStar(require("./components/tooltip"), exports);
|
|
66
67
|
__exportStar(require("./components/wheelpicker"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./timepicker.js";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useTimePicker, } from "@seed-design/react-time-picker";
|
|
4
|
+
import { WheelPicker } from "../wheelpicker/index.js";
|
|
5
|
+
const defaultLabels = {
|
|
6
|
+
period: "AM/PM",
|
|
7
|
+
hour: "Hour",
|
|
8
|
+
minute: "Minute",
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* An hour/minute wheel, driven by seed-design's headless engine so the column
|
|
12
|
+
* order, the 12- vs 24-hour split and the minute stepping are locale-correct by
|
|
13
|
+
* construction, and rendered with crisp's own `WheelPicker` so the pixels are
|
|
14
|
+
* the ones already measured for it.
|
|
15
|
+
*/
|
|
16
|
+
export function TimePicker({ value, defaultValue, onValueChange, minuteStep, locale, disabled, labels, size = "medium", className, ...rest }) {
|
|
17
|
+
// The engine defaults `locale` to "ko-KR" — it is a Korean design system.
|
|
18
|
+
// crisp's other components are English-default, so the default is overridden
|
|
19
|
+
// here rather than inherited; a consumer's own `locale` still wins.
|
|
20
|
+
const api = useTimePicker({
|
|
21
|
+
value,
|
|
22
|
+
defaultValue,
|
|
23
|
+
onValueChange,
|
|
24
|
+
minuteStep,
|
|
25
|
+
locale: locale ?? "en-US",
|
|
26
|
+
disabled,
|
|
27
|
+
});
|
|
28
|
+
const t = { ...defaultLabels, ...labels };
|
|
29
|
+
// `columnOrder` is locale-derived: en-US puts the period last ("3:30 PM"),
|
|
30
|
+
// ko-KR first, and a 24-hour locale omits it entirely.
|
|
31
|
+
const columns = api.columnOrder.map((type) => ({
|
|
32
|
+
key: type,
|
|
33
|
+
label: t[type],
|
|
34
|
+
options: api.columns[type].options.map((o) => ({
|
|
35
|
+
value: o.value,
|
|
36
|
+
label: o.label,
|
|
37
|
+
})),
|
|
38
|
+
}));
|
|
39
|
+
const selection = Object.fromEntries(api.columnOrder.map((type) => [type, api.columns[type].value]));
|
|
40
|
+
return (_jsx("div", { ...rest, className: className, children: _jsx(WheelPicker, { columns: columns, value: selection, size: size, onValueChange: (next) => {
|
|
41
|
+
// Route each wheel back to its OWN column, so the engine keeps
|
|
42
|
+
// ownership of rounding, looping and the 12-to-24-hour mapping.
|
|
43
|
+
// Sending them all to one column silently makes the period wheel
|
|
44
|
+
// set the hour.
|
|
45
|
+
for (const type of api.columnOrder) {
|
|
46
|
+
const v = next[type];
|
|
47
|
+
if (v != null)
|
|
48
|
+
api.columns[type].onValueChange(v);
|
|
49
|
+
}
|
|
50
|
+
} }) }));
|
|
51
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -45,6 +45,7 @@ export * from "./components/table/index.js";
|
|
|
45
45
|
export * from "./components/tabletoolbar/index.js";
|
|
46
46
|
export * from "./components/tabs/index.js";
|
|
47
47
|
export * from "./components/textarea/index.js";
|
|
48
|
+
export * from "./components/timepicker/index.js";
|
|
48
49
|
export * from "./components/toast/index.js";
|
|
49
50
|
export * from "./components/tooltip/index.js";
|
|
50
51
|
export * from "./components/wheelpicker/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./timepicker";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type MinuteStep, type TimePickerValue, type UseTimePickerProps } from "@seed-design/react-time-picker";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
export type { MinuteStep, TimePickerValue };
|
|
4
|
+
export type TimePickerProps = UseTimePickerProps & Omit<React.ComponentPropsWithoutRef<"div">, keyof UseTimePickerProps | "children"> & {
|
|
5
|
+
/** Accessible names for the wheels, so they can be translated. */
|
|
6
|
+
labels?: Partial<Record<"period" | "hour" | "minute", string>>;
|
|
7
|
+
size?: "small" | "medium";
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* An hour/minute wheel, driven by seed-design's headless engine so the column
|
|
11
|
+
* order, the 12- vs 24-hour split and the minute stepping are locale-correct by
|
|
12
|
+
* construction, and rendered with crisp's own `WheelPicker` so the pixels are
|
|
13
|
+
* the ones already measured for it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function TimePicker({ value, defaultValue, onValueChange, minuteStep, locale, disabled, labels, size, className, ...rest }: TimePickerProps): React.JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export * from "./components/table";
|
|
|
41
41
|
export * from "./components/tabletoolbar";
|
|
42
42
|
export * from "./components/tabs";
|
|
43
43
|
export * from "./components/textarea";
|
|
44
|
+
export * from "./components/timepicker";
|
|
44
45
|
export * from "./components/toast";
|
|
45
46
|
export * from "./components/tooltip";
|
|
46
47
|
export * from "./components/wheelpicker";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crisp-ui-kit/crisp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "A lean React design system, measured pixel-for-pixel from Attio.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -247,6 +247,11 @@
|
|
|
247
247
|
"import": "./dist/esm/components/textarea/index.js",
|
|
248
248
|
"require": "./dist/cjs/components/textarea/index.js"
|
|
249
249
|
},
|
|
250
|
+
"./timepicker": {
|
|
251
|
+
"types": "./dist/types/components/timepicker/index.d.ts",
|
|
252
|
+
"import": "./dist/esm/components/timepicker/index.js",
|
|
253
|
+
"require": "./dist/cjs/components/timepicker/index.js"
|
|
254
|
+
},
|
|
250
255
|
"./toast": {
|
|
251
256
|
"types": "./dist/types/components/toast/index.d.ts",
|
|
252
257
|
"import": "./dist/esm/components/toast/index.js",
|
|
@@ -413,6 +418,7 @@
|
|
|
413
418
|
"@seed-design/dom-utils": "^2.1.0",
|
|
414
419
|
"@seed-design/react-date-picker": "1.2.0",
|
|
415
420
|
"@seed-design/react-file-upload": "1.0.1",
|
|
421
|
+
"@seed-design/react-time-picker": "1.0.0",
|
|
416
422
|
"@zag-js/combobox": "^1.43.3",
|
|
417
423
|
"@zag-js/dialog": "^1.43.3",
|
|
418
424
|
"@zag-js/react": "^1.43.3",
|