@mekari/pixel3-date-picker 0.0.3-dev.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/calendar-panel.d.mts +12 -6
  2. package/dist/calendar-panel.d.ts +12 -6
  3. package/dist/calendar-panel.js +163 -85
  4. package/dist/calendar-panel.mjs +14 -13
  5. package/dist/{chunk-EYTJIMSM.mjs → chunk-26K3LMTE.mjs} +32 -11
  6. package/dist/{chunk-5PISTT2K.mjs → chunk-5MFHZK63.mjs} +4 -4
  7. package/dist/{chunk-XQLKPPRN.mjs → chunk-5VRVDIXN.mjs} +47 -0
  8. package/dist/{chunk-NU6HYEPT.mjs → chunk-64EO4HV7.mjs} +1 -1
  9. package/dist/{chunk-ZS4JQRK3.mjs → chunk-7CLF67SP.mjs} +1 -1
  10. package/dist/{chunk-NIUQXHGQ.mjs → chunk-E5BRVBZ2.mjs} +19 -1
  11. package/dist/{chunk-KTADGCWP.mjs → chunk-FPRON3EM.mjs} +14 -14
  12. package/dist/chunk-IRNTTSB7.mjs +144 -0
  13. package/dist/chunk-KTYQJMW4.mjs +35 -0
  14. package/dist/chunk-MO5D3TCF.mjs +113 -0
  15. package/dist/{chunk-HJ4V3PM6.mjs → chunk-O43S64IA.mjs} +4 -4
  16. package/dist/{chunk-NVULZQVI.mjs → chunk-OMV7LXBW.mjs} +1 -1
  17. package/dist/chunk-OYJNIILC.mjs +40 -0
  18. package/dist/{chunk-3RCUXNBN.mjs → chunk-P7JOEQIL.mjs} +9 -6
  19. package/dist/{chunk-26Y3AVJW.mjs → chunk-U7O52D6B.mjs} +13 -1
  20. package/dist/{chunk-JZ2KFYWF.mjs → chunk-WK62QUOT.mjs} +1 -1
  21. package/dist/components/calendar/index.js +83 -51
  22. package/dist/components/calendar/index.mjs +8 -7
  23. package/dist/components/calendar/table-date.js +51 -19
  24. package/dist/components/calendar/table-date.mjs +5 -4
  25. package/dist/components/calendar/table-month.js +48 -16
  26. package/dist/components/calendar/table-month.mjs +6 -5
  27. package/dist/components/calendar/table-year.js +48 -16
  28. package/dist/components/calendar/table-year.mjs +6 -5
  29. package/dist/components/parts/index.d.mts +1 -0
  30. package/dist/components/parts/index.d.ts +1 -0
  31. package/dist/components/parts/index.js +34 -0
  32. package/dist/components/parts/index.mjs +7 -3
  33. package/dist/components/parts/time.d.mts +32 -0
  34. package/dist/components/parts/time.d.ts +32 -0
  35. package/dist/components/parts/time.js +59 -0
  36. package/dist/components/parts/time.mjs +7 -0
  37. package/dist/composables/useCalendar.d.mts +8 -1
  38. package/dist/composables/useCalendar.d.ts +8 -1
  39. package/dist/composables/useCalendar.mjs +2 -2
  40. package/dist/composables/useCalendarRange.mjs +2 -2
  41. package/dist/composables/useTime.d.mts +96 -0
  42. package/dist/composables/useTime.d.ts +96 -0
  43. package/dist/composables/useTime.js +185 -0
  44. package/dist/composables/useTime.mjs +9 -0
  45. package/dist/date-picker.d.mts +91 -3
  46. package/dist/date-picker.d.ts +91 -3
  47. package/dist/date-picker.js +487 -118
  48. package/dist/date-picker.mjs +19 -15
  49. package/dist/index.d.mts +7 -0
  50. package/dist/index.d.ts +7 -0
  51. package/dist/index.js +487 -118
  52. package/dist/index.mjs +19 -15
  53. package/dist/metafile-cjs.json +1 -1
  54. package/dist/metafile-esm.json +1 -1
  55. package/dist/modules/date-picker.hooks.js +3 -0
  56. package/dist/modules/date-picker.hooks.mjs +4 -4
  57. package/dist/modules/date-picker.locales.mjs +2 -2
  58. package/dist/modules/date-picker.props.d.mts +83 -4
  59. package/dist/modules/date-picker.props.d.ts +83 -4
  60. package/dist/modules/date-picker.props.js +50 -2
  61. package/dist/modules/date-picker.props.mjs +5 -3
  62. package/dist/time-panel.d.mts +98 -0
  63. package/dist/time-panel.d.ts +98 -0
  64. package/dist/time-panel.js +665 -0
  65. package/dist/time-panel.mjs +18 -0
  66. package/dist/utils/base.d.mts +3 -1
  67. package/dist/utils/base.d.ts +3 -1
  68. package/dist/utils/base.js +20 -0
  69. package/dist/utils/base.mjs +5 -1
  70. package/dist/utils/date.d.mts +2 -1
  71. package/dist/utils/date.d.ts +2 -1
  72. package/dist/utils/date.js +13 -0
  73. package/dist/utils/date.mjs +3 -1
  74. package/dist/utils/dom.d.mts +18 -0
  75. package/dist/utils/dom.d.ts +18 -0
  76. package/dist/utils/dom.js +62 -0
  77. package/dist/utils/dom.mjs +9 -0
  78. package/package.json +6 -6
  79. /package/dist/{chunk-FTR7OMCT.mjs → chunk-MRP3X6QP.mjs} +0 -0
