@x-plat/design-system 0.11.0 → 0.13.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 (63) hide show
  1. package/dist/components/AutoResizeTextArea/index.cjs +2 -2
  2. package/dist/components/AutoResizeTextArea/index.js +2 -2
  3. package/dist/components/ChatInput/index.cjs +2 -2
  4. package/dist/components/ChatInput/index.js +2 -2
  5. package/dist/components/CheckBox/index.cjs +2 -2
  6. package/dist/components/CheckBox/index.js +2 -2
  7. package/dist/components/DatePicker/index.cjs +109 -75
  8. package/dist/components/DatePicker/index.d.cts +19 -0
  9. package/dist/components/DatePicker/index.d.ts +19 -0
  10. package/dist/components/DatePicker/index.js +109 -75
  11. package/dist/components/Dropdown/index.cjs +22 -9
  12. package/dist/components/Dropdown/index.css +3 -0
  13. package/dist/components/Dropdown/index.js +22 -9
  14. package/dist/components/Editor/index.cjs +602 -30
  15. package/dist/components/Editor/index.css +103 -0
  16. package/dist/components/Editor/index.d.cts +1 -1
  17. package/dist/components/Editor/index.d.ts +1 -1
  18. package/dist/components/Editor/index.js +602 -30
  19. package/dist/components/FieldMessage/index.cjs +2 -2
  20. package/dist/components/FieldMessage/index.d.cts +8 -0
  21. package/dist/components/FieldMessage/index.d.ts +8 -0
  22. package/dist/components/FieldMessage/index.js +2 -2
  23. package/dist/components/FileUpload/index.cjs +10 -6
  24. package/dist/components/FileUpload/index.d.cts +15 -2
  25. package/dist/components/FileUpload/index.d.ts +15 -2
  26. package/dist/components/FileUpload/index.js +10 -6
  27. package/dist/components/ImageSelector/index.cjs +7 -6
  28. package/dist/components/ImageSelector/index.d.cts +15 -2
  29. package/dist/components/ImageSelector/index.d.ts +15 -2
  30. package/dist/components/ImageSelector/index.js +7 -6
  31. package/dist/components/Input/index.cjs +2 -2
  32. package/dist/components/Input/index.d.cts +4 -0
  33. package/dist/components/Input/index.d.ts +4 -0
  34. package/dist/components/Input/index.js +2 -2
  35. package/dist/components/PopOver/index.cjs +21 -7
  36. package/dist/components/PopOver/index.css +3 -0
  37. package/dist/components/PopOver/index.js +21 -7
  38. package/dist/components/Radio/index.cjs +2 -2
  39. package/dist/components/Radio/index.js +2 -2
  40. package/dist/components/Select/index.cjs +23 -10
  41. package/dist/components/Select/index.css +3 -0
  42. package/dist/components/Select/index.d.cts +1 -2
  43. package/dist/components/Select/index.d.ts +1 -2
  44. package/dist/components/Select/index.js +23 -10
  45. package/dist/components/Switch/index.cjs +2 -2
  46. package/dist/components/Switch/index.js +2 -2
  47. package/dist/components/TextArea/index.cjs +2 -2
  48. package/dist/components/TextArea/index.js +2 -2
  49. package/dist/components/TimePicker/index.cjs +23 -10
  50. package/dist/components/TimePicker/index.css +3 -0
  51. package/dist/components/TimePicker/index.js +23 -10
  52. package/dist/components/index.cjs +751 -124
  53. package/dist/components/index.css +113 -0
  54. package/dist/components/index.js +751 -124
  55. package/dist/index.cjs +751 -124
  56. package/dist/index.css +113 -0
  57. package/dist/index.js +751 -124
  58. package/guidelines/Guidelines.md +12 -0
  59. package/guidelines/MIGRATION.md +270 -0
  60. package/guidelines/components/datepicker.md +26 -0
  61. package/guidelines/components/editor.md +58 -3
  62. package/guidelines/components/file-media.md +21 -4
  63. package/package.json +1 -1
