@plexui/vue 0.21.0 → 0.23.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/es/components/Alert/Alert.js +16 -4
- package/dist/es/components/Alert/Alert.js.map +1 -1
- package/dist/es/components/ColorPicker/ColorPicker.js +13 -9
- package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/es/components/ColorPicker/ColorWell.js +5 -3
- package/dist/es/components/ColorPicker/ColorWell.js.map +1 -1
- package/dist/es/components/ColorPicker/shared.js +5 -4
- package/dist/es/components/ColorPicker/shared.js.map +1 -1
- package/dist/es/components/ContextMenu/ContextMenu.js +9 -9
- package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/es/components/ContextMenu/shared.js +25 -5
- package/dist/es/components/ContextMenu/shared.js.map +1 -1
- package/dist/es/components/DataTable/columnHelpers.js +88 -6
- package/dist/es/components/DataTable/columnHelpers.js.map +1 -1
- package/dist/es/components/DatePicker/DatePicker.js +3 -3
- package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/es/components/DatePicker/useCalendarCollisionPadding.js +25 -0
- package/dist/es/components/DatePicker/useCalendarCollisionPadding.js.map +1 -0
- package/dist/es/components/DateRangePicker/DateRangePicker.js +3 -3
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +2 -2
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Input/Input.js +3 -0
- package/dist/es/components/Input/Input.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +10 -1
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/PhoneLayout/PhoneLayout.js +9 -1
- package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -1
- package/dist/es/components/Popover/Popover.js +2 -2
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/ProgressSteps/ProgressSteps.js +7 -3
- package/dist/es/components/ProgressSteps/ProgressSteps.js.map +1 -1
- package/dist/es/components/ProgressSteps/index.js.map +1 -1
- package/dist/es/components/Select/Select.js +178 -32
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +3 -1
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/Slider/Slider.js +24 -11
- package/dist/es/components/Slider/Slider.js.map +1 -1
- package/dist/es/components/Slider/sliderPrimitive.js +5 -2
- package/dist/es/components/Slider/sliderPrimitive.js.map +1 -1
- package/dist/es/components/Sortable/Sortable.js +1 -1
- package/dist/es/components/Sortable/Sortable.js.map +1 -1
- package/dist/es/components/StatCard/index.js +4 -1
- package/dist/es/components/StatCard/index.js.map +1 -1
- package/dist/es/components/{StatCard/StatCard.js → StatsCard/StatsCard.js} +32 -27
- package/dist/es/components/StatsCard/StatsCard.js.map +1 -0
- package/dist/es/components/StatsCard/index.js +2 -0
- package/dist/es/components/StatsCard/index.js.map +1 -0
- package/dist/es/components/SwipeActions/SwipeActions.js +32 -5
- package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -1
- package/dist/es/components/TabBar/TabBar.js +52 -21
- package/dist/es/components/TabBar/TabBar.js.map +1 -1
- package/dist/es/components/Tabs/Tabs.js +229 -6
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/es/lib/menuTriggerCover.js +40 -3
- package/dist/es/lib/menuTriggerCover.js.map +1 -1
- package/dist/types/components/ColorPicker/ColorPicker.d.ts +3 -2
- package/dist/types/components/ColorPicker/shared.d.ts +5 -4
- package/dist/types/components/ContextMenu/shared.d.ts +28 -6
- package/dist/types/components/DatePicker/useCalendarCollisionPadding.d.ts +9 -0
- package/dist/types/components/Dialog/Dialog.d.ts +2 -2
- package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +5 -0
- package/dist/types/components/Popover/Popover.d.ts +5 -5
- package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +17 -3
- package/dist/types/components/ProgressSteps/index.d.ts +1 -1
- package/dist/types/components/Select/Select.d.ts +19 -8
- package/dist/types/components/StatCard/index.d.ts +9 -1
- package/dist/types/components/{StatCard/StatCard.d.ts → StatsCard/StatsCard.d.ts} +19 -19
- package/dist/types/components/StatsCard/index.d.ts +1 -0
- package/dist/types/components/SwipeActions/SwipeActions.d.ts +4 -4
- package/dist/types/components/TabBar/TabBar.d.ts +34 -0
- package/dist/types/components/Tabs/Tabs.d.ts +33 -2
- package/dist/types/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/types/lib/menuTriggerCover.d.ts +16 -2
- package/package.json +2 -2
- package/dist/es/components/DatePicker/useCalendarGutter.js +0 -14
- package/dist/es/components/DatePicker/useCalendarGutter.js.map +0 -1
- package/dist/es/components/StatCard/StatCard.js.map +0 -1
- package/dist/types/components/DatePicker/useCalendarGutter.d.ts +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h } from "vue";
|
|
1
|
+
import { defineComponent, h, onMounted, ref } from "vue";
|
|
2
2
|
import { Badge } from "../Badge/index.js";
|
|
3
3
|
import { CopyTooltip, Tooltip } from "../Tooltip/index.js";
|
|
4
4
|
/** Monospace ID that copies itself on click, with a copy tooltip. */
|
|
@@ -18,19 +18,101 @@ export function idCell(accessor) {
|
|
|
18
18
|
IdCell.displayName = "IdCell";
|
|
19
19
|
return IdCell;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
// ISO 8601: a date, a time, and a zone (Z or an offset) when the value names an instant.
|
|
22
|
+
const ISO_DATE = /^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}(?::?\d{2})?)?)?$/;
|
|
23
|
+
/**
|
|
24
|
+
* An ISO date read field by field, the same in every runtime (engines read the edges of the format each their own
|
|
25
|
+
* way), null when it is no date (the 30th of February, an hour of 25; 24:00 is the next midnight). A date, or a
|
|
26
|
+
* date and time, written without a zone ("2023-01-15", "2023-01-15T09:00") names no instant, and a runtime would
|
|
27
|
+
* read it in its own zone, the server's in one and the reader's in another: it is `written`, shown as written in
|
|
28
|
+
* every zone.
|
|
29
|
+
*/
|
|
30
|
+
function readIsoDate(value) {
|
|
31
|
+
const match = ISO_DATE.exec(value);
|
|
32
|
+
if (!match)
|
|
33
|
+
return undefined;
|
|
34
|
+
const [, yearText, monthText, dayText, hourText = "0", minuteText = "0", secondText = "0", fraction = "0", zone] = match;
|
|
35
|
+
const [year, month, day, hour, minute, second] = [yearText, monthText, dayText, hourText, minuteText, secondText].map(Number);
|
|
36
|
+
const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
37
|
+
const monthDays = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
|
|
38
|
+
const endOfDay = hour === 24 && minute + second + Number(fraction) === 0;
|
|
39
|
+
const offsetHours = zone && zone !== "Z" ? Number(zone.slice(1, 3)) : 0;
|
|
40
|
+
const offsetMinutes = zone && zone.length > 3 ? Number(zone.slice(-2)) : 0;
|
|
41
|
+
const inRange = monthDays !== undefined && day >= 1 && day <= monthDays && (hour <= 23 || endOfDay) && minute <= 59 && second <= 59 &&
|
|
42
|
+
offsetHours <= 23 && offsetMinutes <= 59;
|
|
43
|
+
if (!inRange)
|
|
44
|
+
return null;
|
|
45
|
+
// Counted, not built from a Date: a value at the edge of the range a Date holds would leave it on the way.
|
|
46
|
+
// An offset east of UTC is that much earlier in UTC.
|
|
47
|
+
const offset = (zone?.[0] === "-" ? -1 : 1) * (offsetHours * 60 + offsetMinutes);
|
|
48
|
+
const time = daysFromCivil(year, month, day) * 86_400_000 + ((hour * 60 + minute - offset) * 60 + second) * 1000 +
|
|
49
|
+
Number(fraction.slice(0, 3).padEnd(3, "0"));
|
|
50
|
+
const date = new Date(time);
|
|
51
|
+
return Number.isNaN(date.getTime()) ? null : { date, written: !zone };
|
|
52
|
+
}
|
|
53
|
+
/** Days from 1970-01-01 to a date of the proleptic Gregorian calendar (H. Hinnant's days_from_civil). */
|
|
54
|
+
function daysFromCivil(year, month, day) {
|
|
55
|
+
const y = month <= 2 ? year - 1 : year;
|
|
56
|
+
const era = Math.floor(y / 400);
|
|
57
|
+
const yearOfEra = y - era * 400;
|
|
58
|
+
const dayOfYear = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1;
|
|
59
|
+
const dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;
|
|
60
|
+
return era * 146_097 + dayOfEra - 719_468;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Formats a cell's value: in the reader's zone once mounted, and on the server and while hydrating in a zone that
|
|
64
|
+
* does not depend on where they run. The text can still differ between engines (Node joins a date and a time with
|
|
65
|
+
* ", ", WebKit with " at "), so the cell lets hydration differ in its text and writes the reader's text once mounted.
|
|
66
|
+
*/
|
|
67
|
+
function dateTimeFormatter(options) {
|
|
68
|
+
const formatOptions = options ?? {
|
|
24
69
|
year: "numeric",
|
|
25
70
|
month: "short",
|
|
26
71
|
day: "numeric",
|
|
27
72
|
hour: "2-digit",
|
|
28
73
|
minute: "2-digit",
|
|
29
74
|
};
|
|
30
|
-
const
|
|
75
|
+
const reader = new Intl.DateTimeFormat("en-US", formatOptions);
|
|
76
|
+
// The server knows no reader's time zone: without a timeZone in the options it writes an instant in UTC, and
|
|
77
|
+
// so does the render that takes over the server's markup; the reader's own zone follows once it is mounted.
|
|
78
|
+
const server = formatOptions.timeZone ? reader : new Intl.DateTimeFormat("en-US", { ...formatOptions, timeZone: "UTC" });
|
|
79
|
+
// A written date names no zone, so none is printed: a long or full time would add one, a medium one does not.
|
|
80
|
+
const zoneless = formatOptions.timeStyle === "long" || formatOptions.timeStyle === "full" ? "medium" : formatOptions.timeStyle;
|
|
81
|
+
const written = new Intl.DateTimeFormat("en-US", { ...formatOptions, timeZone: "UTC", timeZoneName: undefined, timeStyle: zoneless });
|
|
82
|
+
return (value, mounted) => {
|
|
83
|
+
const iso = readIsoDate(value);
|
|
84
|
+
if (iso === null)
|
|
85
|
+
return value;
|
|
86
|
+
if (iso)
|
|
87
|
+
return (iso.written ? written : mounted ? reader : server).format(iso.date);
|
|
88
|
+
// Any other way of writing a date each runtime reads its own way, and one that is no date at all none can
|
|
89
|
+
// format: the server and the render that takes over its markup show it as written, the reader's runtime
|
|
90
|
+
// reads it once mounted.
|
|
91
|
+
const date = new Date(value);
|
|
92
|
+
return mounted && !Number.isNaN(date.getTime()) ? reader.format(date) : value;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** One formatted cell: the server's format until it is mounted, then the reader's. */
|
|
96
|
+
const DateTimeText = defineComponent({
|
|
97
|
+
name: "DateTimeText",
|
|
98
|
+
props: {
|
|
99
|
+
value: { type: String, default: undefined },
|
|
100
|
+
format: { type: Function, required: true },
|
|
101
|
+
},
|
|
102
|
+
setup(props) {
|
|
103
|
+
const mounted = ref(false);
|
|
104
|
+
onMounted(() => { mounted.value = true; });
|
|
105
|
+
// Hydration may take the server's text in another engine's words (Vue writes its own over it); once mounted,
|
|
106
|
+
// the reader's zone follows.
|
|
107
|
+
return () => h("span", { "data-allow-mismatch": "text", style: { color: "var(--color-text-secondary)" } }, props.value ? props.format(props.value, mounted.value) : "—");
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
/** Date and time formatted with Intl.DateTimeFormat ("en-US"); "—" when empty. */
|
|
111
|
+
export function dateTimeCell(accessor, options) {
|
|
112
|
+
const format = dateTimeFormatter(options);
|
|
31
113
|
const DateTimeCell = ({ row }) => {
|
|
32
114
|
const val = accessor(row.original);
|
|
33
|
-
return h(
|
|
115
|
+
return h(DateTimeText, { value: val ?? undefined, format });
|
|
34
116
|
};
|
|
35
117
|
DateTimeCell.displayName = "DateTimeCell";
|
|
36
118
|
return DateTimeCell;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnHelpers.js","sourceRoot":"","sources":["../../../../src/components/DataTable/columnHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAA;AAEnC,OAAO,EAAE,KAAK,EAAmB,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAe1D,qEAAqE;AACrE,MAAM,UAAU,MAAM,CAAI,QAA4B;IACpD,MAAM,MAAM,GAAqB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;QAC3C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACpC,OAAO,CAAC,CACN,WAAW,EACX,EAAE,SAAS,EAAE,KAAK,EAAE,EACpB;YACE,OAAO,EAAE,GAAG,EAAE,CACZ,CAAC,CACC,MAAM,EACN;gBACE,KAAK,EAAE;oBACL,UAAU,EAAE,2CAA2C;oBACvD,KAAK,EAAE,6BAA6B;oBACpC,MAAM,EAAE,SAAS;iBAClB;aACF,EACD,KAAK,CACN;SACJ,CACF,CAAA;IACH,CAAC,CAAA;IACD,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAA;IAC7B,OAAO,MAAM,CAAA;AACf,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,YAAY,CAC1B,QAA+C,EAC/C,OAAoC;IAEpC,MAAM,cAAc,GAA+B;QACjD,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,OAAO;QACd,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;KAClB,CAAA;IACD,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,IAAI,cAAc,CAAC,CAAA;IAEvE,MAAM,YAAY,GAAqB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;QACjD,MAAM,GAAG,GAAG,QAAQ,CAAC,GA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ACvE,MAAM,aAAa,GAAuB,GAAG,EAAE,CAC7C,CAAC,CACC,OAAO,EACP,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,EACvD;QACE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,yBAAyB,EAAE,EAAE,EAAE,KAAK,CAAC;KACxG,CACF,CAAA;IACH,aAAa,CAAC,WAAW,GAAG,eAAe,CAAA;IAC3C,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["import { h, type VNode } from \"vue\"\nimport type { CellContext, HeaderContext } from \"@tanstack/vue-table\"\nimport { Badge, type BadgeColor } from \"../Badge/index.js\"\nimport { CopyTooltip, Tooltip } from \"../Tooltip/index.js\"\n\n// Vue port of packages/ui/src/components/DataTable/columnHelpers.tsx. Each\n// helper returns a functional component for a column's `cell` or `header`;\n// FlexRender renders it with the cell or header context as props, as\n// flexRender does in React.\n\ntype StatusColor = Extract<BadgeColor, \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\">\n\n/** A cell renderer: FlexRender calls it with the cell context. */\nexport type CellComponent<T> = ((context: CellContext<T, unknown>) => VNode) & { displayName?: string }\n\n/** A header renderer: FlexRender calls it with the header context. */\nexport type HeaderComponent<T> = ((context: HeaderContext<T, unknown>) => VNode) & { displayName?: string }\n\n/** Monospace ID that copies itself on click, with a copy tooltip. */\nexport function idCell<T>(accessor: (row: T) => string): CellComponent<T> {\n const IdCell: CellComponent<T> = ({ row }) => {\n const value = accessor(row.original)\n return h(\n CopyTooltip,\n { copyValue: value },\n {\n default: () =>\n h(\n \"span\",\n {\n style: {\n fontFamily: \"var(--font-mono, ui-monospace, monospace)\",\n color: \"var(--color-text-secondary)\",\n cursor: \"pointer\",\n },\n },\n value,\n ),\n },\n )\n }\n IdCell.displayName = \"IdCell\"\n return IdCell\n}\n\n/** Date and time formatted with Intl.DateTimeFormat (\"en-US\"); \"—\" when empty. */\nexport function dateTimeCell<T>(\n accessor: (row: T) => string | null | undefined,\n options?: Intl.DateTimeFormatOptions,\n): CellComponent<T> {\n const defaultOptions: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n }\n const fmt = new Intl.DateTimeFormat(\"en-US\", options ?? defaultOptions)\n\n const DateTimeCell: CellComponent<T> = ({ row }) => {\n const val = accessor(row.original)\n return h(\"span\", { style: { color: \"var(--color-text-secondary)\" } }, val ? fmt.format(new Date(val)) : \"—\")\n }\n DateTimeCell.displayName = \"DateTimeCell\"\n return DateTimeCell\n}\n\n/** Soft Badge whose color comes from the lowercased status (`colorMap`, or the default map). */\nexport function statusCell<T>(accessor: (row: T) => string, colorMap?: Record<string, StatusColor>): CellComponent<T> {\n const defaultColorMap: Record<string, StatusColor> = {\n active: \"success\",\n completed: \"success\",\n paid: \"success\",\n pending: \"warning\",\n processing: \"info\",\n inactive: \"secondary\",\n cancelled: \"danger\",\n failed: \"danger\",\n unpaid: \"danger\",\n }\n\n const StatusCell: CellComponent<T> = ({ row }) => {\n const status = accessor(row.original)\n const map = colorMap ?? defaultColorMap\n const color = map[status.toLowerCase()] ?? \"secondary\"\n return h(Badge, { color, variant: \"soft\" }, { default: () => status })\n }\n StatusCell.displayName = \"StatusCell\"\n return StatusCell\n}\n\n/** Header label with a dashed underline and a tooltip carrying `description`. */\nexport function tooltipHeader<T = any>(label: string, description: string): HeaderComponent<T> {\n const TooltipHeader: HeaderComponent<T> = () =>\n h(\n Tooltip,\n { content: description, side: \"bottom\", maxWidth: 260 },\n {\n default: () => h(\"span\", { style: { cursor: \"help\", borderBottom: \"1px dashed currentColor\" } }, label),\n },\n )\n TooltipHeader.displayName = \"TooltipHeader\"\n return TooltipHeader\n}\n"]}
|
|
1
|
+
{"version":3,"file":"columnHelpers.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,IAAI,eAAe,CAAA;QACvC,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,WAAW,CAAA;QACtD,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;IACxE,CAAC,CAAA;IACD,UAAU,CAAC,WAAW,GAAG,YAAY,CAAA;IACrC,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAU,KAAa,EAAE,WAAmB;IACvE,MAAM,aAAa,GAAuB,GAAG,EAAE,CAC7C,CAAC,CACC,OAAO,EACP,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,EACvD;QACE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,yBAAyB,EAAE,EAAE,EAAE,KAAK,CAAC;KACxG,CACF,CAAA;IACH,aAAa,CAAC,WAAW,GAAG,eAAe,CAAA;IAC3C,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["import { defineComponent, h, onMounted, ref, type PropType, type VNode } from \"vue\"\nimport type { CellContext, HeaderContext } from \"@tanstack/vue-table\"\nimport { Badge, type BadgeColor } from \"../Badge/index.js\"\nimport { CopyTooltip, Tooltip } from \"../Tooltip/index.js\"\n\n// Vue port of packages/ui/src/components/DataTable/columnHelpers.tsx. Each\n// helper returns a functional component for a column's `cell` or `header`;\n// FlexRender renders it with the cell or header context as props, as\n// flexRender does in React.\n\ntype StatusColor = Extract<BadgeColor, \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\">\n\n/** A cell renderer: FlexRender calls it with the cell context. */\nexport type CellComponent<T> = ((context: CellContext<T, unknown>) => VNode) & { displayName?: string }\n\n/** A header renderer: FlexRender calls it with the header context. */\nexport type HeaderComponent<T> = ((context: HeaderContext<T, unknown>) => VNode) & { displayName?: string }\n\n/** Monospace ID that copies itself on click, with a copy tooltip. */\nexport function idCell<T>(accessor: (row: T) => string): CellComponent<T> {\n const IdCell: CellComponent<T> = ({ row }) => {\n const value = accessor(row.original)\n return h(\n CopyTooltip,\n { copyValue: value },\n {\n default: () =>\n h(\n \"span\",\n {\n style: {\n fontFamily: \"var(--font-mono, ui-monospace, monospace)\",\n color: \"var(--color-text-secondary)\",\n cursor: \"pointer\",\n },\n },\n value,\n ),\n },\n )\n }\n IdCell.displayName = \"IdCell\"\n return IdCell\n}\n\n// ISO 8601: a date, a time, and a zone (Z or an offset) when the value names an instant.\nconst ISO_DATE = /^([+-]\\d{6}|\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?(Z|[+-]\\d{2}(?::?\\d{2})?)?)?$/\n\n/**\n * An ISO date read field by field, the same in every runtime (engines read the edges of the format each their own\n * way), null when it is no date (the 30th of February, an hour of 25; 24:00 is the next midnight). A date, or a\n * date and time, written without a zone (\"2023-01-15\", \"2023-01-15T09:00\") names no instant, and a runtime would\n * read it in its own zone, the server's in one and the reader's in another: it is `written`, shown as written in\n * every zone.\n */\nfunction readIsoDate(value: string): { date: Date; written: boolean } | null | undefined {\n const match = ISO_DATE.exec(value)\n if (!match) return undefined\n const [, yearText, monthText, dayText, hourText = \"0\", minuteText = \"0\", secondText = \"0\", fraction = \"0\", zone] = match\n const [year, month, day, hour, minute, second] = [yearText, monthText, dayText, hourText, minuteText, secondText].map(Number)\n const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0\n const monthDays = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1]\n const endOfDay = hour === 24 && minute + second + Number(fraction) === 0\n const offsetHours = zone && zone !== \"Z\" ? Number(zone.slice(1, 3)) : 0\n const offsetMinutes = zone && zone.length > 3 ? Number(zone.slice(-2)) : 0\n const inRange =\n monthDays !== undefined && day >= 1 && day <= monthDays && (hour <= 23 || endOfDay) && minute <= 59 && second <= 59 &&\n offsetHours <= 23 && offsetMinutes <= 59\n if (!inRange) return null\n // Counted, not built from a Date: a value at the edge of the range a Date holds would leave it on the way.\n // An offset east of UTC is that much earlier in UTC.\n const offset = (zone?.[0] === \"-\" ? -1 : 1) * (offsetHours * 60 + offsetMinutes)\n const time =\n daysFromCivil(year, month, day) * 86_400_000 + ((hour * 60 + minute - offset) * 60 + second) * 1000 +\n Number(fraction.slice(0, 3).padEnd(3, \"0\"))\n const date = new Date(time)\n return Number.isNaN(date.getTime()) ? null : { date, written: !zone }\n}\n\n/** Days from 1970-01-01 to a date of the proleptic Gregorian calendar (H. Hinnant's days_from_civil). */\nfunction daysFromCivil(year: number, month: number, day: number) {\n const y = month <= 2 ? year - 1 : year\n const era = Math.floor(y / 400)\n const yearOfEra = y - era * 400\n const dayOfYear = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1\n const dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear\n return era * 146_097 + dayOfEra - 719_468\n}\n\n/**\n * Formats a cell's value: in the reader's zone once mounted, and on the server and while hydrating in a zone that\n * does not depend on where they run. The text can still differ between engines (Node joins a date and a time with\n * \", \", WebKit with \" at \"), so the cell lets hydration differ in its text and writes the reader's text once mounted.\n */\nfunction dateTimeFormatter(options?: Intl.DateTimeFormatOptions) {\n const formatOptions: Intl.DateTimeFormatOptions = options ?? {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n }\n const reader = new Intl.DateTimeFormat(\"en-US\", formatOptions)\n // The server knows no reader's time zone: without a timeZone in the options it writes an instant in UTC, and\n // so does the render that takes over the server's markup; the reader's own zone follows once it is mounted.\n const server = formatOptions.timeZone ? reader : new Intl.DateTimeFormat(\"en-US\", { ...formatOptions, timeZone: \"UTC\" })\n // A written date names no zone, so none is printed: a long or full time would add one, a medium one does not.\n const zoneless = formatOptions.timeStyle === \"long\" || formatOptions.timeStyle === \"full\" ? \"medium\" : formatOptions.timeStyle\n const written = new Intl.DateTimeFormat(\"en-US\", { ...formatOptions, timeZone: \"UTC\", timeZoneName: undefined, timeStyle: zoneless })\n return (value: string, mounted: boolean) => {\n const iso = readIsoDate(value)\n if (iso === null) return value\n if (iso) return (iso.written ? written : mounted ? reader : server).format(iso.date)\n // Any other way of writing a date each runtime reads its own way, and one that is no date at all none can\n // format: the server and the render that takes over its markup show it as written, the reader's runtime\n // reads it once mounted.\n const date = new Date(value)\n return mounted && !Number.isNaN(date.getTime()) ? reader.format(date) : value\n }\n}\n\n/** One formatted cell: the server's format until it is mounted, then the reader's. */\nconst DateTimeText = defineComponent({\n name: \"DateTimeText\",\n props: {\n value: { type: String, default: undefined },\n format: { type: Function as PropType<(value: string, mounted: boolean) => string>, required: true },\n },\n setup(props) {\n const mounted = ref(false)\n onMounted(() => { mounted.value = true })\n // Hydration may take the server's text in another engine's words (Vue writes its own over it); once mounted,\n // the reader's zone follows.\n return () =>\n h(\n \"span\",\n { \"data-allow-mismatch\": \"text\", style: { color: \"var(--color-text-secondary)\" } },\n props.value ? props.format(props.value, mounted.value) : \"—\",\n )\n },\n})\n\n/** Date and time formatted with Intl.DateTimeFormat (\"en-US\"); \"—\" when empty. */\nexport function dateTimeCell<T>(\n accessor: (row: T) => string | null | undefined,\n options?: Intl.DateTimeFormatOptions,\n): CellComponent<T> {\n const format = dateTimeFormatter(options)\n\n const DateTimeCell: CellComponent<T> = ({ row }) => {\n const val = accessor(row.original)\n return h(DateTimeText, { value: val ?? undefined, format })\n }\n DateTimeCell.displayName = \"DateTimeCell\"\n return DateTimeCell\n}\n\n/** Soft Badge whose color comes from the lowercased status (`colorMap`, or the default map). */\nexport function statusCell<T>(accessor: (row: T) => string, colorMap?: Record<string, StatusColor>): CellComponent<T> {\n const defaultColorMap: Record<string, StatusColor> = {\n active: \"success\",\n completed: \"success\",\n paid: \"success\",\n pending: \"warning\",\n processing: \"info\",\n inactive: \"secondary\",\n cancelled: \"danger\",\n failed: \"danger\",\n unpaid: \"danger\",\n }\n\n const StatusCell: CellComponent<T> = ({ row }) => {\n const status = accessor(row.original)\n const map = colorMap ?? defaultColorMap\n const color = map[status.toLowerCase()] ?? \"secondary\"\n return h(Badge, { color, variant: \"soft\" }, { default: () => status })\n }\n StatusCell.displayName = \"StatusCell\"\n return StatusCell\n}\n\n/** Header label with a dashed underline and a tooltip carrying `description`. */\nexport function tooltipHeader<T = any>(label: string, description: string): HeaderComponent<T> {\n const TooltipHeader: HeaderComponent<T> = () =>\n h(\n Tooltip,\n { content: description, side: \"bottom\", maxWidth: 260 },\n {\n default: () => h(\"span\", { style: { cursor: \"help\", borderBottom: \"1px dashed currentColor\" } }, label),\n },\n )\n TooltipHeader.displayName = \"TooltipHeader\"\n return TooltipHeader\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { Calendar } from "../Icon/index.js";
|
|
|
7
7
|
import { Popover, PopoverContent, PopoverTrigger } from "../Popover/index.js";
|
|
8
8
|
import { SelectControl } from "../SelectControl/index.js";
|
|
9
9
|
import { DateCalendar } from "./Calendar.js";
|
|
10
|
-
import {
|
|
10
|
+
import { useCalendarCollisionPadding } from "./useCalendarCollisionPadding.js";
|
|
11
11
|
import { DateContextKey } from "./context.js";
|
|
12
12
|
// Vue port of packages/ui/src/components/DatePicker/DatePicker.tsx.
|
|
13
13
|
// - `value` + `update:value` (`v-model:value`), plus `change` with the same
|
|
@@ -85,7 +85,7 @@ const DatePickerComponent = defineComponent({
|
|
|
85
85
|
},
|
|
86
86
|
setup(props, { emit }) {
|
|
87
87
|
const wide = useBreakpoint("md");
|
|
88
|
-
const
|
|
88
|
+
const calendarCollisionPadding = useCalendarCollisionPadding();
|
|
89
89
|
const unwrap = (value) => (value ? toRaw(value) : value);
|
|
90
90
|
const onChange = (nextValue) => {
|
|
91
91
|
emit("update:value", nextValue);
|
|
@@ -170,7 +170,7 @@ const DatePickerComponent = defineComponent({
|
|
|
170
170
|
h(PopoverContent, {
|
|
171
171
|
class: s.Popover,
|
|
172
172
|
minWidth: 230,
|
|
173
|
-
collisionPadding: wide.value ? 20 :
|
|
173
|
+
collisionPadding: wide.value ? 20 : calendarCollisionPadding.value,
|
|
174
174
|
side: wide.value || props.side === "top" ? props.side : "bottom",
|
|
175
175
|
sideOffset: props.sideOffset,
|
|
176
176
|
align,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../src/components/DatePicker/DatePicker.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0DAA0D,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,KAAK,CAAA;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAuC,MAAM,qBAAqB,CAAA;AAClH,OAAO,EAAE,aAAa,EAAyB,MAAM,2BAA2B,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAyB,MAAM,cAAc,CAAA;AAEpE,oEAAoE;AACpE,4EAA4E;AAC5E,uEAAuE;AACvE,8DAA8D;AAC9D,2EAA2E;AAC3E,uEAAuE;AACvE,+CAA+C;AAC/C,2EAA2E;AAC3E,sD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W,EAAE,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;qBAChE,EACD,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,EAAE,CACrC;iBACF;aACF,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAMF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAAA","sourcesContent":["import s from \"@plexui/styles/components/DatePicker/Calendar.module.css\"\nimport { DateTime } from \"luxon\"\nimport { defineComponent, h, provide, toRaw, useId, type PropType } from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { useBreakpoint } from \"../../composables/useBreakpoints.js\"\nimport { isAfter } from \"../../lib/dateUtils.js\"\nimport { Calendar } from \"../Icon/index.js\"\nimport { Popover, PopoverContent, PopoverTrigger, type PopoverAlign, type PopoverSide } from \"../Popover/index.js\"\nimport { SelectControl, type DropdownIconType } from \"../SelectControl/index.js\"\nimport { DateCalendar } from \"./Calendar.js\"\nimport { useCalendarGutter } from \"./useCalendarGutter.js\"\nimport { DateContextKey, type DateContextValue } from \"./context.js\"\n\n// Vue port of packages/ui/src/components/DatePicker/DatePicker.tsx.\n// - `value` + `update:value` (`v-model:value`), plus `change` with the same\n// value (React's `onChange`). Like React the picker is controlled: a\n// parent that does not update `value` keeps the shown date.\n// - `aria-label`, `aria-labelledby`, `aria-describedby` and `aria-invalid`\n// reach the trigger, as in React. Other attributes are not passed on\n// (React's DatePicker takes no other props).\n// - DateTime values are read unwrapped (`toRaw`), so a `ref()` holding one\n// (a deep reactive proxy) works like a plain value.\n\nconst DatePickerComponent = defineComponent({\n name: \"DatePicker\",\n inheritAttrs: false,\n props: {\n /** Allow targeting the input for forms and accessibility. */\n id: String,\n \"ariaLabel\": String,\n \"ariaLabelledby\": String,\n \"ariaDescribedby\": String,\n \"ariaInvalid\": {\n type: [Boolean, String] as PropType<boolean | \"true\" | \"false\" | \"grammar\" | \"spelling\">,\n default: undefined,\n },\n /** The selected date value (`v-model:value`). */\n value: { type: Object as PropType<DateTime | null>, default: null },\n /** Defines the earliest selectable date (inclusive). */\n min: Object as PropType<DateTime>,\n /** Defines the latest selectable date (inclusive). */\n max: Object as PropType<DateTime>,\n /** Preferred side; collisions can flip it. On phones, left and right prefer bottom so seven 44px day targets fit. @default \"bottom\" */\n side: { type: String as PropType<PopoverSide>, default: \"bottom\" },\n /** The distance in pixels from the trigger. @default 8 */\n sideOffset: { type: Number, default: 8 },\n /** The preferred alignment against the trigger. @default \"center\" */\n align: { type: String as PropType<PopoverAlign>, default: \"center\" },\n /** An offset in pixels from the \"start\" or \"end\" alignment options. @default 0 */\n alignOffset: Number,\n /** Disables the select visually and from interactions. @default false */\n disabled: { type: Boolean, default: false },\n /** Placeholder text for the select. @default \"Select date...\" */\n placeholder: { type: String, default: \"Select date...\" },\n /** Style variant for the select trigger. @default \"outline\" */\n variant: { type: String as PropType<\"soft\" | \"outline\" | \"ghost\">, default: \"outline\" },\n /** Determines if the select trigger should be a fully rounded pill shape. @default true */\n pill: { type: Boolean, default: true },\n /** Size of the control: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Icon displayed in the far right of the select trigger. @default \"dropdown\" */\n dropdownIconType: String as PropType<DropdownIconType>,\n /** Custom class applied to the select trigger */\n triggerClassName: String,\n /** Display calendar icon at the start of the trigger. @default true */\n triggerShowIcon: { type: Boolean, default: true },\n /** Format of dates displayed in the trigger. @default \"MM/dd/yy\" (\"MM/dd/yy HH:mm\" with `showTime` and no `triggerTimeFormat`) */\n triggerDateFormat: String,\n /**\n * With `showTime`, the format of the time shown after the date in the trigger. The date and the time are\n * then two parts: in a row of a `FieldGroup` on a phone, the two capsules of iOS's compact date and time.\n */\n triggerTimeFormat: String,\n /** Display a clear action that allows the select to be unset. @default false */\n clearable: { type: Boolean, default: false },\n /** Extends select to 100% of available width. @default false */\n block: { type: Boolean, default: false },\n /** Calendar header: arrow navigation (`\"buttons\"`) or month and year dropdowns. @default \"buttons\" */\n captionLayout: { type: String as PropType<\"buttons\" | \"dropdown\">, default: \"buttons\" },\n /** Show time input below the calendar for combined date and time selection. @default false */\n showTime: { type: Boolean, default: false },\n /** Range of selectable years when `captionLayout` is `\"dropdown\"`. @default [currentYear - 120, currentYear] */\n yearRange: Array as unknown as PropType<[number, number]>,\n },\n emits: {\n \"update:value\": (nextValue: DateTime | null) => nextValue === null || DateTime.isDateTime(nextValue),\n \"change\": (nextValue: DateTime | null) => nextValue === null || DateTime.isDateTime(nextValue),\n },\n setup(props, { emit }) {\n const wide = useBreakpoint(\"md\")\n const calendarGutter = useCalendarGutter()\n const unwrap = <T>(value: T): T => (value ? toRaw(value) : value)\n\n const onChange = (nextValue: DateTime | null) => {\n emit(\"update:value\", nextValue)\n emit(\"change\", nextValue)\n }\n\n const store: DateContextValue = {\n get value() {\n return unwrap(props.value) ?? null\n },\n get min() {\n return unwrap(props.min)\n },\n get max() {\n return unwrap(props.max)\n },\n get disabled() {\n return props.disabled\n },\n get captionLayout() {\n return props.captionLayout\n },\n get showTime() {\n return props.showTime\n },\n get yearRange() {\n return props.yearRange\n },\n onChange,\n }\n provide(DateContextKey, store)\n\n const handleClearClick = () => {\n onChange(null)\n }\n\n // The value text needs an id for aria-labelledby, also when `id` is not set\n const generatedId = useId()\n\n return () => {\n const { id, ariaLabelledby, align, placeholder } = props\n const value = store.value\n const { min, max } = store\n\n // min and max are inclusive, so equal bounds allow one date\n if (min && max && isAfter(min, max)) {\n throw new Error(\"DatePicker error: `min` date must not be after the `max` date\")\n }\n\n const valueId = `${id ?? generatedId}-value`\n\n const timeFormat = props.showTime ? props.triggerTimeFormat : undefined\n const triggerDateFormat = props.triggerDateFormat ?? (props.showTime && !timeFormat ? \"MM/dd/yy HH:mm\" : \"MM/dd/yy\")\n // With a time format the date and the time are two parts, apart by a space; a phone row draws each as a capsule\n const text = !value\n ? placeholder\n : timeFormat\n ? h(\"span\", { \"data-date-parts\": \"\" }, [\n h(\"span\", { \"data-date-part\": \"date\" }, value.toFormat(triggerDateFormat)),\n \" \",\n h(\"span\", { \"data-date-part\": \"time\" }, value.toFormat(timeFormat)),\n ])\n : value.toFormat(triggerDateFormat)\n\n return h(Popover, null, {\n default: () => [\n h(PopoverTrigger, null, {\n default: () => [\n h(\n SelectControl,\n {\n \"id\": id,\n \"aria-label\": props.ariaLabel,\n \"aria-labelledby\": ariaLabelledby ? `${ariaLabelledby} ${valueId}` : undefined,\n \"aria-describedby\": props.ariaDescribedby,\n \"aria-invalid\": props.ariaInvalid,\n \"class\": props.triggerClassName,\n \"data-date-picker\": \"\",\n \"selected\": !!value,\n \"variant\": props.variant,\n \"pill\": props.pill,\n \"block\": props.block,\n \"size\": props.size,\n \"disabled\": props.disabled,\n \"interactOnEnter\": true,\n \"StartIcon\": props.triggerShowIcon ? Calendar : undefined,\n \"dropdownIconType\": props.dropdownIconType,\n \"onClearClick\": props.clearable ? handleClearClick : undefined,\n },\n { default: () => [ariaLabelledby ? h(\"span\", { id: valueId }, text) : text] },\n ),\n ],\n }),\n h(\n PopoverContent,\n {\n class: s.Popover,\n minWidth: 230,\n collisionPadding: wide.value ? 20 : calendarGutter.value,\n side: wide.value || props.side === \"top\" ? props.side : \"bottom\",\n sideOffset: props.sideOffset,\n align,\n alignOffset: props.alignOffset ?? (align === \"center\" ? 0 : -5),\n },\n { default: () => [h(DateCalendar)] },\n ),\n ],\n })\n }\n },\n})\n\ntype DatePickerOwnProps = InstanceType<typeof DatePickerComponent>[\"$props\"]\n\nexport type DatePickerProps = DatePickerOwnProps\n\n/**\n * A date (and optionally time) picker: a SelectControl trigger opening a\n * calendar in a popover. Bind the date (a luxon `DateTime`) with\n * `v-model:value`.\n */\nexport const DatePicker = DatePickerComponent\n"]}
|
|
1
|
+
{"version":3,"file":"DatePicker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\"\nimport { defineComponent, h, provide, toRaw, useId, type PropType } from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { useBreakpoint } from \"../../composables/useBreakpoints.js\"\nimport { isAfter } from \"../../lib/dateUtils.js\"\nimport { Calendar } from \"../Icon/index.js\"\nimport { Popover, PopoverContent, PopoverTrigger, type PopoverAlign, type PopoverSide } from \"../Popover/index.js\"\nimport { SelectControl, type DropdownIconType } from \"../SelectControl/index.js\"\nimport { DateCalendar } from \"./Calendar.js\"\nimport { useCalendarCollisionPadding } from \"./useCalendarCollisionPadding.js\"\nimport { DateContextKey, type DateContextValue } from \"./context.js\"\n\n// Vue port of packages/ui/src/components/DatePicker/DatePicker.tsx.\n// - `value` + `update:value` (`v-model:value`), plus `change` with the same\n// value (React's `onChange`). Like React the picker is controlled: a\n// parent that does not update `value` keeps the shown date.\n// - `aria-label`, `aria-labelledby`, `aria-describedby` and `aria-invalid`\n// reach the trigger, as in React. Other attributes are not passed on\n// (React's DatePicker takes no other props).\n// - DateTime values are read unwrapped (`toRaw`), so a `ref()` holding one\n// (a deep reactive proxy) works like a plain value.\n\nconst DatePickerComponent = defineComponent({\n name: \"DatePicker\",\n inheritAttrs: false,\n props: {\n /** Allow targeting the input for forms and accessibility. */\n id: String,\n \"ariaLabel\": String,\n \"ariaLabelledby\": String,\n \"ariaDescribedby\": String,\n \"ariaInvalid\": {\n type: [Boolean, String] as PropType<boolean | \"true\" | \"false\" | \"grammar\" | \"spelling\">,\n default: undefined,\n },\n /** The selected date value (`v-model:value`). */\n value: { type: Object as PropType<DateTime | null>, default: null },\n /** Defines the earliest selectable date (inclusive). */\n min: Object as PropType<DateTime>,\n /** Defines the latest selectable date (inclusive). */\n max: Object as PropType<DateTime>,\n /** Preferred side; collisions can flip it. On phones, left and right prefer bottom so seven 44px day targets fit. @default \"bottom\" */\n side: { type: String as PropType<PopoverSide>, default: \"bottom\" },\n /** The distance in pixels from the trigger. @default 8 */\n sideOffset: { type: Number, default: 8 },\n /** The preferred alignment against the trigger. @default \"center\" */\n align: { type: String as PropType<PopoverAlign>, default: \"center\" },\n /** An offset in pixels from the \"start\" or \"end\" alignment options. @default 0 */\n alignOffset: Number,\n /** Disables the select visually and from interactions. @default false */\n disabled: { type: Boolean, default: false },\n /** Placeholder text for the select. @default \"Select date...\" */\n placeholder: { type: String, default: \"Select date...\" },\n /** Style variant for the select trigger. @default \"outline\" */\n variant: { type: String as PropType<\"soft\" | \"outline\" | \"ghost\">, default: \"outline\" },\n /** Determines if the select trigger should be a fully rounded pill shape. @default true */\n pill: { type: Boolean, default: true },\n /** Size of the control: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Icon displayed in the far right of the select trigger. @default \"dropdown\" */\n dropdownIconType: String as PropType<DropdownIconType>,\n /** Custom class applied to the select trigger */\n triggerClassName: String,\n /** Display calendar icon at the start of the trigger. @default true */\n triggerShowIcon: { type: Boolean, default: true },\n /** Format of dates displayed in the trigger. @default \"MM/dd/yy\" (\"MM/dd/yy HH:mm\" with `showTime` and no `triggerTimeFormat`) */\n triggerDateFormat: String,\n /**\n * With `showTime`, the format of the time shown after the date in the trigger. The date and the time are\n * then two parts: in a row of a `FieldGroup` on a phone, the two capsules of iOS's compact date and time.\n */\n triggerTimeFormat: String,\n /** Display a clear action that allows the select to be unset. @default false */\n clearable: { type: Boolean, default: false },\n /** Extends select to 100% of available width. @default false */\n block: { type: Boolean, default: false },\n /** Calendar header: arrow navigation (`\"buttons\"`) or month and year dropdowns. @default \"buttons\" */\n captionLayout: { type: String as PropType<\"buttons\" | \"dropdown\">, default: \"buttons\" },\n /** Show time input below the calendar for combined date and time selection. @default false */\n showTime: { type: Boolean, default: false },\n /** Range of selectable years when `captionLayout` is `\"dropdown\"`. @default [currentYear - 120, currentYear] */\n yearRange: Array as unknown as PropType<[number, number]>,\n },\n emits: {\n \"update:value\": (nextValue: DateTime | null) => nextValue === null || DateTime.isDateTime(nextValue),\n \"change\": (nextValue: DateTime | null) => nextValue === null || DateTime.isDateTime(nextValue),\n },\n setup(props, { emit }) {\n const wide = useBreakpoint(\"md\")\n const calendarCollisionPadding = useCalendarCollisionPadding()\n const unwrap = <T>(value: T): T => (value ? toRaw(value) : value)\n\n const onChange = (nextValue: DateTime | null) => {\n emit(\"update:value\", nextValue)\n emit(\"change\", nextValue)\n }\n\n const store: DateContextValue = {\n get value() {\n return unwrap(props.value) ?? null\n },\n get min() {\n return unwrap(props.min)\n },\n get max() {\n return unwrap(props.max)\n },\n get disabled() {\n return props.disabled\n },\n get captionLayout() {\n return props.captionLayout\n },\n get showTime() {\n return props.showTime\n },\n get yearRange() {\n return props.yearRange\n },\n onChange,\n }\n provide(DateContextKey, store)\n\n const handleClearClick = () => {\n onChange(null)\n }\n\n // The value text needs an id for aria-labelledby, also when `id` is not set\n const generatedId = useId()\n\n return () => {\n const { id, ariaLabelledby, align, placeholder } = props\n const value = store.value\n const { min, max } = store\n\n // min and max are inclusive, so equal bounds allow one date\n if (min && max && isAfter(min, max)) {\n throw new Error(\"DatePicker error: `min` date must not be after the `max` date\")\n }\n\n const valueId = `${id ?? generatedId}-value`\n\n const timeFormat = props.showTime ? props.triggerTimeFormat : undefined\n const triggerDateFormat = props.triggerDateFormat ?? (props.showTime && !timeFormat ? \"MM/dd/yy HH:mm\" : \"MM/dd/yy\")\n // With a time format the date and the time are two parts, apart by a space; a phone row draws each as a capsule\n const text = !value\n ? placeholder\n : timeFormat\n ? h(\"span\", { \"data-date-parts\": \"\" }, [\n h(\"span\", { \"data-date-part\": \"date\" }, value.toFormat(triggerDateFormat)),\n \" \",\n h(\"span\", { \"data-date-part\": \"time\" }, value.toFormat(timeFormat)),\n ])\n : value.toFormat(triggerDateFormat)\n\n return h(Popover, null, {\n default: () => [\n h(PopoverTrigger, null, {\n default: () => [\n h(\n SelectControl,\n {\n \"id\": id,\n \"aria-label\": props.ariaLabel,\n \"aria-labelledby\": ariaLabelledby ? `${ariaLabelledby} ${valueId}` : undefined,\n \"aria-describedby\": props.ariaDescribedby,\n \"aria-invalid\": props.ariaInvalid,\n \"class\": props.triggerClassName,\n \"data-date-picker\": \"\",\n \"selected\": !!value,\n \"variant\": props.variant,\n \"pill\": props.pill,\n \"block\": props.block,\n \"size\": props.size,\n \"disabled\": props.disabled,\n \"interactOnEnter\": true,\n \"StartIcon\": props.triggerShowIcon ? Calendar : undefined,\n \"dropdownIconType\": props.dropdownIconType,\n \"onClearClick\": props.clearable ? handleClearClick : undefined,\n },\n { default: () => [ariaLabelledby ? h(\"span\", { id: valueId }, text) : text] },\n ),\n ],\n }),\n h(\n PopoverContent,\n {\n class: s.Popover,\n minWidth: 230,\n collisionPadding: wide.value ? 20 : calendarCollisionPadding.value,\n side: wide.value || props.side === \"top\" ? props.side : \"bottom\",\n sideOffset: props.sideOffset,\n align,\n alignOffset: props.alignOffset ?? (align === \"center\" ? 0 : -5),\n },\n { default: () => [h(DateCalendar)] },\n ),\n ],\n })\n }\n },\n})\n\ntype DatePickerOwnProps = InstanceType<typeof DatePickerComponent>[\"$props\"]\n\nexport type DatePickerProps = DatePickerOwnProps\n\n/**\n * A date (and optionally time) picker: a SelectControl trigger opening a\n * calendar in a popover. Bind the date (a luxon `DateTime`) with\n * `v-model:value`.\n */\nexport const DatePicker = DatePickerComponent\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
|
2
|
+
// Mirrors React's useCalendarCollisionPadding. The calendar's collision padding on a phone: seven 44px days leave the
|
|
3
|
+
// rest of the width to two outer and two inner gutters (the CSS uses the same gutter for its width), and the calendar
|
|
4
|
+
// keeps that gutter above and below. Where the 328px calendar fits with room to spare, its sides keep up to 32px from
|
|
5
|
+
// the screen's edges, as iOS 27.2 keeps the compact date picker's calendar 32pt from the edge it would cross (UIKit
|
|
6
|
+
// and Calendar on an iPhone 17).
|
|
7
|
+
export const calendarCollisionPadding = (width) => {
|
|
8
|
+
const gutter = Math.max(3, Math.min(16, (width - 308) / 4));
|
|
9
|
+
const side = Math.max(gutter, Math.min(32, (width - 328) / 2));
|
|
10
|
+
return { top: gutter, right: side, bottom: gutter, left: side };
|
|
11
|
+
};
|
|
12
|
+
// The root's client width leaves out a classic scrollbar, as the popover's own viewport does; a document with no
|
|
13
|
+
// layout (0) falls back to the window's width.
|
|
14
|
+
const viewportWidth = () => document.documentElement.clientWidth || window.innerWidth;
|
|
15
|
+
export const useCalendarCollisionPadding = () => {
|
|
16
|
+
const width = ref();
|
|
17
|
+
const update = () => { width.value = viewportWidth(); };
|
|
18
|
+
onMounted(() => {
|
|
19
|
+
update();
|
|
20
|
+
window.addEventListener("resize", update);
|
|
21
|
+
});
|
|
22
|
+
onBeforeUnmount(() => window.removeEventListener("resize", update));
|
|
23
|
+
return computed(() => width.value === undefined ? { top: 16, right: 16, bottom: 16, left: 16 } : calendarCollisionPadding(width.value));
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useCalendarCollisionPadding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCalendarCollisionPadding.js","sourceRoot":"","sources":["../../../../src/components/DatePicker/useCalendarCollisionPadding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,EAAoB,MAAM,KAAK,CAAA;AAIjF,sHAAsH;AACtH,sHAAsH;AACtH,sHAAsH;AACtH,oHAAoH;AACpH,iCAAiC;AACjC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAa,EAA4B,EAAE;IAClF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AACjE,CAAC,CAAA;AAED,iHAAiH;AACjH,+CAA+C;AAC/C,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,WAAW,IAAI,MAAM,CAAC,UAAU,CAAA;AAErF,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAA0C,EAAE;IACrF,MAAM,KAAK,GAAG,GAAG,EAAU,CAAA;IAC3B,MAAM,MAAM,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,GAAG,aAAa,EAAE,CAAA,CAAC,CAAC,CAAA;IAEtD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,CAAA;QACR,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;IACF,eAAe,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;IAEnE,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,wBAAwB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;AACzI,CAAC,CAAA","sourcesContent":["import { computed, onBeforeUnmount, onMounted, ref, type ComputedRef } from \"vue\"\n\nexport type CalendarCollisionPadding = { top: number; right: number; bottom: number; left: number }\n\n// Mirrors React's useCalendarCollisionPadding. The calendar's collision padding on a phone: seven 44px days leave the\n// rest of the width to two outer and two inner gutters (the CSS uses the same gutter for its width), and the calendar\n// keeps that gutter above and below. Where the 328px calendar fits with room to spare, its sides keep up to 32px from\n// the screen's edges, as iOS 27.2 keeps the compact date picker's calendar 32pt from the edge it would cross (UIKit\n// and Calendar on an iPhone 17).\nexport const calendarCollisionPadding = (width: number): CalendarCollisionPadding => {\n const gutter = Math.max(3, Math.min(16, (width - 308) / 4))\n const side = Math.max(gutter, Math.min(32, (width - 328) / 2))\n return { top: gutter, right: side, bottom: gutter, left: side }\n}\n\n// The root's client width leaves out a classic scrollbar, as the popover's own viewport does; a document with no\n// layout (0) falls back to the window's width.\nconst viewportWidth = () => document.documentElement.clientWidth || window.innerWidth\n\nexport const useCalendarCollisionPadding = (): ComputedRef<CalendarCollisionPadding> => {\n const width = ref<number>()\n const update = () => { width.value = viewportWidth() }\n\n onMounted(() => {\n update()\n window.addEventListener(\"resize\", update)\n })\n onBeforeUnmount(() => window.removeEventListener(\"resize\", update))\n\n return computed(() => width.value === undefined ? { top: 16, right: 16, bottom: 16, left: 16 } : calendarCollisionPadding(width.value))\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { computed, defineComponent, h, provide, toRaw } from "vue";
|
|
|
4
4
|
import { useBreakpoint } from "../../composables/useBreakpoints.js";
|
|
5
5
|
import { isAfter } from "../../lib/dateUtils.js";
|
|
6
6
|
import { Popover, PopoverContent, PopoverTrigger } from "../Popover/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useCalendarCollisionPadding } from "../DatePicker/useCalendarCollisionPadding.js";
|
|
8
8
|
import { DateRangeCalendar, DateRangeShortcuts } from "./Calendar.js";
|
|
9
9
|
import { DateRangeContextKey } from "./context.js";
|
|
10
10
|
import { DateRangeTrigger } from "./Trigger.js";
|
|
@@ -72,7 +72,7 @@ const DateRangePickerComponent = defineComponent({
|
|
|
72
72
|
},
|
|
73
73
|
setup(props, { emit }) {
|
|
74
74
|
const wide = useBreakpoint("md");
|
|
75
|
-
const
|
|
75
|
+
const calendarCollisionPadding = useCalendarCollisionPadding();
|
|
76
76
|
const unwrap = (value) => (value ? toRaw(value) : value);
|
|
77
77
|
// A new range only when `value` or one of its endpoints changes, as the
|
|
78
78
|
// identity React's effects see. The endpoints are read through the array
|
|
@@ -157,7 +157,7 @@ const DateRangePickerComponent = defineComponent({
|
|
|
157
157
|
h(PopoverContent, {
|
|
158
158
|
class: s.Popover,
|
|
159
159
|
minWidth: 230,
|
|
160
|
-
collisionPadding: wide.value ? 20 :
|
|
160
|
+
collisionPadding: wide.value ? 20 : calendarCollisionPadding.value,
|
|
161
161
|
side: wide.value || props.side === "top" ? props.side : "bottom",
|
|
162
162
|
sideOffset: props.sideOffset,
|
|
163
163
|
align,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangePicker.js","sourceRoot":"","sources":["../../../../src/components/DateRangePicker/DateRangePicker.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,+DAA+D,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAiB,MAAM,KAAK,CAAA;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAuC,MAAM,qBAAqB,CAAA;AAClH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAEtE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACrE,OAAO,EAAE,mBAAmB,EAA8B,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAA0D,MAAM,YAAY,CAAA;AAEnF,8EAA8E;AAC9E,0EAA0E;AAC1E,4EAA4E;AAC5E,uEAAuE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c,CAAC,KAAK;wBACxD,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ;wBAChE,UAAU,EAAE,KAAK,CAAC,UAAU;wBAC5B,KAAK;wBACL,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;qBAChE,EACD;wBACE,OAAO,EAAE,GAAG,EAAE,CAAC;4BACb,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;yBAC3G;qBACF,CACF;iBACF;aACF,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAIF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAA","sourcesContent":["import s from \"@plexui/styles/components/DateRangePicker/Calendar.module.css\"\nimport { DateTime } from \"luxon\"\nimport { computed, defineComponent, h, provide, toRaw, type PropType } from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { useBreakpoint } from \"../../composables/useBreakpoints.js\"\nimport { isAfter } from \"../../lib/dateUtils.js\"\nimport { Popover, PopoverContent, PopoverTrigger, type PopoverAlign, type PopoverSide } from \"../Popover/index.js\"\nimport { useCalendarGutter } from \"../DatePicker/useCalendarGutter.js\"\nimport type { DropdownIconType } from \"../SelectControl/index.js\"\nimport { DateRangeCalendar, DateRangeShortcuts } from \"./Calendar.js\"\nimport { DateRangeContextKey, type DateRangeContextValue } from \"./context.js\"\nimport { DateRangeTrigger } from \"./Trigger.js\"\nimport { type DateRange, type DateRangeShortcut, type WeekStart } from \"./types.js\"\n\n// Vue port of packages/ui/src/components/DateRangePicker/DateRangePicker.tsx.\n// - `value` + `update:value` (`v-model:value`), plus `change`, which also\n// carries the selected shortcut like React's `onChange(range, shortcut)`.\n// Like React the picker is controlled: a parent that does not update\n// `value` keeps the shown range.\n// - DateTime values are read unwrapped (`toRaw`), so a `ref()` holding a\n// range (a deep reactive proxy) works like a plain value.\n\nconst DateRangePickerComponent = defineComponent({\n name: \"DateRangePicker\",\n inheritAttrs: false,\n props: {\n /** The selected date range value (`v-model:value`). */\n value: { type: Array as unknown as PropType<DateRange | null>, default: null },\n /** Defines the earliest selectable date (inclusive). */\n min: Object as PropType<DateTime>,\n /** Defines the latest selectable date (inclusive). */\n max: Object as PropType<DateTime>,\n /** Maximum length of the selectable range in days (inclusive). */\n maxRangeDays: Number,\n /** The day each week starts on, from 0 (Sunday) to 6 (Saturday). @default 0 */\n weekStartsOn: { type: Number as PropType<WeekStart>, default: 0 },\n /** Date range shortcuts for quick selection, shown to the left of the calendar. Not shown below the md breakpoint: on a phone, offer them in a row of their own (see the docs). */\n shortcuts: Array as PropType<DateRangeShortcut[]>,\n /** Preferred side; collisions can flip it. On phones, left and right prefer bottom so seven 44px day targets fit. @default \"bottom\" */\n side: { type: String as PropType<PopoverSide>, default: \"bottom\" },\n /** The distance in pixels from the trigger. @default 8 */\n sideOffset: { type: Number, default: 8 },\n /** The preferred alignment against the trigger. @default \"center\" */\n align: { type: String as PropType<PopoverAlign>, default: \"center\" },\n /** An offset in pixels from the \"start\" or \"end\" alignment options. @default 0 */\n alignOffset: Number,\n /** Disables the select visually and from interactions. @default false */\n disabled: { type: Boolean, default: false },\n /** Placeholder text for the select. @default \"Select date range...\" */\n placeholder: { type: String, default: \"Select date range...\" },\n /** Style variant for the select trigger. @default \"outline\" */\n variant: { type: String as PropType<\"soft\" | \"outline\" | \"ghost\">, default: \"outline\" },\n /** Determines if the select trigger should be a fully rounded pill shape. @default true */\n pill: { type: Boolean, default: true },\n /** Size of the control: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Icon displayed in the far right of the select trigger. @default \"dropdown\" */\n dropdownIconType: String as PropType<DropdownIconType>,\n /** Custom class applied to the select trigger */\n triggerClassName: String,\n /** Display calendar icon at the start of the trigger. @default true */\n triggerShowIcon: { type: Boolean, default: true },\n /** Shows a stepper in the trigger when the selected range matches the unit ('month'). */\n triggerStepperUnit: String as PropType<\"month\">,\n /** Format of dates displayed in the trigger. @default \"MM/dd/yy\" */\n triggerDateFormat: { type: String, default: \"MM/dd/yy\" },\n /** Display a clear action that allows the select to be unset. @default false */\n clearable: { type: Boolean, default: false },\n /** Extends select to 100% of available width. @default false */\n block: { type: Boolean, default: false },\n },\n emits: {\n \"update:value\": (nextValue: DateRange | null) => nextValue === null || nextValue.every(DateTime.isDateTime),\n \"change\": (nextValue: DateRange | null, shortcut?: DateRangeShortcut) =>\n (nextValue === null || nextValue.every(DateTime.isDateTime)) &&\n (shortcut === undefined || typeof shortcut.getDateRange === \"function\"),\n },\n setup(props, { emit }) {\n const wide = useBreakpoint(\"md\")\n const calendarGutter = useCalendarGutter()\n const unwrap = <T>(value: T): T => (value ? toRaw(value) : value)\n\n // A new range only when `value` or one of its endpoints changes, as the\n // identity React's effects see. The endpoints are read through the array\n // so that `range.value[0] = date` on a `ref()` range is tracked.\n const value = computed<DateRange | null>(() => {\n const range = props.value\n if (!range) return null\n return [toRaw(range[0]), toRaw(range[1])]\n })\n\n const store: DateRangeContextValue = {\n get value() {\n return value.value\n },\n get min() {\n return unwrap(props.min)\n },\n get max() {\n return unwrap(props.max)\n },\n get maxRangeDays() {\n return props.maxRangeDays\n },\n get weekStartsOn() {\n return props.weekStartsOn\n },\n get triggerStepperUnit() {\n return props.triggerStepperUnit\n },\n get triggerClassName() {\n return props.triggerClassName\n },\n get triggerShowIcon() {\n return props.triggerShowIcon\n },\n get triggerDateFormat() {\n return props.triggerDateFormat\n },\n get disabled() {\n return props.disabled\n },\n get variant() {\n return props.variant\n },\n get pill() {\n return props.pill\n },\n get block() {\n return props.block\n },\n get size() {\n return props.size\n },\n get dropdownIconType() {\n return props.dropdownIconType\n },\n get clearable() {\n return props.clearable\n },\n get placeholder() {\n return props.placeholder\n },\n get shortcuts() {\n return props.shortcuts\n },\n onChange: (nextValue, shortcut) => {\n emit(\"update:value\", nextValue)\n emit(\"change\", nextValue, shortcut)\n },\n }\n provide(DateRangeContextKey, store)\n\n return () => {\n const { min, max } = store\n const { align } = props\n\n // min and max are inclusive, so equal bounds allow one date\n if (min && max && isAfter(min, max)) {\n throw new Error(\"DateRangePicker error: `min` date must not be after the `max` date\")\n }\n\n return h(Popover, null, {\n default: () => [\n h(PopoverTrigger, null, { default: () => [h(DateRangeTrigger)] }),\n h(\n PopoverContent,\n {\n class: s.Popover,\n minWidth: 230,\n collisionPadding: wide.value ? 20 : calendarGutter.value,\n side: wide.value || props.side === \"top\" ? props.side : \"bottom\",\n sideOffset: props.sideOffset,\n align,\n alignOffset: props.alignOffset ?? (align === \"center\" ? 0 : -5),\n },\n {\n default: () => [\n h(\"div\", { class: \"flex\" }, [h(DateRangeShortcuts, { shortcuts: props.shortcuts }), h(DateRangeCalendar)]),\n ],\n },\n ),\n ],\n })\n }\n },\n})\n\nexport type DateRangePickerProps = InstanceType<typeof DateRangePickerComponent>[\"$props\"]\n\n/**\n * A date range picker: a SelectControl trigger (or a month stepper) opening\n * two calendars and optional shortcuts in a popover. Bind the range\n * (`[start, end]` luxon `DateTime`s) with `v-model:value`.\n */\nexport const DateRangePicker = DateRangePickerComponent\n"]}
|
|
1
|
+
{"version":3,"file":"DateRangePicker.js","sourceRoot":"","sources":["../../../../src/components/DateRangePicker/DateRangePicker.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,+DAA+D,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EA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M,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAA","sourcesContent":["import s from \"@plexui/styles/components/DateRangePicker/Calendar.module.css\"\nimport { DateTime } from \"luxon\"\nimport { computed, defineComponent, h, provide, toRaw, type PropType } from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { useBreakpoint } from \"../../composables/useBreakpoints.js\"\nimport { isAfter } from \"../../lib/dateUtils.js\"\nimport { Popover, PopoverContent, PopoverTrigger, type PopoverAlign, type PopoverSide } from \"../Popover/index.js\"\nimport { useCalendarCollisionPadding } from \"../DatePicker/useCalendarCollisionPadding.js\"\nimport type { DropdownIconType } from \"../SelectControl/index.js\"\nimport { DateRangeCalendar, DateRangeShortcuts } from \"./Calendar.js\"\nimport { DateRangeContextKey, type DateRangeContextValue } from \"./context.js\"\nimport { DateRangeTrigger } from \"./Trigger.js\"\nimport { type DateRange, type DateRangeShortcut, type WeekStart } from \"./types.js\"\n\n// Vue port of packages/ui/src/components/DateRangePicker/DateRangePicker.tsx.\n// - `value` + `update:value` (`v-model:value`), plus `change`, which also\n// carries the selected shortcut like React's `onChange(range, shortcut)`.\n// Like React the picker is controlled: a parent that does not update\n// `value` keeps the shown range.\n// - DateTime values are read unwrapped (`toRaw`), so a `ref()` holding a\n// range (a deep reactive proxy) works like a plain value.\n\nconst DateRangePickerComponent = defineComponent({\n name: \"DateRangePicker\",\n inheritAttrs: false,\n props: {\n /** The selected date range value (`v-model:value`). */\n value: { type: Array as unknown as PropType<DateRange | null>, default: null },\n /** Defines the earliest selectable date (inclusive). */\n min: Object as PropType<DateTime>,\n /** Defines the latest selectable date (inclusive). */\n max: Object as PropType<DateTime>,\n /** Maximum length of the selectable range in days (inclusive). */\n maxRangeDays: Number,\n /** The day each week starts on, from 0 (Sunday) to 6 (Saturday). @default 0 */\n weekStartsOn: { type: Number as PropType<WeekStart>, default: 0 },\n /** Date range shortcuts for quick selection, shown to the left of the calendar. Not shown below the md breakpoint: on a phone, offer them in a row of their own (see the docs). */\n shortcuts: Array as PropType<DateRangeShortcut[]>,\n /** Preferred side; collisions can flip it. On phones, left and right prefer bottom so seven 44px day targets fit. @default \"bottom\" */\n side: { type: String as PropType<PopoverSide>, default: \"bottom\" },\n /** The distance in pixels from the trigger. @default 8 */\n sideOffset: { type: Number, default: 8 },\n /** The preferred alignment against the trigger. @default \"center\" */\n align: { type: String as PropType<PopoverAlign>, default: \"center\" },\n /** An offset in pixels from the \"start\" or \"end\" alignment options. @default 0 */\n alignOffset: Number,\n /** Disables the select visually and from interactions. @default false */\n disabled: { type: Boolean, default: false },\n /** Placeholder text for the select. @default \"Select date range...\" */\n placeholder: { type: String, default: \"Select date range...\" },\n /** Style variant for the select trigger. @default \"outline\" */\n variant: { type: String as PropType<\"soft\" | \"outline\" | \"ghost\">, default: \"outline\" },\n /** Determines if the select trigger should be a fully rounded pill shape. @default true */\n pill: { type: Boolean, default: true },\n /** Size of the control: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Icon displayed in the far right of the select trigger. @default \"dropdown\" */\n dropdownIconType: String as PropType<DropdownIconType>,\n /** Custom class applied to the select trigger */\n triggerClassName: String,\n /** Display calendar icon at the start of the trigger. @default true */\n triggerShowIcon: { type: Boolean, default: true },\n /** Shows a stepper in the trigger when the selected range matches the unit ('month'). */\n triggerStepperUnit: String as PropType<\"month\">,\n /** Format of dates displayed in the trigger. @default \"MM/dd/yy\" */\n triggerDateFormat: { type: String, default: \"MM/dd/yy\" },\n /** Display a clear action that allows the select to be unset. @default false */\n clearable: { type: Boolean, default: false },\n /** Extends select to 100% of available width. @default false */\n block: { type: Boolean, default: false },\n },\n emits: {\n \"update:value\": (nextValue: DateRange | null) => nextValue === null || nextValue.every(DateTime.isDateTime),\n \"change\": (nextValue: DateRange | null, shortcut?: DateRangeShortcut) =>\n (nextValue === null || nextValue.every(DateTime.isDateTime)) &&\n (shortcut === undefined || typeof shortcut.getDateRange === \"function\"),\n },\n setup(props, { emit }) {\n const wide = useBreakpoint(\"md\")\n const calendarCollisionPadding = useCalendarCollisionPadding()\n const unwrap = <T>(value: T): T => (value ? toRaw(value) : value)\n\n // A new range only when `value` or one of its endpoints changes, as the\n // identity React's effects see. The endpoints are read through the array\n // so that `range.value[0] = date` on a `ref()` range is tracked.\n const value = computed<DateRange | null>(() => {\n const range = props.value\n if (!range) return null\n return [toRaw(range[0]), toRaw(range[1])]\n })\n\n const store: DateRangeContextValue = {\n get value() {\n return value.value\n },\n get min() {\n return unwrap(props.min)\n },\n get max() {\n return unwrap(props.max)\n },\n get maxRangeDays() {\n return props.maxRangeDays\n },\n get weekStartsOn() {\n return props.weekStartsOn\n },\n get triggerStepperUnit() {\n return props.triggerStepperUnit\n },\n get triggerClassName() {\n return props.triggerClassName\n },\n get triggerShowIcon() {\n return props.triggerShowIcon\n },\n get triggerDateFormat() {\n return props.triggerDateFormat\n },\n get disabled() {\n return props.disabled\n },\n get variant() {\n return props.variant\n },\n get pill() {\n return props.pill\n },\n get block() {\n return props.block\n },\n get size() {\n return props.size\n },\n get dropdownIconType() {\n return props.dropdownIconType\n },\n get clearable() {\n return props.clearable\n },\n get placeholder() {\n return props.placeholder\n },\n get shortcuts() {\n return props.shortcuts\n },\n onChange: (nextValue, shortcut) => {\n emit(\"update:value\", nextValue)\n emit(\"change\", nextValue, shortcut)\n },\n }\n provide(DateRangeContextKey, store)\n\n return () => {\n const { min, max } = store\n const { align } = props\n\n // min and max are inclusive, so equal bounds allow one date\n if (min && max && isAfter(min, max)) {\n throw new Error(\"DateRangePicker error: `min` date must not be after the `max` date\")\n }\n\n return h(Popover, null, {\n default: () => [\n h(PopoverTrigger, null, { default: () => [h(DateRangeTrigger)] }),\n h(\n PopoverContent,\n {\n class: s.Popover,\n minWidth: 230,\n collisionPadding: wide.value ? 20 : calendarCollisionPadding.value,\n side: wide.value || props.side === \"top\" ? props.side : \"bottom\",\n sideOffset: props.sideOffset,\n align,\n alignOffset: props.alignOffset ?? (align === \"center\" ? 0 : -5),\n },\n {\n default: () => [\n h(\"div\", { class: \"flex\" }, [h(DateRangeShortcuts, { shortcuts: props.shortcuts }), h(DateRangeCalendar)]),\n ],\n },\n ),\n ],\n })\n }\n },\n})\n\nexport type DateRangePickerProps = InstanceType<typeof DateRangePickerComponent>[\"$props\"]\n\n/**\n * A date range picker: a SelectControl trigger (or a month stepper) opening\n * two calendars and optional shortcuts in a popover. Bind the range\n * (`[start, end]` luxon `DateTime`s) with `v-model:value`.\n */\nexport const DateRangePicker = DateRangePickerComponent\n"]}
|
|
@@ -476,7 +476,7 @@ export const DialogHeader = defineComponent({
|
|
|
476
476
|
const slot = descriptionSlot ? descriptionSlot.own.value ?? descriptionSlot.body.value : null;
|
|
477
477
|
// On a phone the header of a Sheet is its Toolbar (iOS 27 kit Sheets 507-24684, Toolbar - Top - iPhone
|
|
478
478
|
// 1-54520): Close at the leading edge, the title alone centered on the row of controls, the header actions
|
|
479
|
-
// at the trailing edge, all on one 44px row under the
|
|
479
|
+
// at the trailing edge, all on one 44px row 16px under the top edge.
|
|
480
480
|
return [
|
|
481
481
|
h(Toolbar, mergeProps({ "background": props.background, "data-dialog-bar": "" }, attrs), () => [
|
|
482
482
|
sheet?.value?.showClose
|
|
@@ -559,7 +559,7 @@ export const DialogDescriptionSlot = defineComponent({
|
|
|
559
559
|
export const DialogFooter = defineComponent({
|
|
560
560
|
name: "DialogFooter",
|
|
561
561
|
props: {
|
|
562
|
-
/** Override the mobile action layout.
|
|
562
|
+
/** Override the mobile action layout. Two alert actions default to inline, three or more and sheets to stacked. */
|
|
563
563
|
mobileLayout: String,
|
|
564
564
|
/** How the bar meets the content scrolled under it in a phone Sheet. @default "soft" */
|
|
565
565
|
background: { type: String, default: "soft" },
|