@@ -23,7 +23,9 @@ var base_exports = {};
23
23
  __export(base_exports, {
24
24
  assign: () => assign,
25
25
  chunk: () => chunk,
26
+ generateOptions: () => generateOptions,
26
27
  isObject: () => isObject,
28
+ padNumber: () => padNumber,
27
29
  pick: () => pick
28
30
  });
29
31
  module.exports = __toCommonJS(base_exports);
@@ -71,10 +73,28 @@ var assign = /* @__PURE__ */ __name((initial, override) => {
71
73
  };
72
74
  }, {});
73
75
  }, "assign");
76
+ function padNumber(value) {
77
+ value = parseInt(value, 10);
78
+ return value < 10 ? `0${value}` : `${value}`;
79
+ }
80
+ __name(padNumber, "padNumber");
81
+ function generateOptions(length, step) {
82
+ if (step <= 0) {
83
+ step = 1;
84
+ }
85
+ const arr = [];
86
+ for (let i = 0; i < length; i += step) {
87
+ arr.push(i);
88
+ }
89
+ return arr;
90
+ }
91
+ __name(generateOptions, "generateOptions");
74
92
  // Annotate the CommonJS export names for ESM import in node:
75
93
  0 && (module.exports = {
76
94
  assign,
77
95
  chunk,
96
+ generateOptions,
78
97
  isObject,
98
+ padNumber,
79
99
  pick
80
100
  });
@@ -1,13 +1,17 @@
1
1
  import {
2
2
  assign,
3
3
  chunk,
4
+ generateOptions,
4
5
  isObject,
6
+ padNumber,
5
7
  pick
6
- } from "../chunk-NIUQXHGQ.mjs";
8
+ } from "../chunk-E5BRVBZ2.mjs";
7
9
  import "../chunk-QZ7VFGWC.mjs";
8
10
  export {
9
11
  assign,
10
12
  chunk,
13
+ generateOptions,
11
14
  isObject,
15
+ padNumber,
12
16
  pick
13
17
  };
@@ -15,5 +15,6 @@ declare function getNextMonth(date: Date): Date;
15
15
  declare function getPreviousMonth(date: Date): Date;
16
16
  declare function addDays(value: Date, days: number): Date;
17
17
  declare function isDateBetween(date: Date, min: Date, max: Date): boolean;
18
+ declare function getValidDate(value: Date | string | number, ...backup: (Date | string | number)[]): Date;
18
19
 
19
- export { addDays, createDate, getCalendar, getNextMonth, getPreviousMonth, isDateBetween, isValidDate, isValidRangeDate, startOfDay, startOfMonth, startOfWeek, startOfYear };
20
+ export { addDays, createDate, getCalendar, getNextMonth, getPreviousMonth, getValidDate, isDateBetween, isValidDate, isValidRangeDate, startOfDay, startOfMonth, startOfWeek, startOfYear };
@@ -15,5 +15,6 @@ declare function getNextMonth(date: Date): Date;
15
15
  declare function getPreviousMonth(date: Date): Date;