@@ -52,8 +52,10 @@ var import_react = __toESM(require("react"), 1);
52
52
  var useAutoPosition = (triggerRef, popRef, enabled = true) => {
53
53
  const [position, setPosition] = import_react.default.useState({
54
54
  position: {},
55
- direction: "bottom"
55
+ direction: "bottom",
56
+ repositioning: false
56
57
  });
58
+ const placedRef = import_react.default.useRef(false);
57
59
  const calculatePosition = import_react.default.useCallback(() => {
58
60
  if (!triggerRef.current || !popRef.current) return;
59
61
  const triggerRect = triggerRef.current.getBoundingClientRect();
@@ -78,11 +80,16 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
78
80
  if (left < 8) left = 8;
79
81
  setPosition({
80
82
  position: { top, left },
81
- direction
83
+ direction,
84
+ repositioning: placedRef.current
82
85
  });
86
+ placedRef.current = true;
83
87
  }, [triggerRef, popRef]);
84
88
  import_react.default.useLayoutEffect(() => {
85
- if (!enabled) return;
89
+ if (!enabled) {
90
+ placedRef.current = false;
91
+ return;
92
+ }
86
93
  calculatePosition();
87
94
  const raf = requestAnimationFrame(calculatePosition);
88
95
  return () => cancelAnimationFrame(raf);
@@ -97,11 +104,17 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
97
104
  }, [calculatePosition, enabled, popRef]);
98
105
  import_react.default.useEffect(() => {
99
106
  if (!enabled) return;
100
- window.addEventListener("resize", calculatePosition);
101
- window.addEventListener("scroll", calculatePosition, true);
107
+ let raf = 0;
108
+ const onScrollOrResize = () => {
109
+ cancelAnimationFrame(raf);
110
+ raf = requestAnimationFrame(calculatePosition);
111
+ };
112
+ window.addEventListener("resize", onScrollOrResize, { passive: true });
113
+ window.addEventListener("scroll", onScrollOrResize, { passive: true, capture: true });
102
114
  return () => {
103
- window.removeEventListener("resize", calculatePosition);
104
- window.removeEventListener("scroll", calculatePosition, true);
115
+ cancelAnimationFrame(raf);
116
+ window.removeEventListener("resize", onScrollOrResize);
117
+ window.removeEventListener("scroll", onScrollOrResize, true);
105
118
  };
106
119
  }, [calculatePosition, enabled]);
107
120
  return position;
@@ -1187,11 +1200,11 @@ var FieldMessage = (props) => {
1187
1200
  };
1188
1201
  FieldMessage.displayName = "FieldMessage";
1189
1202
  var Field = (props) => {
1190
- const { label, required = false, htmlFor, validations, children } = props;
1203
+ const { label, required = false, htmlFor, labelId, validations, children } = props;
1191
1204
  const hasMessages = !!validations && validations.length > 0;
1192
1205
  if (!label && !hasMessages) return /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(import_jsx_runtime295.Fragment, { children });
1193
1206
  return /* @__PURE__ */ (0, import_jsx_runtime295.jsxs)("div", { className: "lib-xplat-field", children: [
1194
- label && /* @__PURE__ */ (0, import_jsx_runtime295.jsxs)("label", { className: "lib-xplat-field-label", htmlFor, children: [
1207
+ label && /* @__PURE__ */ (0, import_jsx_runtime295.jsxs)("label", { className: "lib-xplat-field-label", id: labelId, htmlFor, children: [
1195
1208
  label,
1196
1209
  required && /* @__PURE__ */ (0, import_jsx_runtime295.jsx)("span", { className: "required", "aria-hidden": "true", children: "*" })
1197
1210
  ] }),
@@ -1409,7 +1422,7 @@ var SelectRoot = (props) => {
1409
1422
  mounted && /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime297.jsxs)(
1410
1423
  "div",
1411
1424
  {
1412
- className: clsx_default("lib-xplat-select-content", size, position.direction, stateClass),
1425
+ className: clsx_default("lib-xplat-select-content", size, position.direction, stateClass, position.repositioning && "repositioning"),
1413
1426
  ref: contentRef,
1414
1427
  style: { ...position.position, width: triggerRef.current?.offsetWidth },
1415
1428
  role: "listbox",
@@ -273,3 +273,6 @@
273
273
  cursor: not-allowed;
274
274
  color: var(--semantic-text-disabled);
275
275
  }
276
+ .lib-xplat-select-content.repositioning {
277
+ transition: none;
278
+ }
@@ -34,10 +34,8 @@ interface SelectProps {
34
34
  children: SelectItemElement | SelectItemElement[];
35
35
  /** 비활성화 상태 */
36
36
  disabled?: boolean;
37
- /** 에러 상태 */
38
37
  /** 컨트롤 아래에 표시할 검증 메시지. DS 폼 컴포넌트 공통 */
39
38
  validations?: Validation[];
40
- /** 메시지 없이 테두리만 붉게 한다. validations 와 함께 쓰면 둘 중 하나만 참이어도 적용된다 */
41
39
  /** 컨트롤 위에 붙는 라벨. 클릭하면 컨트롤에 포커스가 간다 */
42
40
  label?: React.ReactNode;
43
41
  /** 라벨 뒤에 필수 표시(*)를 붙인다 */
@@ -49,6 +47,7 @@ interface SelectProps {
49
47
  searchable?: boolean;
50
48
  /** 검색칸 안내 문구 */
51
49
  searchPlaceholder?: string;
50
+ /** 메시지 없이 테두리만 붉게 한다. validations 와 함께 쓰면 둘 중 하나만 참이어도 적용된다 */
52
51
  error?: boolean;
53
52
  /** 사이즈 */
54
53
  size?: SelectSize;
@@ -34,10 +34,8 @@ interface SelectProps {
34
34
  children: SelectItemElement | SelectItemElement[];
35
35
  /** 비활성화 상태 */
36
36
  disabled?: boolean;
37
- /** 에러 상태 */
38
37
  /** 컨트롤 아래에 표시할 검증 메시지. DS 폼 컴포넌트 공통 */
39
38
  validations?: Validation[];
40
- /** 메시지 없이 테두리만 붉게 한다. validations 와 함께 쓰면 둘 중 하나만 참이어도 적용된다 */
41
39
  /** 컨트롤 위에 붙는 라벨. 클릭하면 컨트롤에 포커스가 간다 */
42
40
  label?: React.ReactNode;
43
41
  /** 라벨 뒤에 필수 표시(*)를 붙인다 */
@@ -49,6 +47,7 @@ interface SelectProps {
49
47
  searchable?: boolean;
50
48
  /** 검색칸 안내 문구 */
51
49
  searchPlaceholder?: string;
50
+ /** 메시지 없이 테두리만 붉게 한다. validations 와 함께 쓰면 둘 중 하나만 참이어도 적용된다 */
52
51
  error?: boolean;
53
52
  /** 사이즈 */
54
53
  size?: SelectSize;
@@ -15,8 +15,10 @@ import React from "react";
15
15
  var useAutoPosition = (triggerRef, popRef, enabled = true) => {
16
16
  const [position, setPosition] = React.useState({
17
17
  position: {},
18
- direction: "bottom"
18
+ direction: "bottom",
19
+ repositioning: false
19
20
  });
21
+ const placedRef = React.useRef(false);
20
22
  const calculatePosition = React.useCallback(() => {
21
23
  if (!triggerRef.current || !popRef.current) return;
22
24
  const triggerRect = triggerRef.current.getBoundingClientRect();
@@ -41,11 +43,16 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
41
43
  if (left < 8) left = 8;
42
44
  setPosition({
43
45
  position: { top, left },
44
- direction
46
+ direction,
47
+ repositioning: placedRef.current
45
48
  });
49
+ placedRef.current = true;
46
50
  }, [triggerRef, popRef]);
47
51
  React.useLayoutEffect(() => {
48
- if (!enabled) return;
52
+ if (!enabled) {
53
+ placedRef.current = false;
54
+ return;
55
+ }
49
56
  calculatePosition();
50
57
  const raf = requestAnimationFrame(calculatePosition);
51
58
  return () => cancelAnimationFrame(raf);
@@ -60,11 +67,17 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
60
67
  }, [calculatePosition, enabled, popRef]);
61
68
  React.useEffect(() => {
62
69
  if (!enabled) return;
63
- window.addEventListener("resize", calculatePosition);
64
- window.addEventListener("scroll", calculatePosition, true);
70
+ let raf = 0;
71
+ const onScrollOrResize = () => {
72
+ cancelAnimationFrame(raf);
73
+ raf = requestAnimationFrame(calculatePosition);
74
+ };
75
+ window.addEventListener("resize", onScrollOrResize, { passive: true });
76
+ window.addEventListener("scroll", onScrollOrResize, { passive: true, capture: true });
65
77
  return () => {
66
- window.removeEventListener("resize", calculatePosition);
67
- window.removeEventListener("scroll", calculatePosition, true);
78
+ cancelAnimationFrame(raf);
79
+ window.removeEventListener("resize", onScrollOrResize);
80
+ window.removeEventListener("scroll", onScrollOrResize, true);
68
81
  };
69
82
  }, [calculatePosition, enabled]);
70
83
  return position;
@@ -1150,11 +1163,11 @@ var FieldMessage = (props) => {
1150
1163
  };
1151
1164
  FieldMessage.displayName = "FieldMessage";
1152
1165
  var Field = (props) => {
1153
- const { label, required = false, htmlFor, validations, children } = props;
1166
+ const { label, required = false, htmlFor, labelId, validations, children } = props;
1154
1167
  const hasMessages = !!validations && validations.length > 0;
1155
1168
  if (!label && !hasMessages) return /* @__PURE__ */ jsx295(Fragment, { children });
1156
1169
  return /* @__PURE__ */ jsxs189("div", { className: "lib-xplat-field", children: [
1157
- label && /* @__PURE__ */ jsxs189("label", { className: "lib-xplat-field-label", htmlFor, children: [
1170
+ label && /* @__PURE__ */ jsxs189("label", { className: "lib-xplat-field-label", id: labelId, htmlFor, children: [
1158
1171
  label,
1159
1172
  required && /* @__PURE__ */ jsx295("span", { className: "required", "aria-hidden": "true", children: "*" })
1160
1173
  ] }),
@@ -1372,7 +1385,7 @@ var SelectRoot = (props) => {
1372
1385
  mounted && /* @__PURE__ */ jsx297(Portal_default, { children: /* @__PURE__ */ jsxs190(
1373
1386
  "div",
1374
1387
  {
1375
- className: clsx_default("lib-xplat-select-content", size, position.direction, stateClass),
1388
+ className: clsx_default("lib-xplat-select-content", size, position.direction, stateClass, position.repositioning && "repositioning"),
1376
1389
  ref: contentRef,
1377
1390
  style: { ...position.position, width: triggerRef.current?.offsetWidth },
1378
1391
  role: "listbox",
@@ -179,11 +179,11 @@ var FieldMessage = (props) => {
179
179
  };
180
180
  FieldMessage.displayName = "FieldMessage";
181
181
  var Field = (props) => {
182
- const { label, required = false, htmlFor, validations, children } = props;
182
+ const { label, required = false, htmlFor, labelId, validations, children } = props;
183
183
  const hasMessages = !!validations && validations.length > 0;
184
184
  if (!label && !hasMessages) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children });
185
185
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "lib-xplat-field", children: [
186
- label && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "lib-xplat-field-label", htmlFor, children: [
186
+ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "lib-xplat-field-label", id: labelId, htmlFor, children: [
187
187
  label,
188
188
  required && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "required", "aria-hidden": "true", children: "*" })
189
189
  ] }),
@@ -143,11 +143,11 @@ var FieldMessage = (props) => {
143
143
  };
144
144
  FieldMessage.displayName = "FieldMessage";
145
145
  var Field = (props) => {
146
- const { label, required = false, htmlFor, validations, children } = props;
146
+ const { label, required = false, htmlFor, labelId, validations, children } = props;
147
147
  const hasMessages = !!validations && validations.length > 0;
148
148
  if (!label && !hasMessages) return /* @__PURE__ */ jsx4(Fragment, { children });
149
149
  return /* @__PURE__ */ jsxs3("div", { className: "lib-xplat-field", children: [
150
- label && /* @__PURE__ */ jsxs3("label", { className: "lib-xplat-field-label", htmlFor, children: [
150
+ label && /* @__PURE__ */ jsxs3("label", { className: "lib-xplat-field-label", id: labelId, htmlFor, children: [
151
151
  label,
152
152
  required && /* @__PURE__ */ jsx4("span", { className: "required", "aria-hidden": "true", children: "*" })
153
153
  ] }),
@@ -176,11 +176,11 @@ var FieldMessage = (props) => {
176
176
  };
177
177
  FieldMessage.displayName = "FieldMessage";
178
178
  var Field = (props) => {
179
- const { label, required = false, htmlFor, validations, children } = props;
179
+ const { label, required = false, htmlFor, labelId, validations, children } = props;
180
180
  const hasMessages = !!validations && validations.length > 0;
181
181
  if (!label && !hasMessages) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children });
182
182
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "lib-xplat-field", children: [
183
- label && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "lib-xplat-field-label", htmlFor, children: [
183
+ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "lib-xplat-field-label", id: labelId, htmlFor, children: [
184
184
  label,
185
185
  required && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "required", "aria-hidden": "true", children: "*" })
186
186
  ] }),
@@ -140,11 +140,11 @@ var FieldMessage = (props) => {
140
140
  };
141
141
  FieldMessage.displayName = "FieldMessage";
142
142
  var Field = (props) => {
143
- const { label, required = false, htmlFor, validations, children } = props;
143
+ const { label, required = false, htmlFor, labelId, validations, children } = props;
144
144
  const hasMessages = !!validations && validations.length > 0;
145
145
  if (!label && !hasMessages) return /* @__PURE__ */ jsx4(Fragment, { children });
146
146
  return /* @__PURE__ */ jsxs3("div", { className: "lib-xplat-field", children: [
147
- label && /* @__PURE__ */ jsxs3("label", { className: "lib-xplat-field-label", htmlFor, children: [
147
+ label && /* @__PURE__ */ jsxs3("label", { className: "lib-xplat-field-label", id: labelId, htmlFor, children: [
148
148
  label,
149
149
  required && /* @__PURE__ */ jsx4("span", { className: "required", "aria-hidden": "true", children: "*" })
150
150
  ] }),
@@ -51,8 +51,10 @@ var import_react = __toESM(require("react"), 1);
51
51
  var useAutoPosition = (triggerRef, popRef, enabled = true) => {
52
52
  const [position, setPosition] = import_react.default.useState({
53
53
  position: {},
54
- direction: "bottom"
54
+ direction: "bottom",
55
+ repositioning: false
55
56
  });
57
+ const placedRef = import_react.default.useRef(false);
56
58
  const calculatePosition = import_react.default.useCallback(() => {
57
59
  if (!triggerRef.current || !popRef.current) return;
58
60
  const triggerRect = triggerRef.current.getBoundingClientRect();
@@ -77,11 +79,16 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
77
79
  if (left < 8) left = 8;
78
80
  setPosition({
79
81
  position: { top, left },
80
- direction
82
+ direction,
83
+ repositioning: placedRef.current
81
84
  });
85
+ placedRef.current = true;
82
86
  }, [triggerRef, popRef]);
83
87
  import_react.default.useLayoutEffect(() => {
84
- if (!enabled) return;
88
+ if (!enabled) {
89
+ placedRef.current = false;
90
+ return;
91
+ }
85
92
  calculatePosition();
86
93
  const raf = requestAnimationFrame(calculatePosition);
87
94
  return () => cancelAnimationFrame(raf);
@@ -96,11 +103,17 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
96
103
  }, [calculatePosition, enabled, popRef]);
97
104
  import_react.default.useEffect(() => {
98
105
  if (!enabled) return;
99
- window.addEventListener("resize", calculatePosition);
100
- window.addEventListener("scroll", calculatePosition, true);
106
+ let raf = 0;
107
+ const onScrollOrResize = () => {
108
+ cancelAnimationFrame(raf);
109
+ raf = requestAnimationFrame(calculatePosition);
110
+ };
111
+ window.addEventListener("resize", onScrollOrResize, { passive: true });
112
+ window.addEventListener("scroll", onScrollOrResize, { passive: true, capture: true });
101
113
  return () => {
102
- window.removeEventListener("resize", calculatePosition);
103
- window.removeEventListener("scroll", calculatePosition, true);
114
+ cancelAnimationFrame(raf);
115
+ window.removeEventListener("resize", onScrollOrResize);
116
+ window.removeEventListener("scroll", onScrollOrResize, true);
104
117
  };
105
118
  }, [calculatePosition, enabled]);
106
119
  return position;
@@ -295,11 +308,11 @@ var FieldMessage = (props) => {
295
308
  };
296
309
  FieldMessage.displayName = "FieldMessage";
297
310
  var Field = (props) => {
298
- const { label, required = false, htmlFor, validations, children } = props;
311
+ const { label, required = false, htmlFor, labelId, validations, children } = props;
299
312
  const hasMessages = !!validations && validations.length > 0;
300
313
  if (!label && !hasMessages) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children });
301
314
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "lib-xplat-field", children: [
302
- label && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "lib-xplat-field-label", htmlFor, children: [
315
+ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "lib-xplat-field-label", id: labelId, htmlFor, children: [
303
316
  label,
304
317
  required && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "required", "aria-hidden": "true", children: "*" })
305
318
  ] }),
@@ -414,7 +427,7 @@ var TimePicker = (props) => {
414
427
  "div",
415
428
  {
416
429
  ref: contentRef,
417
- className: clsx_default("lib-xplat-time-picker-content", size, visible ? "enter" : "exit"),
430
+ className: clsx_default("lib-xplat-time-picker-content", size, visible ? "enter" : "exit", position.repositioning && "repositioning"),
418
431
  style: { ...position.position, width: triggerRef.current?.offsetWidth },
419
432
  role: "listbox",
420
433
  children: options.map((t) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
@@ -170,3 +170,6 @@
170
170
  font-weight: var(--semantic-typo-label-1-m-weight);
171
171
  letter-spacing: var(--semantic-typo-label-1-m-ls);
172
172
  }
173
+ .lib-xplat-time-picker-content.repositioning {
174
+ transition: none;
175
+ }
@@ -15,8 +15,10 @@ import React from "react";
15
15
  var useAutoPosition = (triggerRef, popRef, enabled = true) => {
16
16
  const [position, setPosition] = React.useState({
17
17
  position: {},
18
- direction: "bottom"
18
+ direction: "bottom",
19
+ repositioning: false
19
20
  });
21
+ const placedRef = React.useRef(false);
20
22
  const calculatePosition = React.useCallback(() => {
21
23
  if (!triggerRef.current || !popRef.current) return;
22
24
  const triggerRect = triggerRef.current.getBoundingClientRect();
@@ -41,11 +43,16 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
41
43
  if (left < 8) left = 8;
42
44
  setPosition({
43
45
  position: { top, left },
44
- direction
46
+ direction,
47
+ repositioning: placedRef.current
45
48
  });
49
+ placedRef.current = true;
46
50
  }, [triggerRef, popRef]);
47
51
  React.useLayoutEffect(() => {
48
- if (!enabled) return;
52
+ if (!enabled) {
53
+ placedRef.current = false;
54
+ return;
55
+ }
49
56
  calculatePosition();
50
57
  const raf = requestAnimationFrame(calculatePosition);
51
58
  return () => cancelAnimationFrame(raf);
@@ -60,11 +67,17 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
60
67
  }, [calculatePosition, enabled, popRef]);
61
68
  React.useEffect(() => {
62
69
  if (!enabled) return;
63
- window.addEventListener("resize", calculatePosition);
64
- window.addEventListener("scroll", calculatePosition, true);
70
+ let raf = 0;
71
+ const onScrollOrResize = () => {
72
+ cancelAnimationFrame(raf);
73
+ raf = requestAnimationFrame(calculatePosition);
74
+ };
75
+ window.addEventListener("resize", onScrollOrResize, { passive: true });
76
+ window.addEventListener("scroll", onScrollOrResize, { passive: true, capture: true });
65
77
  return () => {
66
- window.removeEventListener("resize", calculatePosition);
67
- window.removeEventListener("scroll", calculatePosition, true);
78
+ cancelAnimationFrame(raf);
79
+ window.removeEventListener("resize", onScrollOrResize);
80
+ window.removeEventListener("scroll", onScrollOrResize, true);
68
81
  };
69
82
  }, [calculatePosition, enabled]);
70
83
  return position;
@@ -259,11 +272,11 @@ var FieldMessage = (props) => {
259
272
  };
260
273
  FieldMessage.displayName = "FieldMessage";
261
274
  var Field = (props) => {
262
- const { label, required = false, htmlFor, validations, children } = props;
275
+ const { label, required = false, htmlFor, labelId, validations, children } = props;
263
276
  const hasMessages = !!validations && validations.length > 0;
264
277
  if (!label && !hasMessages) return /* @__PURE__ */ jsx4(Fragment, { children });
265
278
  return /* @__PURE__ */ jsxs3("div", { className: "lib-xplat-field", children: [
266
- label && /* @__PURE__ */ jsxs3("label", { className: "lib-xplat-field-label", htmlFor, children: [
279
+ label && /* @__PURE__ */ jsxs3("label", { className: "lib-xplat-field-label", id: labelId, htmlFor, children: [
267
280
  label,
268
281
  required && /* @__PURE__ */ jsx4("span", { className: "required", "aria-hidden": "true", children: "*" })
269
282
  ] }),
@@ -378,7 +391,7 @@ var TimePicker = (props) => {
378
391
  "div",
379
392
  {
380
393
  ref: contentRef,
381
- className: clsx_default("lib-xplat-time-picker-content", size, visible ? "enter" : "exit"),
394
+ className: clsx_default("lib-xplat-time-picker-content", size, visible ? "enter" : "exit", position.repositioning && "repositioning"),
382
395
  style: { ...position.position, width: triggerRef.current?.offsetWidth },
383
396
  role: "listbox",
384
397
  children: options.map((t) => /* @__PURE__ */ jsx5(