motile-ui 1.2.0 → 1.2.1

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.
@@ -1 +1 @@
1
- .motile-timepicker{display:flex;position:relative;user-select:none;-webkit-user-select:none;overflow:hidden}.motile-timepicker--disabled{pointer-events:none}.motile-timepicker--full-width{width:100%}.motile-timepicker__column{flex:1;overflow-y:scroll;overflow-x:hidden;scroll-snap-type:none;scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;touch-action:pan-y;cursor:grab}@media (hover: none) and (pointer: coarse){.motile-timepicker__column{scroll-snap-type:y mandatory;cursor:default}}.motile-timepicker__column::-webkit-scrollbar{display:none}.motile-timepicker__item{display:flex;align-items:center;justify-content:center;scroll-snap-align:center;font-variant-numeric:tabular-nums;color:#d1d5db}.motile-timepicker__item--selected{color:inherit}.motile-timepicker__spacer{flex-shrink:0;pointer-events:none}.motile-timepicker__highlight{position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);pointer-events:none;background-color:#0000000d;border-radius:8px}@media (prefers-reduced-motion: reduce){.motile-timepicker__column{scroll-behavior:auto}}
1
+ .motile-timepicker{display:flex;position:relative;user-select:none;-webkit-user-select:none;overflow:hidden;width:200px;height:120px}.motile-timepicker--disabled{pointer-events:none}.motile-timepicker__column{flex:1;overflow-y:scroll;overflow-x:hidden;scroll-snap-type:none;scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;touch-action:pan-y;cursor:grab}@media (hover: none) and (pointer: coarse){.motile-timepicker__column{scroll-snap-type:y mandatory;cursor:default}}.motile-timepicker__column::-webkit-scrollbar{display:none}.motile-timepicker__item{display:flex;align-items:center;justify-content:center;scroll-snap-align:center;font-variant-numeric:tabular-nums;color:#d1d5db}.motile-timepicker__item--selected{color:inherit}.motile-timepicker__spacer{flex-shrink:0;pointer-events:none}.motile-timepicker__highlight{position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);pointer-events:none;background-color:#0000000d;border-radius:8px;z-index:0}.motile-timepicker__column{position:relative;z-index:1}@media (prefers-reduced-motion: reduce){.motile-timepicker__column{scroll-behavior:auto}}
@@ -15,7 +15,6 @@ export interface TimePickerRootProps extends Omit<React.HTMLAttributes<HTMLDivEl
15
15
  minuteStep?: MinuteStep;
16
16
  disabled?: boolean;
17
17
  itemHeight?: number;
18
- fullWidth?: boolean;
19
18
  children: React.ReactNode;
20
19
  }
21
20
  export declare const TimePickerRoot: React.ForwardRefExoticComponent<TimePickerRootProps & React.RefAttributes<HTMLDivElement>>;
@@ -11,188 +11,187 @@ const W = ee(null), q = () => {
11
11
  }, z = U(
12
12
  ({
13
13
  value: t,
14
- defaultValue: w,
14
+ defaultValue: R,
15
15
  onChange: v,
16
- format: l = "12",
17
- minuteStep: a = 5,
16
+ format: s = "12",
17
+ minuteStep: l = 5,
18
18
  disabled: p = !1,
19
- itemHeight: n = 40,
20
- fullWidth: g = !1,
21
- children: $,
19
+ itemHeight: o = 40,
20
+ children: g,
22
21
  className: D,
23
22
  style: I,
24
- ...m
25
- }, M) => {
26
- const [P, E] = Z(() => t || w || {
27
- hour: l === "12" ? 12 : 0,
23
+ ...$
24
+ }, a) => {
25
+ const [x, w] = Z(() => t || R || {
26
+ hour: s === "12" ? 12 : 0,
28
27
  minute: 0,
29
- period: l === "12" ? "AM" : void 0
30
- }), k = t !== void 0, b = k ? t : P, L = O(() => l === "12" ? Array.from({ length: 12 }, (x, u) => u + 1) : Array.from({ length: 24 }, (x, u) => u), [l]), _ = O(() => {
31
- const x = 60 / a;
32
- return Array.from({ length: x }, (u, s) => s * a);
33
- }, [a]), V = O(() => ["AM", "PM"], []), A = T(
34
- (x, u) => {
35
- const s = { ...b };
36
- x === "hour" ? s.hour = u : x === "minute" ? s.minute = u : s.period = u, k || E(s), v == null || v(s);
28
+ period: s === "12" ? "AM" : void 0
29
+ }), M = t !== void 0, k = M ? t : x, E = O(() => s === "12" ? Array.from({ length: 12 }, (n, h) => h + 1) : Array.from({ length: 24 }, (n, h) => h), [s]), L = O(() => {
30
+ const n = 60 / l;
31
+ return Array.from({ length: n }, (h, u) => u * l);
32
+ }, [l]), b = O(() => ["AM", "PM"], []), V = T(
33
+ (n, h) => {
34
+ const u = { ...k };
35
+ n === "hour" ? u.hour = h : n === "minute" ? u.minute = h : u.period = h, M || w(u), v == null || v(u);
37
36
  },
38
- [b, k, v]
39
- ), o = {
40
- value: b,
41
- format: l,
42
- minuteStep: a,
37
+ [k, M, v]
38
+ ), A = {
39
+ value: k,
40
+ format: s,
41
+ minuteStep: l,
43
42
  disabled: p,
44
- itemHeight: n,
45
- updateValue: A,
46
- hourOptions: L,
47
- minuteOptions: _,
48
- periodOptions: V
49
- }, c = {
50
- "--timepicker-item-height": `${n}px`,
43
+ itemHeight: o,
44
+ updateValue: V,
45
+ hourOptions: E,
46
+ minuteOptions: L,
47
+ periodOptions: b
48
+ }, i = {
49
+ "--timepicker-item-height": `${o}px`,
51
50
  ...I
52
51
  };
53
- return /* @__PURE__ */ S(W.Provider, { value: o, children: /* @__PURE__ */ S(
52
+ return /* @__PURE__ */ S(W.Provider, { value: A, children: /* @__PURE__ */ S(
54
53
  "div",
55
54
  {
56
- ref: M,
57
- className: `motile-timepicker ${p ? "motile-timepicker--disabled" : ""} ${g ? "motile-timepicker--full-width" : ""} ${D || ""}`,
58
- style: c,
55
+ ref: a,
56
+ className: `motile-timepicker ${p ? "motile-timepicker--disabled" : ""} ${D || ""}`,
57
+ style: i,
59
58
  "aria-disabled": p,
60
59
  role: "group",
61
60
  "aria-label": "시간 선택",
62
- ...m,
63
- children: $
61
+ ...$,
62
+ children: g
64
63
  }
65
64
  ) });
66
65
  }
67
66
  );
68
67
  z.displayName = "TimePicker.Root";
69
- const B = U(({ type: t, className: w, ...v }, l) => {
68
+ const B = U(({ type: t, className: R, ...v }, s) => {
70
69
  const {
71
- value: a,
70
+ value: l,
72
71
  disabled: p,
73
- itemHeight: n,
72
+ itemHeight: o,
74
73
  updateValue: g,
75
- hourOptions: $,
76
- minuteOptions: D,
77
- periodOptions: I
78
- } = q(), m = f(null), M = f(null), P = f(!1), E = f(!1), k = f(0), b = f(null), L = f(!0), _ = f(!1), V = f(0), A = f(0), o = O(() => {
74
+ hourOptions: D,
75
+ minuteOptions: I,
76
+ periodOptions: $
77
+ } = q(), a = f(null), x = f(null), w = f(!1), M = f(!1), k = f(0), E = f(null), L = f(!0), b = f(!1), V = f(0), A = f(0), i = O(() => {
79
78
  switch (t) {
80
79
  case "hour":
81
- return $;
82
- case "minute":
83
80
  return D;
84
- case "period":
81
+ case "minute":
85
82
  return I;
83
+ case "period":
84
+ return $;
86
85
  default:
87
86
  return [];
88
87
  }
89
- }, [t, $, D, I]), c = O(() => {
88
+ }, [t, D, I, $]), n = O(() => {
90
89
  switch (t) {
91
90
  case "hour":
92
- return a.hour;
91
+ return l.hour;
93
92
  case "minute":
94
- return a.minute;
93
+ return l.minute;
95
94
  case "period":
96
- return a.period;
95
+ return l.period;
97
96
  default:
98
97
  return;
99
98
  }
100
- }, [t, a]), x = T(
99
+ }, [t, l]), h = T(
101
100
  (e) => t === "period" ? e : e.toString().padStart(2, "0"),
102
101
  [t]
103
102
  ), u = T(
104
103
  (e, r = !0) => {
105
- const i = m.current;
106
- if (!i || e === void 0) return;
107
- const d = o.indexOf(e);
108
- if (d === -1) return;
109
- const R = d * n;
110
- i.scrollTo({
111
- top: R,
104
+ const c = a.current;
105
+ if (!c || e === void 0) return;
106
+ const m = i.indexOf(e);
107
+ if (m === -1) return;
108
+ const _ = m * o;
109
+ c.scrollTo({
110
+ top: _,
112
111
  behavior: r ? "smooth" : "auto"
113
112
  });
114
113
  },
115
- [o, n]
116
- ), s = T(() => typeof window < "u" && window.matchMedia("(hover: none) and (pointer: coarse)").matches, []), Y = T(
114
+ [i, o]
115
+ ), P = T(() => typeof window < "u" && window.matchMedia("(hover: none) and (pointer: coarse)").matches, []), Y = T(
117
116
  (e) => {
118
- if (s()) return;
117
+ if (P()) return;
119
118
  e.preventDefault();
120
- const r = m.current;
121
- r && (k.current += e.deltaY, b.current && clearTimeout(b.current), E.current = !0, b.current = setTimeout(() => {
122
- const i = k.current, d = 20, R = 80;
123
- let h = 0;
124
- if (Math.abs(i) >= d && (h = Math.sign(i) * Math.max(1, Math.round(Math.abs(i) / R))), h !== 0) {
125
- const H = o.indexOf(c), j = Math.max(
119
+ const r = a.current;
120
+ r && (k.current += e.deltaY, E.current && clearTimeout(E.current), M.current = !0, E.current = setTimeout(() => {
121
+ const c = k.current, m = 20, _ = 80;
122
+ let d = 0;
123
+ if (Math.abs(c) >= m && (d = Math.sign(c) * Math.max(1, Math.round(Math.abs(c) / _))), d !== 0) {
124
+ const H = i.indexOf(n), j = Math.max(
126
125
  0,
127
- Math.min(H + h, o.length - 1)
126
+ Math.min(H + d, i.length - 1)
128
127
  );
129
128
  if (j !== H) {
130
- const K = o[j], Q = j * n;
129
+ const K = i[j], Q = j * o;
131
130
  r.scrollTo({ top: Q, behavior: "smooth" }), g(t, K);
132
131
  }
133
132
  }
134
133
  k.current = 0, setTimeout(() => {
135
- E.current = !1;
134
+ M.current = !1;
136
135
  }, 150);
137
136
  }, 50));
138
137
  },
139
- [o, n, c, g, t, s]
138
+ [i, o, n, g, t, P]
140
139
  ), G = T(
141
140
  (e) => {
142
- if (s() || p) return;
143
- const r = m.current;
144
- r && (_.current = !0, V.current = e.clientY, A.current = r.scrollTop, r.style.cursor = "grabbing", e.preventDefault());
141
+ if (P() || p) return;
142
+ const r = a.current;
143
+ r && (b.current = !0, V.current = e.clientY, A.current = r.scrollTop, r.style.cursor = "grabbing", e.preventDefault());
145
144
  },
146
- [s, p]
145
+ [P, p]
147
146
  ), y = T((e) => {
148
- if (!_.current) return;
149
- const r = m.current;
147
+ if (!b.current) return;
148
+ const r = a.current;
150
149
  if (!r) return;
151
- const i = V.current - e.clientY;
152
- r.scrollTop = A.current + i;
150
+ const c = V.current - e.clientY;
151
+ r.scrollTop = A.current + c;
153
152
  }, []), C = T(() => {
154
- if (!_.current) return;
155
- _.current = !1;
156
- const e = m.current;
153
+ if (!b.current) return;
154
+ b.current = !1;
155
+ const e = a.current;
157
156
  if (!e) return;
158
157
  e.style.cursor = "grab";
159
- const r = e.scrollTop, i = Math.round(r / n), d = Math.max(0, Math.min(i, o.length - 1)), R = d * n;
160
- e.scrollTo({ top: R, behavior: "smooth" });
161
- const h = o[d];
162
- h !== void 0 && h !== c && g(t, h);
163
- }, [o, n, c, g, t]), J = T(() => {
164
- if (E.current || _.current) return;
165
- M.current && clearTimeout(M.current);
166
- const e = s() ? 50 : 100;
167
- M.current = setTimeout(() => {
168
- const r = m.current;
158
+ const r = e.scrollTop, c = Math.round(r / o), m = Math.max(0, Math.min(c, i.length - 1)), _ = m * o;
159
+ e.scrollTo({ top: _, behavior: "smooth" });
160
+ const d = i[m];
161
+ d !== void 0 && d !== n && g(t, d);
162
+ }, [i, o, n, g, t]), J = T(() => {
163
+ if (M.current || b.current) return;
164
+ x.current && clearTimeout(x.current);
165
+ const e = P() ? 50 : 100;
166
+ x.current = setTimeout(() => {
167
+ const r = a.current;
169
168
  if (!r) return;
170
- if (P.current) {
171
- P.current = !1;
169
+ if (w.current) {
170
+ w.current = !1;
172
171
  return;
173
172
  }
174
- const i = r.scrollTop, d = Math.round(i / n), R = Math.max(0, Math.min(d, o.length - 1)), h = o[R];
175
- h !== void 0 && h !== c && g(t, h);
173
+ const c = r.scrollTop, m = Math.round(c / o), _ = Math.max(0, Math.min(m, i.length - 1)), d = i[_];
174
+ d !== void 0 && d !== n && g(t, d);
176
175
  }, e);
177
- }, [o, n, c, g, t, s]);
176
+ }, [i, o, n, g, t, P]);
178
177
  return N(() => {
179
178
  if (!L.current) return;
180
179
  L.current = !1;
181
180
  const e = setTimeout(() => {
182
- u(c, !1);
181
+ u(n, !1);
183
182
  }, 0);
184
183
  return () => clearTimeout(e);
185
- }, [u, c]), N(() => {
186
- const e = m.current;
187
- if (!e || c === void 0) return;
188
- const r = o.indexOf(c);
184
+ }, [u, n]), N(() => {
185
+ const e = a.current;
186
+ if (!e || n === void 0) return;
187
+ const r = i.indexOf(n);
189
188
  if (r === -1) return;
190
- const i = r * n, d = e.scrollTop;
191
- Math.abs(d - i) > 1 && (P.current = !0, u(c, !0), setTimeout(() => {
192
- P.current = !1;
189
+ const c = r * o, m = e.scrollTop;
190
+ Math.abs(m - c) > 1 && (w.current = !0, u(n, !0), setTimeout(() => {
191
+ w.current = !1;
193
192
  }, 200));
194
- }, [c, u, o, n]), N(() => {
195
- const e = m.current;
193
+ }, [n, u, i, o]), N(() => {
194
+ const e = a.current;
196
195
  if (e)
197
196
  return e.addEventListener("wheel", Y, { passive: !1 }), () => {
198
197
  e.removeEventListener("wheel", Y);
@@ -200,14 +199,14 @@ const B = U(({ type: t, className: w, ...v }, l) => {
200
199
  }, [Y]), N(() => (document.addEventListener("mousemove", y), document.addEventListener("mouseup", C), () => {
201
200
  document.removeEventListener("mousemove", y), document.removeEventListener("mouseup", C);
202
201
  }), [y, C]), N(() => () => {
203
- M.current !== null && clearTimeout(M.current);
202
+ x.current !== null && clearTimeout(x.current);
204
203
  }, []), /* @__PURE__ */ X(
205
204
  "div",
206
205
  {
207
206
  ref: (e) => {
208
- typeof l == "function" ? l(e) : l && (l.current = e), m.current = e;
207
+ typeof s == "function" ? s(e) : s && (s.current = e), a.current = e;
209
208
  },
210
- className: `motile-timepicker__column ${w || ""}`,
209
+ className: `motile-timepicker__column ${R || ""}`,
211
210
  onScroll: J,
212
211
  onMouseDown: G,
213
212
  role: "listbox",
@@ -219,21 +218,21 @@ const B = U(({ type: t, className: w, ...v }, l) => {
219
218
  "div",
220
219
  {
221
220
  className: "motile-timepicker__spacer",
222
- style: { height: n },
221
+ style: { height: o },
223
222
  "aria-hidden": "true"
224
223
  }
225
224
  ),
226
- o.map((e, r) => {
227
- const i = e === c;
225
+ i.map((e, r) => {
226
+ const c = e === n;
228
227
  return /* @__PURE__ */ S(
229
228
  "div",
230
229
  {
231
- className: `motile-timepicker__item ${i ? "motile-timepicker__item--selected" : ""} ${p ? "motile-timepicker__item--disabled" : ""}`,
232
- style: { height: n },
230
+ className: `motile-timepicker__item ${c ? "motile-timepicker__item--selected" : ""} ${p ? "motile-timepicker__item--disabled" : ""}`,
231
+ style: { height: o },
233
232
  role: "option",
234
- "aria-selected": i,
233
+ "aria-selected": c,
235
234
  "data-value": e,
236
- children: x(e)
235
+ children: h(e)
237
236
  },
238
237
  r
239
238
  );
@@ -242,7 +241,7 @@ const B = U(({ type: t, className: w, ...v }, l) => {
242
241
  "div",
243
242
  {
244
243
  className: "motile-timepicker__spacer",
245
- style: { height: n },
244
+ style: { height: o },
246
245
  "aria-hidden": "true"
247
246
  }
248
247
  )
@@ -251,15 +250,15 @@ const B = U(({ type: t, className: w, ...v }, l) => {
251
250
  );
252
251
  });
253
252
  B.displayName = "TimePicker.Column";
254
- const F = U(({ className: t, style: w, ...v }, l) => {
255
- const { itemHeight: a } = q(), p = {
256
- height: a,
257
- ...w
253
+ const F = U(({ className: t, style: R, ...v }, s) => {
254
+ const { itemHeight: l } = q(), p = {
255
+ height: l,
256
+ ...R
258
257
  };
259
258
  return /* @__PURE__ */ S(
260
259
  "div",
261
260
  {
262
- ref: l,
261
+ ref: s,
263
262
  className: `motile-timepicker__highlight ${t || ""}`,
264
263
  style: p,
265
264
  "aria-hidden": "true",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motile-ui",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "description": "A modern React component library for webview applications",
6
6
  "main": "./dist/index.js",