16
16
  declare function addDays(value: Date, days: number): Date;
17
17
  declare function isDateBetween(date: Date, min: Date, max: Date): boolean;
18
+ declare function getValidDate(value: Date | string | number, ...backup: (Date | string | number)[]): Date;
18
19
 
19
- export { addDays, createDate, getCalendar, getNextMonth, getPreviousMonth, isDateBetween, isValidDate, isValidRangeDate, startOfDay, startOfMonth, startOfWeek, startOfYear };
20
+ export { addDays, createDate, getCalendar, getNextMonth, getPreviousMonth, getValidDate, isDateBetween, isValidDate, isValidRangeDate, startOfDay, startOfMonth, startOfWeek, startOfYear };
@@ -26,6 +26,7 @@ __export(date_exports, {
26
26
  getCalendar: () => getCalendar,
27
27
  getNextMonth: () => getNextMonth,
28
28
  getPreviousMonth: () => getPreviousMonth,
29
+ getValidDate: () => getValidDate,
29
30
  isDateBetween: () => isDateBetween,
30
31
  isValidDate: () => isValidDate,
31
32
  isValidRangeDate: () => isValidRangeDate,
@@ -130,6 +131,17 @@ function isDateBetween(date, min, max) {
130
131
  return _date.getTime() >= _min.getTime() && _date.getTime() <= _max.getTime();
131
132
  }
132
133
  __name(isDateBetween, "isDateBetween");
134
+ function getValidDate(value, ...backup) {
135
+ const date = new Date(value);
136
+ if (isValidDate(date)) {
137
+ return date;
138
+ }
139
+ if (backup.length) {
140
+ return getValidDate(backup[0], ...backup.slice(1));
141
+ }
142
+ return /* @__PURE__ */ new Date();
143
+ }
144
+ __name(getValidDate, "getValidDate");
133
145
  // Annotate the CommonJS export names for ESM import in node:
134
146
  0 && (module.exports = {
135
147
  addDays,
@@ -137,6 +149,7 @@ __name(isDateBetween, "isDateBetween");
137
149
  getCalendar,
138
150
  getNextMonth,
139
151
  getPreviousMonth,
152
+ getValidDate,
140
153
  isDateBetween,
141
154
  isValidDate,
142
155
  isValidRangeDate,
@@ -4,6 +4,7 @@ import {
4
4
  getCalendar,
5
5
  getNextMonth,
6
6
  getPreviousMonth,
7
+ getValidDate,
7
8
  isDateBetween,
8
9
  isValidDate,
9
10
  isValidRangeDate,
@@ -11,7 +12,7 @@ import {
11
12
  startOfMonth,
12
13
  startOfWeek,
13
14
  startOfYear
14
- } from "../chunk-26Y3AVJW.mjs";
15
+ } from "../chunk-U7O52D6B.mjs";
15
16
  import "../chunk-QZ7VFGWC.mjs";
16
17
  export {
17
18
  addDays,
@@ -19,6 +20,7 @@ export {
19
20
  getCalendar,
20
21
  getNextMonth,
21
22
  getPreviousMonth,
23
+ getValidDate,
22
24
  isDateBetween,
23
25
  isValidDate,
24
26
  isValidRangeDate,
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Recursively finds the scrollable parent element of a given node.
3
+ *
4
+ * @param {HTMLElement | null} node - The starting node to search from.
5
+ * @param {HTMLElement} [until=document.body] - The node at which to stop searching.
6
+ * @returns {HTMLElement | null} The scrollable parent element, or null if none is found.
7
+ */
8
+ declare function getScrollParent(node: HTMLElement | null, until?: HTMLElement): HTMLElement | null;
9
+ /**
10
+ * Scrolls an element to a specified position over a given duration.
11
+ *
12
+ * @param {HTMLElement} element - The element to scroll.
13
+ * @param {number} to - The target scroll position.
14
+ * @param {number} [duration=0] - The duration of the scroll in milliseconds. If 0, scrolls instantly.
15
+ */
16
+ declare function scrollTo(element: HTMLElement, to: number, duration?: number): void;
17
+
18
+ export { getScrollParent, scrollTo };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Recursively finds the scrollable parent element of a given node.
3
+ *
4
+ * @param {HTMLElement | null} node - The starting node to search from.
5
+ * @param {HTMLElement} [until=document.body] - The node at which to stop searching.
6
+ * @returns {HTMLElement | null} The scrollable parent element, or null if none is found.
7
+ */
8
+ declare function getScrollParent(node: HTMLElement | null, until?: HTMLElement): HTMLElement | null;
9
+ /**
10
+ * Scrolls an element to a specified position over a given duration.
11
+ *
12
+ * @param {HTMLElement} element - The element to scroll.
13
+ * @param {number} to - The target scroll position.
14
+ * @param {number} [duration=0] - The duration of the scroll in milliseconds. If 0, scrolls instantly.
15
+ */
16
+ declare function scrollTo(element: HTMLElement, to: number, duration?: number): void;
17
+
18
+ export { getScrollParent, scrollTo };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/utils/dom.ts
22
+ var dom_exports = {};
23
+ __export(dom_exports, {
24
+ getScrollParent: () => getScrollParent,
25
+ scrollTo: () => scrollTo
26
+ });
27
+ module.exports = __toCommonJS(dom_exports);
28
+ function getScrollParent(node, until = document.body) {
29
+ if (!node || node === until) {
30
+ return null;
31
+ }
32
+ const style = /* @__PURE__ */ __name((value, prop) => getComputedStyle(value, null).getPropertyValue(prop), "style");
33
+ const regex = /(auto|scroll)/;
34
+ const scroll = regex.test(style(node, "overflow") + style(node, "overflow-y") + style(node, "overflow-x"));
35
+ return scroll ? node : getScrollParent(node.parentElement, until);
36
+ }
37
+ __name(getScrollParent, "getScrollParent");
38
+ function scrollTo(element, to, duration = 0) {
39
+ if (duration <= 0) {
40
+ requestAnimationFrame(() => {
41
+ element.scrollTop = to;
42
+ });
43
+ return;
44
+ }
45
+ const difference = to - element.scrollTop;
46
+ const tick = difference / duration * 10;
47
+ requestAnimationFrame(() => {
48
+ const scrollTop = element.scrollTop + tick;
49
+ if (scrollTop >= to) {
50
+ element.scrollTop = to;
51
+ return;
52
+ }
53
+ element.scrollTop = scrollTop;
54
+ scrollTo(element, to, duration - 10);
55
+ });
56
+ }
57
+ __name(scrollTo, "scrollTo");
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ getScrollParent,
61
+ scrollTo
62
+ });
@@ -0,0 +1,9 @@
1
+ import {
2
+ getScrollParent,
3
+ scrollTo
4
+ } from "../chunk-OYJNIILC.mjs";
5
+ import "../chunk-QZ7VFGWC.mjs";
6
+ export {
7
+ getScrollParent,
8
+ scrollTo
9
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@mekari/pixel3-date-picker",
3
3
  "description": "Date Picker component for mekari pixel 3",
4
4
  "author": "Dimas Raka Septiawan <dimas.raka@mekari.com>",
5
- "version": "0.0.3-dev.0",
5
+ "version": "0.1.0",
6
6
  "main": "dist/index.js",
7
7
  "license": "MIT",
8
8
  "files": [
@@ -11,11 +11,11 @@
11
11
  "dependencies": {
12
12
  "date-fns": "^3.3.1",
13
13
  "date-format-parse": "^0.2.7",
14
- "@mekari/pixel3-input": "0.0.10",
15
- "@mekari/pixel3-popover": "0.0.11-dev.0",
16
- "@mekari/pixel3-button": "0.0.10",
17
- "@mekari/pixel3-icon": "0.0.10",
18
- "@mekari/pixel3-styled-system": "0.0.8",
14
+ "@mekari/pixel3-input": "0.0.11",
15
+ "@mekari/pixel3-popover": "0.0.11",
16
+ "@mekari/pixel3-button": "0.0.11",
17
+ "@mekari/pixel3-icon": "0.0.11",
18
+ "@mekari/pixel3-styled-system": "0.0.9",
19
19
  "@mekari/pixel3-utils": "0.0.6"
20
20
  },
21
21
  "peerDependencies": {
File without changes