@qyu/reactcmp-dropdown 1.1.0 → 2.0.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 (84) hide show
  1. package/README.md +173 -69
  2. package/build/bundle/entry/index.js +1268 -385
  3. package/build/declaration/component/button/element/view.d.ts +8 -5
  4. package/build/declaration/component/button/element/virtual.d.ts +9 -0
  5. package/build/declaration/component/container/element/view.d.ts +14 -23
  6. package/build/declaration/component/container/element/virtual.d.ts +13 -0
  7. package/build/declaration/component/content/element/view.d.ts +11 -0
  8. package/build/declaration/component/ctx-state/element/config.d.ts +3 -0
  9. package/build/declaration/component/ctx-state/element/content.d.ts +3 -0
  10. package/build/declaration/component/ctx-state/element/open.d.ts +2 -5
  11. package/build/declaration/component/ctx-state/element/refs.d.ts +3 -0
  12. package/build/declaration/component/ctx-state/hook/init/config.d.ts +8 -0
  13. package/build/declaration/component/ctx-state/hook/init/content.d.ts +6 -0
  14. package/build/declaration/component/ctx-state/hook/init/open.d.ts +7 -0
  15. package/build/declaration/component/ctx-state/hook/init/refs.d.ts +5 -0
  16. package/build/declaration/component/ctx-state/hook/view/config.d.ts +1 -0
  17. package/build/declaration/component/ctx-state/hook/view/content.d.ts +1 -0
  18. package/build/declaration/component/ctx-state/hook/view/open.d.ts +1 -0
  19. package/build/declaration/component/ctx-state/hook/view/refs.d.ts +1 -0
  20. package/build/declaration/component/ctx-state/type/state.d.ts +40 -6
  21. package/build/declaration/component/list-abs/element/view.d.ts +23 -36
  22. package/build/declaration/component/list-fix/element/view.d.ts +24 -36
  23. package/build/declaration/component/list-portal/element/view.d.ts +29 -0
  24. package/build/declaration/hook/closeevt/root.d.ts +8 -0
  25. package/build/declaration/hook/closeevt/root_infer.d.ts +3 -0
  26. package/build/declaration/hook/closeevt/shard.d.ts +9 -0
  27. package/build/declaration/hook/closeevt/shard_infer.d.ts +3 -0
  28. package/build/declaration/hook/ddnparts/list.d.ts +6 -0
  29. package/build/declaration/hook/ddnparts/list_infer.d.ts +3 -0
  30. package/build/declaration/hook/ddnparts/root.d.ts +8 -0
  31. package/build/declaration/hook/ddnparts/root_infer.d.ts +3 -0
  32. package/build/declaration/hook/ddnparts/shard.d.ts +9 -0
  33. package/build/declaration/hook/ddnparts/shard_infer.d.ts +3 -0
  34. package/build/declaration/hook/focus/capture.d.ts +16 -0
  35. package/build/declaration/hook/focus/capture_infer.d.ts +3 -0
  36. package/build/declaration/hook/listpos/api/absolute.d.ts +15 -0
  37. package/build/declaration/hook/listpos/api/fixed.d.ts +18 -0
  38. package/build/declaration/hook/listpos/api/type/api.d.ts +13 -0
  39. package/build/declaration/hook/listpos/api/type/position.d.ts +6 -0
  40. package/build/declaration/hook/listpos/api/type/reverse.d.ts +4 -0
  41. package/build/declaration/hook/listpos/api/type/size.d.ts +4 -0
  42. package/build/declaration/hook/listpos/rearrange/index.d.ts +10 -0
  43. package/build/declaration/hook/listpos/rearrange/type/config.d.ts +7 -0
  44. package/build/declaration/hook/open/view.d.ts +6 -0
  45. package/build/declaration/hook/open/view_infer.d.ts +3 -0
  46. package/build/declaration/hook/ref/merge.d.ts +2 -0
  47. package/build/declaration/hook/ref/o.d.ts +3 -0
  48. package/build/declaration/index.d.ts +58 -3
  49. package/build/declaration/type/fnref.d.ts +4 -0
  50. package/build/declaration/util/clname/merge.d.ts +1 -0
  51. package/build/declaration/util/closeevt/type/config.d.ts +11 -0
  52. package/build/declaration/util/cssprops/new/position.d.ts +3 -0
  53. package/build/declaration/util/cssprops/new/size.d.ts +9 -0
  54. package/build/declaration/util/focus/config/type/config.d.ts +6 -0
  55. package/build/declaration/util/prop/align/new/index.d.ts +2 -0
  56. package/build/declaration/util/prop/align/new/reversed.d.ts +2 -0
  57. package/build/declaration/util/prop/align/type/prop.d.ts +2 -0
  58. package/build/declaration/util/prop/clmap/def/container.d.ts +6 -0
  59. package/build/declaration/util/prop/clmap/def/content.d.ts +8 -0
  60. package/build/declaration/util/prop/clmap/def/listabs.d.ts +15 -0
  61. package/build/declaration/util/prop/clmap/def/listfix.d.ts +16 -0
  62. package/build/declaration/util/prop/clmap/new/index.d.ts +2 -0
  63. package/build/declaration/util/prop/clmap/type/prop.d.ts +4 -0
  64. package/build/declaration/util/prop/direction/new/index.d.ts +2 -0
  65. package/build/declaration/util/prop/direction/type/prop.d.ts +2 -0
  66. package/build/declaration/util/prop/justify/new/index.d.ts +2 -0
  67. package/build/declaration/util/prop/justify/new/reversed.d.ts +2 -0
  68. package/build/declaration/util/prop/justify/type/prop.d.ts +2 -0
  69. package/build/declaration/util/prop/portal/new/index.d.ts +2 -0
  70. package/build/declaration/util/prop/portal/type/prop.d.ts +2 -0
  71. package/build/declaration/util/ref/use.d.ts +2 -0
  72. package/build/style/index.css +132 -0
  73. package/build/style/index.css.d.ts +21 -0
  74. package/package.json +6 -9
  75. package/build/declaration/component/container/hook/useDropdownCloseEvents.d.ts +0 -15
  76. package/build/declaration/type/params.d.ts +0 -6
  77. package/build/declaration/util/cl.d.ts +0 -1
  78. package/build/declaration/util/nprop/index.d.ts +0 -4
  79. package/build/declaration/util/stylemap/new/remap.d.ts +0 -2
  80. package/build/declaration/util/stylemap/type/StyleMap.d.ts +0 -3
  81. package/build/style/index.global.css +0 -110
  82. package/build/style/index.global.css.d.ts +0 -21
  83. package/build/style/index.module.css +0 -110
  84. package/build/style/index.module.css.d.ts +0 -20
@@ -1,68 +1,224 @@
1
1
  import * as r from 'react';
2
- import { jsx } from 'react/jsx-runtime';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import * as rdom from 'react-dom';
3
4
 
4
5
  const CmpCtxState_Open = r.createContext(null);
5
6
 
6
- const CmpButton = props => {
7
- const ctxstate = r.useContext(CmpCtxState_Open);
8
- if (!ctxstate) {
9
- throw new Error(`Using DropdownStateOpen dependend component outside of DropdownStateOpen Context`);
7
+ const CmpCtxState_Refs = r.createContext(null);
8
+
9
+ const CmpCtxState_Content = r.createContext(null);
10
+
11
+ const CmpCtxState_Config = r.createContext(null);
12
+
13
+ const useCtxStateOpen = function () {
14
+ const ctxstate_open = r.useContext(CmpCtxState_Open);
15
+ if (!ctxstate_open) {
16
+ throw new Error(`Using DDN dependend component outside of DDNOpen Context`);
10
17
  }
11
- const event_click = r.useCallback(() => {
12
- ctxstate.open_set(t => !t);
13
- }, []);
14
- return jsx("button", { onClick: event_click, className: props.className, children: props.children });
18
+ return ctxstate_open;
15
19
  };
16
20
 
17
- const useDropdownCloseEvents = function (params) {
18
- const nconfig_blur = params.config?.blur ?? true;
19
- const nconfig_click = params.config?.click ?? true;
20
- const nconfig_scroll = params.config?.scroll ?? true;
21
- const nconfig_resize = params.config?.resize ?? true;
22
- const nconfig_escape = params.config?.escape ?? true;
23
- r.useEffect(() => {
24
- const container = params.ref();
25
- if (params.open && container) {
26
- const controller = new AbortController();
27
- if (nconfig_blur) {
28
- container.addEventListener("focusout", ev => {
29
- if (!(ev.relatedTarget instanceof Element) || !container.contains(ev.relatedTarget)) {
30
- params.open_set(false);
21
+ const useCtxStateRefs = function () {
22
+ const ctxstate_open = r.useContext(CmpCtxState_Refs);
23
+ if (!ctxstate_open) {
24
+ throw new Error(`Using DDN dependend component outside of DDNRefs Context`);
25
+ }
26
+ return ctxstate_open;
27
+ };
28
+
29
+ const useCtxStateContent = function () {
30
+ const ctxstate_content = r.useContext(CmpCtxState_Content);
31
+ if (!ctxstate_content) {
32
+ throw new Error(`Using DDN dependend component outside of DDNContent Context`);
33
+ }
34
+ return ctxstate_content;
35
+ };
36
+
37
+ const useCtxStateConfig = function () {
38
+ const ctxstate_open = r.useContext(CmpCtxState_Config);
39
+ if (!ctxstate_open) {
40
+ throw new Error(`Using DDN dependend component outside of DDNConfig Context`);
41
+ }
42
+ return ctxstate_open;
43
+ };
44
+
45
+ const useCtxStateInitOpen = function (params) {
46
+ const ctxstate_open = r.useContext(CmpCtxState_Open);
47
+ const [l_open, l_open_set] = r.useState(false);
48
+ const open = params.open ?? l_open;
49
+ const open_set = params.open_set ?? l_open_set;
50
+ return r.useMemo(() => {
51
+ return {
52
+ open_local: open,
53
+ open_inherited: open && (ctxstate_open?.open_inherited ?? true),
54
+ open_set
55
+ };
56
+ }, [open, open_set, ctxstate_open?.open_inherited]);
57
+ };
58
+
59
+ const useCascade = function () {
60
+ const [cascade, cascade_set] = r.useState(0);
61
+ const ctxstate_refs = r.useContext(CmpCtxState_Refs);
62
+ return [
63
+ cascade,
64
+ r.useMemo(() => {
65
+ return {
66
+ increment: () => {
67
+ cascade_set(n => n + 1);
68
+ ctxstate_refs?.cascade_api?.increment();
69
+ },
70
+ decrement: () => {
71
+ cascade_set(n => n - 1);
72
+ ctxstate_refs?.cascade_api?.decrement();
73
+ },
74
+ };
75
+ }, [ctxstate_refs?.cascade_api])
76
+ ];
77
+ };
78
+ const useRegister = function () {
79
+ const ctxstate_refs = r.useContext(CmpCtxState_Refs);
80
+ const l_register_local = r.useMemo(() => new Set(), []);
81
+ const l_register_down = r.useMemo(() => new Set(), []);
82
+ return r.useMemo(() => {
83
+ return {
84
+ add_own: ref => {
85
+ l_register_local.add(ref);
86
+ ctxstate_refs?.register.add_down(ref);
87
+ },
88
+ delete_own: ref => {
89
+ l_register_local.delete(ref);
90
+ ctxstate_refs?.register.delete_down(ref);
91
+ },
92
+ add_down: ref => {
93
+ l_register_down.add(ref);
94
+ ctxstate_refs?.register.add_down(ref);
95
+ },
96
+ delete_down: ref => {
97
+ l_register_down.delete(ref);
98
+ ctxstate_refs?.register.delete_down(ref);
99
+ },
100
+ it_full: {
101
+ [Symbol.iterator]: function* () {
102
+ if (ctxstate_refs) {
103
+ yield* ctxstate_refs.register.it_up;
104
+ yield* ctxstate_refs.register.it_context;
31
105
  }
32
- }, { signal: controller.signal });
33
- }
34
- if (nconfig_click) {
35
- document.addEventListener("click", ev => {
36
- const path = ev.composedPath();
37
- if (!container || !path.includes(container)) {
38
- params.open_set(false);
106
+ yield* l_register_local;
107
+ yield* l_register_down;
108
+ }
109
+ },
110
+ it_local: {
111
+ [Symbol.iterator]: function* () {
112
+ yield* l_register_local;
113
+ }
114
+ },
115
+ it_up: {
116
+ [Symbol.iterator]: function* () {
117
+ if (ctxstate_refs) {
118
+ yield* ctxstate_refs.register.it_up;
119
+ yield* ctxstate_refs.register.it_context;
39
120
  }
40
- }, { signal: controller.signal });
121
+ }
122
+ },
123
+ it_down: {
124
+ [Symbol.iterator]: function* () {
125
+ yield* l_register_down;
126
+ }
127
+ },
128
+ it_context: {
129
+ [Symbol.iterator]: function* () {
130
+ yield* l_register_local;
131
+ yield* l_register_down;
132
+ }
41
133
  }
42
- if (nconfig_escape) {
43
- document.addEventListener("keydown", ev => {
44
- if (!ev.defaultPrevented && ev.key.toLowerCase() === "escape") {
45
- params.open_set(false);
46
- ev.preventDefault();
134
+ };
135
+ }, [ctxstate_refs?.register, l_register_local, l_register_down]);
136
+ };
137
+ const useCtxStateInitRefs = function (params) {
138
+ const register = useRegister();
139
+ const [cascade, cascade_api] = useCascade();
140
+ const [rootref, rootref_set] = r.useState(() => new Set());
141
+ const shardevt_scroll = r.useMemo(() => new Set(), []);
142
+ return r.useMemo(() => {
143
+ return {
144
+ register,
145
+ container_real: params.container_real,
146
+ shardevt_scroll,
147
+ rootref,
148
+ rootref_set,
149
+ cascade,
150
+ cascade_api,
151
+ };
152
+ }, [params.container_real, register, rootref, shardevt_scroll, cascade, cascade_api]);
153
+ };
154
+
155
+ const useCtxStateInitContent = function (params) {
156
+ return r.useMemo(() => {
157
+ return {
158
+ ref_content: params.ref_content,
159
+ };
160
+ }, [params.ref_content]);
161
+ };
162
+
163
+ const useCtxStateInitConfig = function (params) {
164
+ const nprop_focus = r.useMemo(() => params.focus ?? {}, [params.focus]);
165
+ const nprop_closeevt = r.useMemo(() => params.closeevt ?? {}, [params.closeevt]);
166
+ return r.useMemo(() => {
167
+ return {
168
+ focus: nprop_focus,
169
+ closeevt: nprop_closeevt,
170
+ };
171
+ }, [nprop_closeevt, nprop_focus]);
172
+ };
173
+
174
+ const useDDNRoot = function (params) {
175
+ const { ctxstate_refs } = params;
176
+ r.useLayoutEffect(() => {
177
+ if (params.active) {
178
+ ctxstate_refs.rootref_set(old_rootref => {
179
+ const now_rootref = new Set(old_rootref);
180
+ now_rootref.add(params.ref);
181
+ return now_rootref;
182
+ });
183
+ return () => {
184
+ ctxstate_refs.rootref_set(old_rootref => {
185
+ const now_rootref = new Set(old_rootref);
186
+ now_rootref.delete(params.ref);
187
+ return now_rootref;
188
+ });
189
+ };
190
+ }
191
+ }, [ctxstate_refs.rootref_set, params.ref, params.active]);
192
+ };
193
+
194
+ const useDDNRootInfer = function (params) {
195
+ const ctxstate_refs = useCtxStateRefs();
196
+ useDDNRoot({
197
+ ...params,
198
+ ctxstate_refs,
199
+ });
200
+ };
201
+
202
+ const useCloseEvtShard = function (params) {
203
+ const { ctxstate_refs, ctxstate_open, ctxstate_config, } = params;
204
+ const nconfig_scroll = ctxstate_config.closeevt.scroll ?? true;
205
+ r.useEffect(() => {
206
+ if (params.active) {
207
+ const element = params.ref();
208
+ const controller = new AbortController();
209
+ if (element) {
210
+ let parent = element.parentElement;
211
+ const scroll_handler = (event) => {
212
+ if (nconfig_scroll) {
213
+ ctxstate_open.open_set(false);
47
214
  }
48
- }, { signal: controller.signal });
49
- }
50
- if (nconfig_resize) {
51
- window.addEventListener("resize", () => {
52
- params.open_set(false);
53
- }, { signal: controller.signal });
54
- }
55
- if (nconfig_scroll) {
56
- let parent = container.parentElement;
215
+ ctxstate_refs.shardevt_scroll.forEach(cb => cb(event));
216
+ };
57
217
  while (parent) {
58
- parent.addEventListener("scroll", () => {
59
- params.open_set(false);
60
- }, { signal: controller.signal });
218
+ parent.addEventListener("scroll", scroll_handler, { signal: controller.signal });
61
219
  parent = parent.parentElement;
62
220
  }
63
- document.addEventListener("scroll", () => {
64
- params.open_set(false);
65
- }, { signal: controller.signal });
221
+ document.addEventListener("scroll", scroll_handler, { signal: controller.signal });
66
222
  }
67
223
  return () => {
68
224
  controller.abort();
@@ -70,117 +226,192 @@ const useDropdownCloseEvents = function (params) {
70
226
  }
71
227
  }, [
72
228
  params.ref,
73
- params.open,
74
- params.open_set,
75
- nconfig_click,
229
+ params.active,
230
+ ctxstate_open.open_set,
76
231
  nconfig_scroll,
77
- nconfig_resize,
78
- nconfig_escape
232
+ ctxstate_refs.shardevt_scroll,
79
233
  ]);
80
234
  };
81
235
 
82
- const cl = function (...clnames) {
83
- let result = [];
84
- for (const clname of clnames) {
85
- if (clname) {
86
- result.push(clname);
236
+ const useDDNShard = function (params) {
237
+ const { ctxstate_open, ctxstate_refs, ctxstate_config } = params;
238
+ useCloseEvtShard({
239
+ ref: params.ref,
240
+ active: params.isolated || !ctxstate_refs.container_real,
241
+ ctxstate_open,
242
+ ctxstate_refs,
243
+ ctxstate_config,
244
+ });
245
+ r.useLayoutEffect(() => {
246
+ if (params.isolated || !ctxstate_refs.container_real) {
247
+ ctxstate_refs.register.add_own(params.ref);
248
+ return () => {
249
+ ctxstate_refs.register.delete_own(params.ref);
250
+ };
87
251
  }
88
- }
89
- return result.join(" ");
252
+ }, [ctxstate_refs.register, ctxstate_refs.container_real, params.isolated, params.ref]);
90
253
  };
91
254
 
92
- const stylemap_new_remap = function (def, remap) {
93
- const result = {};
94
- for (const clname of Object.keys(def)) {
95
- const remaped = remap[clname];
96
- if (remaped !== undefined) {
97
- result[clname] = remaped;
98
- continue;
255
+ const useDDNShardInfer = function (params) {
256
+ const ctxstate_open = useCtxStateOpen();
257
+ const ctxstate_refs = useCtxStateRefs();
258
+ const ctxstate_config = useCtxStateConfig();
259
+ useDDNShard({
260
+ ...params,
261
+ ctxstate_refs,
262
+ ctxstate_open,
263
+ ctxstate_config,
264
+ });
265
+ };
266
+
267
+ const ref_use = function (ref, value) {
268
+ if (ref) {
269
+ if (typeof ref === "object") {
270
+ ref.current = value;
99
271
  }
100
- {
101
- result[clname] = clname;
272
+ else {
273
+ ref(value);
102
274
  }
103
275
  }
104
- return result;
105
276
  };
106
277
 
107
- const stylemap$2 = {
108
- container: "container"
278
+ const useRefMerge = function (...refs) {
279
+ return r.useCallback((value) => {
280
+ for (const ref of refs) {
281
+ ref_use(ref, value);
282
+ }
283
+ }, refs);
109
284
  };
110
- const CmpContainer = r.memo(r.forwardRef((props, ref) => {
111
- const nprop_style = r.useMemo(() => (props.stylemodule ? stylemap_new_remap(stylemap$2, props.stylemodule) : stylemap$2), [props.stylemodule]);
285
+
286
+ const render_view_default$5 = function (props) {
287
+ return jsx("button", { ...props });
288
+ };
289
+ const CmpButton = r.memo(r.forwardRef((props, f_ref) => {
290
+ const nprop_render_view = props.render_view ?? render_view_default$5;
291
+ const ctxstate_refs = useCtxStateRefs();
292
+ const ctxstate_open = useCtxStateOpen();
112
293
  const l_ref = r.useRef(null);
113
- const [open, open_set] = r.useState(false);
114
- const l_open = props.open ?? open;
115
- const l_open_set = props.open_set ?? open_set;
116
- const ctxstate = r.useMemo(() => {
117
- return {
118
- open: l_open,
119
- ref: l_ref,
120
- open_set: l_open_set,
121
- };
122
- }, [l_open, l_open_set]);
123
- const mref = r.useMemo(() => {
124
- return (element) => {
125
- l_ref.current = element;
126
- if (ref) {
127
- if (typeof ref === "object") {
128
- ref.current = element;
129
- }
130
- else {
131
- ref(element);
132
- }
133
- }
134
- };
135
- }, [ref]);
136
- useDropdownCloseEvents({
137
- config: props.closeevents,
294
+ const event_click = r.useCallback(() => {
295
+ ctxstate_open.open_set(t => !t);
296
+ }, []);
297
+ useDDNShardInfer({
298
+ isolated: false,
138
299
  ref: r.useCallback(() => l_ref.current, []),
139
- open: ctxstate.open,
140
- open_set: ctxstate.open_set,
141
300
  });
142
- return jsx("div", { ref: mref, className: cl("__qyuddn", props.className, nprop_style.container), children: jsx(CmpCtxState_Open.Provider, { value: ctxstate, children: props.children }) });
301
+ useDDNRootInfer({
302
+ ref: r.useCallback(() => l_ref.current, []),
303
+ active: props.isroot ?? !ctxstate_refs.container_real,
304
+ });
305
+ const ref = useRefMerge(l_ref, f_ref);
306
+ return nprop_render_view({
307
+ ref,
308
+ onClick: event_click,
309
+ disabled: props.disabled,
310
+ children: props.children,
311
+ className: props.className,
312
+ });
143
313
  }));
144
314
 
145
- const nprop_align_new = function (raw) {
146
- if (!raw) {
147
- return "start";
148
- }
149
- if (raw === true) {
150
- return "end";
151
- }
152
- return raw;
315
+ const CmpButtonVirtual = r.memo(props => {
316
+ const { target: ref_target } = props;
317
+ const ctxstate_refs = useCtxStateRefs();
318
+ useDDNShardInfer({
319
+ ref: ref_target,
320
+ isolated: false,
321
+ });
322
+ useDDNRootInfer({
323
+ ref: ref_target,
324
+ active: props.isroot ?? !ctxstate_refs.container_real,
325
+ });
326
+ return props.children;
327
+ });
328
+
329
+ const useDDNList = function (params) {
330
+ const { ctxstate_refs } = params;
331
+ r.useEffect(() => {
332
+ if (params.visible) {
333
+ ctxstate_refs.cascade_api.increment();
334
+ return () => {
335
+ ctxstate_refs.cascade_api.decrement();
336
+ };
337
+ }
338
+ }, [params.visible, ctxstate_refs.cascade_api]);
153
339
  };
154
- const nprop_justify_new = function (raw) {
155
- if (!raw) {
156
- return "end";
157
- }
158
- if (raw === true) {
159
- return "start";
160
- }
161
- return raw;
340
+
341
+ const useDDNListInfer = function (params) {
342
+ const ctxstate_refs = useCtxStateRefs();
343
+ useDDNList({
344
+ ...params,
345
+ ctxstate_refs,
346
+ });
162
347
  };
163
- const nprop_direction_new = function (raw) {
164
- if (!raw) {
165
- return "ver";
348
+
349
+ const refs_unpack$1 = function* (src) {
350
+ for (const ref of src) {
351
+ const element = ref();
352
+ if (element) {
353
+ yield element;
354
+ }
166
355
  }
167
- if (raw === true) {
168
- return "hor";
356
+ };
357
+ const element_inside = function (element, shards) {
358
+ for (const ref of shards) {
359
+ if (ref === element || ref.contains(element)) {
360
+ return true;
361
+ }
169
362
  }
170
- return raw;
363
+ return false;
171
364
  };
365
+ function useFocusCapture(params) {
366
+ const { ctxstate_config, ctxstate_refs } = params;
367
+ const nprop_move = ctxstate_config.focus.capture ?? true;
368
+ const nprop_restore = ctxstate_config.focus.capture ?? true;
369
+ const nprop_capture_options = r.useMemo(() => {
370
+ return ctxstate_config.focus.capture_options ?? {
371
+ preventScroll: true,
372
+ };
373
+ }, [ctxstate_config.focus.capture_options]);
374
+ const nprop_restore_options = r.useMemo(() => {
375
+ return ctxstate_config.focus.restore_options ?? {
376
+ preventScroll: true,
377
+ };
378
+ }, [ctxstate_config.focus.restore_options]);
379
+ const ref_restorecapture = r.useRef(null);
380
+ r.useLayoutEffect(() => {
381
+ if (params.open) {
382
+ if (document.activeElement instanceof HTMLElement) {
383
+ ref_restorecapture.current = document.activeElement;
384
+ }
385
+ if (nprop_move) {
386
+ params.ref_target()?.focus(nprop_capture_options);
387
+ }
388
+ }
389
+ else {
390
+ const active = document.activeElement;
391
+ const restorecapture = ref_restorecapture.current;
392
+ {
393
+ ref_restorecapture.current = null;
394
+ }
395
+ if (nprop_restore && restorecapture && active instanceof HTMLElement) {
396
+ const active_inside = element_inside(active, refs_unpack$1(ctxstate_refs.register.it_context));
397
+ if (active_inside) {
398
+ restorecapture.focus(nprop_restore_options);
399
+ }
400
+ }
401
+ }
402
+ }, [params.open]);
403
+ }
172
404
 
173
- const stylemap$1 = {
174
- listfix: "listfix",
175
- listfix_open: "listfix_open",
176
- listfix_justify_start: "listfix_justify_start",
177
- listfix_justify_end: "listfix_justify_end",
178
- listfix_align_start: "listfix_align_start",
179
- listfix_align_end: "listfix_align_end",
180
- listfix_align_center: "listfix_align_center",
181
- listfix_vertical: "listfix_vertical",
182
- listfix_horizontal: "listfix_horizontal",
405
+ const useFocusCaptureInfer = function (params) {
406
+ const ctxstate_refs = useCtxStateRefs();
407
+ const ctxstate_config = useCtxStateConfig();
408
+ useFocusCapture({
409
+ ...params,
410
+ ctxstate_refs,
411
+ ctxstate_config,
412
+ });
183
413
  };
414
+
184
415
  const normalize_justify$1 = function (params) {
185
416
  let axis_main;
186
417
  switch (params.direction) {
@@ -219,27 +450,15 @@ const normalize_justify$1 = function (params) {
219
450
  break;
220
451
  }
221
452
  }
222
- if (freespace_direct >= axis_main.list_size) {
223
- params.reverse_justify_set(false);
224
- axis_main.space_set(null);
225
- flow_direct.position_set(position_direct);
226
- flow_reverse.position_set(null);
227
- }
228
- else if (freespace_reverse >= axis_main.list_size) {
229
- params.reverse_justify_set(true);
230
- axis_main.space_set(null);
231
- flow_direct.position_set(null);
232
- flow_reverse.position_set(position_reverse);
233
- }
234
- else if (freespace_direct >= freespace_reverse) {
235
- params.reverse_justify_set(false);
236
- axis_main.space_set(freespace_direct);
453
+ if (freespace_direct >= axis_main.list_size || freespace_direct >= freespace_reverse) {
454
+ params.reverse_set(false);
455
+ axis_main.size_set(Math.min(freespace_direct, axis_main.list_size));
237
456
  flow_direct.position_set(position_direct);
238
457
  flow_reverse.position_set(null);
239
458
  }
240
459
  else {
241
- params.reverse_justify_set(true);
242
- axis_main.space_set(freespace_reverse);
460
+ params.reverse_set(true);
461
+ axis_main.size_set(Math.min(freespace_reverse, axis_main.list_size));
243
462
  flow_direct.position_set(null);
244
463
  flow_reverse.position_set(position_reverse);
245
464
  }
@@ -256,13 +475,37 @@ const normalize_align$1 = function (params) {
256
475
  break;
257
476
  }
258
477
  }
259
- axis_main.space_set(null);
260
478
  switch (params.align) {
261
479
  case "center": {
262
- const offset = (axis_main.list_size - axis_main.container_size) / 2;
263
- params.reverse_align_set(false);
264
- axis_main.flow_reverse.position_set(null);
265
- axis_main.flow_direct.position_set(Math.max(0, axis_main.container_pos - offset));
480
+ if (axis_main.list_size >= axis_main.screen_size) {
481
+ params.reverse_set(false);
482
+ axis_main.size_set(axis_main.screen_size);
483
+ axis_main.flow_direct.position_set(0);
484
+ axis_main.flow_reverse.position_set(null);
485
+ }
486
+ else {
487
+ const point = axis_main.container_pos + axis_main.container_size / 2;
488
+ const freespace_reverse = point;
489
+ const freespace_direct = axis_main.screen_size - point;
490
+ if (axis_main.list_size >= freespace_reverse) {
491
+ params.reverse_set(false);
492
+ axis_main.flow_direct.position_set(0);
493
+ axis_main.flow_reverse.position_set(null);
494
+ axis_main.size_set(axis_main.list_size);
495
+ }
496
+ else if (axis_main.list_size >= freespace_direct) {
497
+ params.reverse_set(true);
498
+ axis_main.flow_reverse.position_set(0);
499
+ axis_main.flow_direct.position_set(null);
500
+ axis_main.size_set(axis_main.list_size);
501
+ }
502
+ else {
503
+ params.reverse_set(false);
504
+ axis_main.flow_direct.position_set(point - axis_main.list_size / 2);
505
+ axis_main.flow_reverse.position_set(null);
506
+ axis_main.size_set(axis_main.list_size);
507
+ }
508
+ }
266
509
  break;
267
510
  }
268
511
  case "start": {
@@ -276,12 +519,13 @@ const normalize_align$1 = function (params) {
276
519
  - (axis_main.container_pos + axis_main.container_size)
277
520
  - Math.max(0, axis_main.list_size - freespace_reverse)));
278
521
  if (freespace_direct >= axis_main.list_size || freespace_direct >= freespace_reverse) {
279
- params.reverse_align_set(false);
280
- flow_reverse.position_set(null);
522
+ params.reverse_set(false);
523
+ axis_main.size_set(Math.min(freespace_direct, axis_main.list_size));
281
524
  flow_direct.position_set(position_direct);
282
525
  }
283
526
  else {
284
- params.reverse_align_set(true);
527
+ params.reverse_set(true);
528
+ axis_main.size_set(Math.min(freespace_reverse, axis_main.list_size));
285
529
  flow_direct.position_set(null);
286
530
  flow_reverse.position_set(position_reverse);
287
531
  }
@@ -298,12 +542,14 @@ const normalize_align$1 = function (params) {
298
542
  const position_reverse = Math.max(0, (+axis_main.container_pos
299
543
  - Math.max(0, axis_main.list_size - freespace_reverse)));
300
544
  if (freespace_direct >= axis_main.list_size || freespace_direct >= freespace_reverse) {
301
- params.reverse_align_set(false);
545
+ params.reverse_set(false);
546
+ axis_main.size_set(Math.min(freespace_direct, axis_main.list_size));
302
547
  flow_reverse.position_set(null);
303
548
  flow_direct.position_set(position_direct);
304
549
  }
305
550
  else {
306
- params.reverse_align_set(true);
551
+ params.reverse_set(true);
552
+ axis_main.size_set(Math.min(freespace_reverse, axis_main.list_size));
307
553
  flow_direct.position_set(null);
308
554
  flow_reverse.position_set(position_reverse);
309
555
  }
@@ -311,137 +557,417 @@ const normalize_align$1 = function (params) {
311
557
  }
312
558
  }
313
559
  };
314
- const CmpListFix = r.memo(r.forwardRef((props, ref) => {
315
- const nprop_gap = props.gap ?? 0;
316
- const nprop_lazy = props.lazy ?? false;
317
- const nprop_align = nprop_align_new(props.align);
318
- const nprop_justify = nprop_justify_new(props.justify);
319
- const nprop_direction = nprop_direction_new(props.direction);
320
- const nprop_style = r.useMemo(() => (props.stylemodule ? stylemap_new_remap(stylemap$1, props.stylemodule) : stylemap$1), [props.stylemodule]);
321
- const ctxstate = r.useContext(CmpCtxState_Open);
322
- if (!ctxstate) {
323
- throw new Error(`Using DDN dependend component outside of DDN Context`);
324
- }
325
- const l_ref = r.useRef(null);
326
- const [visible, visible_set] = r.useState(false);
327
- const [revalign, revalign_set] = r.useState(false);
328
- const [revjustify, revjustify_set] = r.useState(false);
329
- const [maxheight, maxheight_set] = r.useState(null);
330
- const [maxwidth, maxwidth_set] = r.useState(null);
560
+ const useListPosApiFixed = function (params) {
561
+ const ctxstate_refs = useCtxStateRefs();
562
+ const [align_reverse, align_reverse_set] = r.useState(false);
563
+ const [justify_reverse, justify_reverse_set] = r.useState(false);
564
+ let [width, width_set] = r.useState(null);
565
+ let [height, height_set] = r.useState(null);
331
566
  const [top, top_set] = r.useState(null);
332
567
  const [left, left_set] = r.useState(null);
333
568
  const [right, right_set] = r.useState(null);
334
569
  const [bottom, bottom_set] = r.useState(null);
570
+ return {
571
+ reverse: r.useMemo(() => ({
572
+ align: align_reverse,
573
+ justify: justify_reverse,
574
+ }), [align_reverse, justify_reverse]),
575
+ size: r.useMemo(() => ({
576
+ width: width,
577
+ height: height,
578
+ }), [width, height]),
579
+ position: r.useMemo(() => ({
580
+ top,
581
+ left,
582
+ right,
583
+ bottom,
584
+ }), [top, left, right, bottom]),
585
+ api: r.useMemo(() => ({
586
+ clear: () => {
587
+ align_reverse_set(false);
588
+ justify_reverse_set(false);
589
+ top_set(null);
590
+ left_set(null);
591
+ right_set(null);
592
+ bottom_set(null);
593
+ },
594
+ rearrange: config => {
595
+ const list = params.ref_list();
596
+ const content = params.ref_content();
597
+ const container = [...ctxstate_refs.rootref].map(ref => ref()).find(el => el !== null);
598
+ if (list && container && content) {
599
+ if (params.clmap_content._tracking) {
600
+ content.classList.add(params.clmap_content._tracking);
601
+ }
602
+ const container_rect = container.getBoundingClientRect();
603
+ const axis_main = {
604
+ list_size: content.offsetHeight,
605
+ screen_size: document.documentElement.clientHeight,
606
+ container_pos: container_rect.y,
607
+ container_size: container_rect.height,
608
+ size_set: height_set,
609
+ flow_direct: {
610
+ position_set: top_set
611
+ },
612
+ flow_reverse: {
613
+ position_set: bottom_set
614
+ },
615
+ };
616
+ const axis_cross = {
617
+ list_size: content.offsetWidth,
618
+ screen_size: document.documentElement.clientWidth,
619
+ container_pos: container_rect.x,
620
+ container_size: container_rect.width,
621
+ size_set: width_set,
622
+ flow_direct: {
623
+ position_set: left_set
624
+ },
625
+ flow_reverse: {
626
+ position_set: right_set
627
+ },
628
+ };
629
+ normalize_justify$1({
630
+ axis_main,
631
+ axis_cross,
632
+ gap: config.gap,
633
+ justify: config.justify,
634
+ direction: config.direction,
635
+ reverse_set: justify_reverse_set,
636
+ });
637
+ normalize_align$1({
638
+ axis_main,
639
+ axis_cross,
640
+ align: config.align,
641
+ direction: config.direction,
642
+ reverse_set: align_reverse_set,
643
+ });
644
+ if (params.clmap_content._tracking) {
645
+ content.classList.remove(params.clmap_content._tracking);
646
+ }
647
+ }
648
+ },
649
+ }), [ctxstate_refs.rootref, params.ref_list, params.ref_content])
650
+ };
651
+ };
652
+
653
+ const useListPosRearrange = function (params) {
654
+ const nprop_rearrange_open = params.rearrange_config?.open ?? true;
655
+ const nprop_rearrange_scroll = params.rearrange_config?.scroll ?? true;
656
+ const nprop_rearrange_resize = params.rearrange_config?.resize ?? true;
657
+ const nprop_rearrange_polling = params.rearrange_config?.polling ?? false;
658
+ const ctxstate_refs = useCtxStateRefs();
659
+ const rearrange = r.useCallback(() => {
660
+ params.api.rearrange(params.api_config);
661
+ }, [
662
+ params.api,
663
+ params.api_config.gap,
664
+ params.api_config.align,
665
+ params.api_config.justify,
666
+ params.api_config.direction,
667
+ ]);
335
668
  r.useLayoutEffect(() => {
336
- const list = l_ref.current;
337
- const container = ctxstate.ref.current;
338
- if (list && container && ctxstate.open) {
339
- const container_rect = container.getBoundingClientRect();
340
- const axis_main = {
341
- list_size: list.offsetHeight,
342
- space_set: maxheight_set,
343
- screen_size: document.documentElement.clientHeight,
344
- container_pos: container_rect.y,
345
- container_size: container_rect.height,
346
- flow_direct: {
347
- position_set: top_set
348
- },
349
- flow_reverse: {
350
- position_set: bottom_set
351
- },
669
+ if (params.rearrange_config?.deps && params.open) {
670
+ rearrange();
671
+ }
672
+ }, [...params.rearrange_config?.deps ?? []]);
673
+ r.useLayoutEffect(() => {
674
+ if (nprop_rearrange_open && params.open) {
675
+ rearrange();
676
+ }
677
+ }, [rearrange, params.open]);
678
+ r.useLayoutEffect(() => {
679
+ if (nprop_rearrange_resize && params.active) {
680
+ document.addEventListener("resize", rearrange);
681
+ return () => {
682
+ document.addEventListener("resize", rearrange);
352
683
  };
353
- const axis_cross = {
354
- list_size: list.offsetWidth,
355
- space_set: maxwidth_set,
356
- screen_size: document.documentElement.clientWidth,
357
- container_pos: container_rect.x,
358
- container_size: container_rect.width,
359
- flow_direct: {
360
- position_set: left_set
361
- },
362
- flow_reverse: {
363
- position_set: right_set
364
- },
684
+ }
685
+ }, [rearrange, params.active, nprop_rearrange_resize]);
686
+ r.useLayoutEffect(() => {
687
+ if (nprop_rearrange_scroll && params.active) {
688
+ ctxstate_refs.shardevt_scroll.add(rearrange);
689
+ return () => {
690
+ ctxstate_refs.shardevt_scroll.delete(rearrange);
365
691
  };
366
- normalize_justify$1({
367
- axis_main,
368
- axis_cross,
369
- gap: nprop_gap,
370
- justify: nprop_justify,
371
- direction: nprop_direction,
372
- reverse_align_set: revalign_set,
373
- reverse_justify_set: revjustify_set,
374
- });
375
- normalize_align$1({
376
- axis_main,
377
- axis_cross,
378
- align: nprop_align,
379
- direction: nprop_direction,
380
- reverse_align_set: revalign_set,
381
- reverse_justify_set: revjustify_set,
382
- });
383
692
  }
384
- }, [ctxstate.open, ctxstate.ref, nprop_gap, nprop_align, nprop_justify, nprop_direction]);
385
- const mref = r.useMemo(() => {
386
- return (element) => {
387
- l_ref.current = element;
388
- if (ref) {
389
- if (typeof ref === "object") {
390
- ref.current = element;
391
- }
392
- else {
393
- ref(element);
394
- }
693
+ }, [rearrange, params.active, nprop_rearrange_scroll]);
694
+ r.useLayoutEffect(() => {
695
+ if (nprop_rearrange_polling && params.active) {
696
+ let frame_id;
697
+ const frame_cb = () => {
698
+ rearrange();
699
+ frame_id = requestAnimationFrame(frame_cb);
700
+ };
701
+ requestAnimationFrame(frame_cb);
702
+ return () => {
703
+ cancelAnimationFrame(frame_id);
704
+ };
705
+ }
706
+ }, [rearrange, params.active, nprop_rearrange_polling, ctxstate_refs]);
707
+ };
708
+
709
+ const useOpen = function (params) {
710
+ const { ctxstate_open, ctxstate_refs } = params;
711
+ return r.useMemo(() => {
712
+ return ctxstate_open.open_inherited || ctxstate_refs.cascade > 1;
713
+ }, [ctxstate_open.open_inherited, ctxstate_refs.cascade]);
714
+ };
715
+
716
+ const useOpenInfer = function (params) {
717
+ const ctxstate_refs = useCtxStateRefs();
718
+ const ctxstate_open = useCtxStateOpen();
719
+ return useOpen({
720
+ ...params,
721
+ ctxstate_open,
722
+ ctxstate_refs,
723
+ });
724
+ };
725
+
726
+ const useRefO = function (ref) {
727
+ return r.useCallback(() => ref.current, [ref]);
728
+ };
729
+
730
+ const cl = function (...names) {
731
+ let result = [];
732
+ for (const name of names) {
733
+ if (name) {
734
+ result.push(name);
735
+ }
736
+ }
737
+ if (result.length === 0) {
738
+ return undefined;
739
+ }
740
+ return result.join(" ");
741
+ };
742
+
743
+ const cssprops_new_position = function (params) {
744
+ const result = {};
745
+ if (params.top !== null) {
746
+ result.top = `${params.top}px`;
747
+ }
748
+ if (params.left !== null) {
749
+ result.left = `${params.left}px`;
750
+ }
751
+ if (params.right !== null) {
752
+ result.right = `${params.right}px`;
753
+ }
754
+ if (params.bottom !== null) {
755
+ result.bottom = `${params.bottom}px`;
756
+ }
757
+ return result;
758
+ };
759
+
760
+ const cssprops_new_size = function (params) {
761
+ const result = {};
762
+ switch (params.direction) {
763
+ case "hor": {
764
+ if (params.open) {
765
+ result.width = params.size.width ?? 1;
395
766
  }
396
- };
397
- }, [ref]);
767
+ else {
768
+ result.width = 1;
769
+ }
770
+ if (params.size.height) {
771
+ result.height = params.size.height;
772
+ }
773
+ break;
774
+ }
775
+ case "ver": {
776
+ if (params.open) {
777
+ result.height = params.size.height ?? 1;
778
+ }
779
+ else {
780
+ result.height = 1;
781
+ }
782
+ if (params.size.width) {
783
+ result.width = params.size.width;
784
+ }
785
+ break;
786
+ }
787
+ }
788
+ return result;
789
+ };
790
+
791
+ const prop_align_new = function (raw) {
792
+ if (!raw) {
793
+ return "start";
794
+ }
795
+ if (raw === true) {
796
+ return "end";
797
+ }
798
+ return raw;
799
+ };
800
+
801
+ const prop_align_new_reversed = function (src_align) {
802
+ switch (src_align) {
803
+ case "start":
804
+ return "end";
805
+ case "end":
806
+ return "start";
807
+ }
808
+ return src_align;
809
+ };
810
+
811
+ const prop_clmap_def_content = {
812
+ __qyuddn: "__qyuddn",
813
+ content: "content",
814
+ _tracking: "_tracking",
815
+ focusguard: "focusguard",
816
+ };
817
+
818
+ const prop_clmap_def_listfix = {
819
+ __qyuddn: "__qyuddn",
820
+ listfix: "listfix",
821
+ _transition_nopos: "_transition_nopos",
822
+ _transition_nosize: "_transition_nosize",
823
+ _open: "_open",
824
+ _justify_start: "_justify_start",
825
+ _justify_end: "_justify_end",
826
+ _align_start: "_align_start",
827
+ _align_end: "_align_end",
828
+ _align_center: "_align_center",
829
+ _vertical: "_vertical",
830
+ _horizontal: "_horizontal",
831
+ };
832
+
833
+ const prop_clmap_new = function (stylemap, def) {
834
+ if (!stylemap) {
835
+ return def;
836
+ }
837
+ const result = {};
838
+ for (const clname of Object.keys(def)) {
839
+ const remaped = stylemap[clname];
840
+ if (remaped !== undefined) {
841
+ result[clname] = remaped;
842
+ continue;
843
+ }
844
+ {
845
+ result[clname] = clname;
846
+ }
847
+ }
848
+ return result;
849
+ };
850
+
851
+ const prop_direction_new = function (raw) {
852
+ if (!raw) {
853
+ return "ver";
854
+ }
855
+ if (raw === true) {
856
+ return "hor";
857
+ }
858
+ return raw;
859
+ };
860
+
861
+ const prop_justify_new = function (raw) {
862
+ if (!raw) {
863
+ return "end";
864
+ }
865
+ if (raw === true) {
866
+ return "start";
867
+ }
868
+ return raw;
869
+ };
870
+
871
+ const prop_justify_new_reversed = function (src_justify) {
872
+ switch (src_justify) {
873
+ case "start":
874
+ return "end";
875
+ case "end":
876
+ return "start";
877
+ }
878
+ return src_justify;
879
+ };
880
+
881
+ const render_view_default$4 = function (props) {
882
+ return jsx("div", { ...props });
883
+ };
884
+ const CmpListFix = r.memo(r.forwardRef((props, f_ref) => {
885
+ const nprop_gap = props.gap ?? 0;
886
+ const nprop_lazy = props.lazy ?? false;
887
+ const nprop_align = prop_align_new(props.align);
888
+ const nprop_justify = prop_justify_new(props.justify);
889
+ const nprop_direction = prop_direction_new(props.direction);
890
+ const nprop_transition_nopos = props.transition_nopos ?? false;
891
+ const nprop_transition_nosize = props.transition_nosize ?? false;
892
+ const nprop_render_view = props.render_view ?? render_view_default$4;
893
+ const nprop_clmap = r.useMemo(() => prop_clmap_new(props.clmap, prop_clmap_def_listfix), [props.clmap]);
894
+ const nprop_clmap_content = r.useMemo(() => prop_clmap_new(props.clmap_content, prop_clmap_def_content), [props.clmap_content]);
895
+ const l_ref = r.useRef(null);
896
+ const l_ref_content = r.useRef(null);
897
+ const ref_list = useRefO(l_ref);
898
+ const ref_content = useRefO(l_ref_content);
899
+ const open = useOpenInfer({});
900
+ const [visible, visible_set] = r.useState(false);
901
+ const listapi = useListPosApiFixed({ ref_list, ref_content, clmap_content: nprop_clmap_content });
902
+ const ctxstate_content = useCtxStateInitContent({
903
+ ref_content: l_ref_content,
904
+ });
905
+ useDDNListInfer({
906
+ visible,
907
+ });
908
+ useDDNShardInfer({
909
+ isolated: false,
910
+ ref: useRefO(l_ref),
911
+ });
912
+ useListPosRearrange({
913
+ open,
914
+ api: listapi.api,
915
+ active: visible || open,
916
+ rearrange_config: props.rearrange,
917
+ api_config: {
918
+ gap: nprop_gap,
919
+ align: nprop_align,
920
+ justify: nprop_justify,
921
+ direction: nprop_direction,
922
+ },
923
+ });
924
+ useFocusCaptureInfer({
925
+ open,
926
+ ref_target: useRefO(ctxstate_content.ref_content),
927
+ });
928
+ const ref = useRefMerge(l_ref, f_ref);
398
929
  const children = r.useMemo(() => {
399
- if (!nprop_lazy || visible || ctxstate.open) {
930
+ if (!nprop_lazy || visible || open) {
400
931
  if (typeof props.children === "function") {
401
932
  return props.children();
402
933
  }
403
934
  return props.children;
404
935
  }
405
936
  return null;
406
- }, [nprop_lazy, visible, ctxstate.open, props.children]);
407
- return jsx("div", { ref: mref, tabIndex: props.tabIndex, className: cl("__qyuddn", props.className, nprop_style.listfix, ctxstate.open && nprop_style.listfix_open, ((nprop_align === "end" && !revalign) || (nprop_align === "start" && revalign)) && nprop_style.listfix_align_end, ((nprop_align === "start" && !revalign) || (nprop_align === "end" && revalign)) && nprop_style.listfix_align_start, nprop_align === "center" && nprop_style.listfix_align_center, ((nprop_justify === "end") !== revjustify) && nprop_style.listfix_justify_end, ((nprop_justify === "start") !== revjustify) && nprop_style.listfix_justify_start, nprop_direction === "hor" && nprop_style.listfix_horizontal, nprop_direction === "ver" && nprop_style.listfix_vertical), style: {
408
- ["--gap"]: `${nprop_gap}px`,
409
- top: top !== null ? `${top}px` : null,
410
- left: left !== null ? `${left}px` : null,
411
- right: right !== null ? `${right}px` : null,
412
- bottom: bottom !== null ? `${bottom}px` : null,
413
- maxWidth: maxwidth === null ? undefined : `${maxwidth}px`,
414
- maxHeight: maxheight === null ? undefined : `${maxheight}px`,
415
- }, onTransitionStart: ev => {
416
- if (ev.nativeEvent.propertyName === "opacity" && ctxstate.open) {
417
- visible_set(true);
418
- }
419
- }, onTransitionEnd: ev => {
420
- if (ev.nativeEvent.propertyName === "opacity" && !ctxstate.open) {
421
- revalign_set(false);
422
- revjustify_set(false);
423
- maxwidth_set(null);
424
- maxheight_set(null);
425
- visible_set(false);
426
- top_set(null);
427
- bottom_set(null);
428
- left_set(null);
429
- right_set(null);
430
- }
431
- }, children: children });
937
+ }, [nprop_lazy, visible, open, props.children]);
938
+ const view_align = listapi.reverse.align ? prop_align_new_reversed(nprop_align) : nprop_align;
939
+ const view_justify = listapi.reverse.justify ? prop_justify_new_reversed(nprop_justify) : nprop_justify;
940
+ return jsx(CmpCtxState_Content.Provider, { value: ctxstate_content, children: nprop_render_view({
941
+ ref,
942
+ children,
943
+ className: cl(nprop_clmap.__qyuddn, nprop_clmap.listfix, open && nprop_clmap._open, nprop_transition_nopos && nprop_clmap._transition_nopos, nprop_transition_nosize && nprop_clmap._transition_nosize, view_align === "end" && nprop_clmap._align_end, view_align === "start" && nprop_clmap._align_start, view_align === "center" && nprop_clmap._align_center, view_justify === "end" && nprop_clmap._justify_end, view_justify === "start" && nprop_clmap._justify_start, nprop_direction === "hor" && nprop_clmap._horizontal, nprop_direction === "ver" && nprop_clmap._vertical, props.className),
944
+ style: {
945
+ ["--gap"]: `${nprop_gap}px`,
946
+ ...cssprops_new_position(listapi.position),
947
+ ...cssprops_new_size({
948
+ size: listapi.size,
949
+ open: open,
950
+ direction: nprop_direction,
951
+ }),
952
+ },
953
+ onTransitionStart: ev => {
954
+ props.event_transition_change?.(ev.nativeEvent.propertyName, true);
955
+ if (ev.nativeEvent.propertyName === "opacity" && open) {
956
+ visible_set(true);
957
+ props.event_visible_change?.(true);
958
+ }
959
+ },
960
+ onTransitionEnd: ev => {
961
+ props.event_transition_change?.(ev.nativeEvent.propertyName, false);
962
+ if (ev.nativeEvent.propertyName === "opacity" && !open) {
963
+ listapi.api.clear();
964
+ visible_set(false);
965
+ props.event_visible_change?.(false);
966
+ }
967
+ },
968
+ }) });
432
969
  }));
433
970
 
434
- const stylemap = {
435
- listabs: "listabs",
436
- listabs_open: "listabs_open",
437
- listabs_justify_start: "listabs_justify_start",
438
- listabs_justify_end: "listabs_justify_end",
439
- listabs_align_start: "listabs_align_start",
440
- listabs_align_end: "listabs_align_end",
441
- listabs_align_center: "listabs_align_center",
442
- listabs_vertical: "listabs_vertical",
443
- listabs_horizontal: "listabs_horizontal",
444
- };
445
971
  const normalize_justify = function (params) {
446
972
  let axis_main;
447
973
  switch (params.direction) {
@@ -468,21 +994,13 @@ const normalize_justify = function (params) {
468
994
  break;
469
995
  }
470
996
  }
471
- if (freespace_direct >= axis_main.list_size) {
472
- params.reverse_justify_set(false);
473
- axis_main.space_set(null);
474
- }
475
- else if (freespace_reverse >= axis_main.list_size) {
476
- params.reverse_justify_set(true);
477
- axis_main.space_set(null);
478
- }
479
- else if (freespace_direct >= freespace_reverse) {
480
- params.reverse_justify_set(false);
481
- axis_main.space_set(freespace_direct);
997
+ if (freespace_direct >= axis_main.list_size || freespace_direct >= freespace_reverse) {
998
+ params.reverse_set(false);
999
+ axis_main.size_set(Math.min(freespace_direct, axis_main.list_size));
482
1000
  }
483
1001
  else {
484
- params.reverse_justify_set(true);
485
- axis_main.space_set(freespace_reverse);
1002
+ params.reverse_set(true);
1003
+ axis_main.size_set(Math.min(freespace_reverse, axis_main.list_size));
486
1004
  }
487
1005
  };
488
1006
  const normalize_align = function (params) {
@@ -501,8 +1019,10 @@ const normalize_align = function (params) {
501
1019
  let freespace_reverse;
502
1020
  switch (params.align) {
503
1021
  case "center": {
504
- params.reverse_align_set(false);
505
- axis_main.space_set(null);
1022
+ const point = axis_main.container_pos + (axis_main.container_size / 2);
1023
+ const freespace = Math.max(Math.min(point, axis_main.screen_size - point), 0) * 2;
1024
+ params.reverse_set(false);
1025
+ axis_main.size_set(Math.min(freespace, axis_main.list_size));
506
1026
  return;
507
1027
  }
508
1028
  case "start": {
@@ -516,117 +1036,480 @@ const normalize_align = function (params) {
516
1036
  break;
517
1037
  }
518
1038
  }
519
- if (freespace_direct >= axis_main.list_size) {
520
- params.reverse_align_set(false);
521
- axis_main.space_set(null);
522
- }
523
- else if (freespace_reverse >= axis_main.list_size) {
524
- params.reverse_align_set(true);
525
- axis_main.space_set(null);
526
- }
527
- else if (freespace_direct >= freespace_reverse) {
528
- params.reverse_align_set(false);
529
- axis_main.space_set(freespace_direct);
1039
+ if (freespace_direct >= axis_main.list_size || freespace_direct >= freespace_reverse) {
1040
+ params.reverse_set(false);
1041
+ axis_main.size_set(Math.min(freespace_direct, axis_main.list_size));
530
1042
  }
531
1043
  else {
532
- params.reverse_align_set(true);
533
- axis_main.space_set(freespace_reverse);
1044
+ params.reverse_set(true);
1045
+ axis_main.size_set(Math.min(freespace_reverse, axis_main.list_size));
534
1046
  }
535
1047
  };
536
- const CmpListAbs = r.memo(r.forwardRef((props, ref) => {
1048
+ const useListPosApiAbsolute = function (params) {
1049
+ const ctxstate_refs = useCtxStateRefs();
1050
+ const [align_reverse, align_reverse_set] = r.useState(false);
1051
+ const [justify_reverse, justify_reverse_set] = r.useState(false);
1052
+ const [width, width_set] = r.useState(null);
1053
+ const [height, height_set] = r.useState(null);
1054
+ return {
1055
+ size: r.useMemo(() => ({
1056
+ width: width,
1057
+ height: height,
1058
+ }), [width, height]),
1059
+ reverse: r.useMemo(() => ({
1060
+ align: align_reverse,
1061
+ justify: justify_reverse,
1062
+ }), [align_reverse, justify_reverse]),
1063
+ api: r.useMemo(() => ({
1064
+ clear: () => {
1065
+ align_reverse_set(false);
1066
+ justify_reverse_set(false);
1067
+ width_set(null);
1068
+ height_set(null);
1069
+ },
1070
+ rearrange: config => {
1071
+ const list = params.ref_list();
1072
+ const content = params.ref_content();
1073
+ const container = [...ctxstate_refs.rootref].map(ref => ref()).find(el => el !== null);
1074
+ if (list && container && content) {
1075
+ if (params.clmap_content._tracking) {
1076
+ content.classList.add(params.clmap_content._tracking);
1077
+ }
1078
+ const container_rect = container.getBoundingClientRect();
1079
+ const axis_main = {
1080
+ size_set: height_set,
1081
+ list_size: content.offsetHeight,
1082
+ screen_size: document.documentElement.clientHeight,
1083
+ container_pos: container_rect.y,
1084
+ container_size: container_rect.height,
1085
+ };
1086
+ const axis_cross = {
1087
+ size_set: width_set,
1088
+ list_size: content.offsetWidth,
1089
+ screen_size: document.documentElement.clientWidth,
1090
+ container_pos: container_rect.x,
1091
+ container_size: container_rect.width,
1092
+ };
1093
+ normalize_justify({
1094
+ axis_main,
1095
+ axis_cross,
1096
+ gap: config.gap,
1097
+ justify: config.justify,
1098
+ direction: config.direction,
1099
+ reverse_set: justify_reverse_set,
1100
+ });
1101
+ normalize_align({
1102
+ axis_main,
1103
+ axis_cross,
1104
+ align: config.align,
1105
+ direction: config.direction,
1106
+ reverse_set: align_reverse_set,
1107
+ });
1108
+ if (params.clmap_content._tracking) {
1109
+ content.classList.remove(params.clmap_content._tracking);
1110
+ }
1111
+ }
1112
+ },
1113
+ }), [ctxstate_refs.rootref, params.ref_list, params.ref_content, params.clmap_content])
1114
+ };
1115
+ };
1116
+
1117
+ const prop_clmap_def_listabs = {
1118
+ __qyuddn: "__qyuddn",
1119
+ listabs: "listabs",
1120
+ _transition_nosize: "_transition_nosize",
1121
+ _open: "_open",
1122
+ _justify_start: "_justify_start",
1123
+ _justify_end: "_justify_end",
1124
+ _align_start: "_align_start",
1125
+ _align_end: "_align_end",
1126
+ _align_center: "_align_center",
1127
+ _vertical: "_vertical",
1128
+ _horizontal: "_horizontal",
1129
+ };
1130
+
1131
+ const render_view_default$3 = function (props) {
1132
+ return jsx("div", { ...props });
1133
+ };
1134
+ const CmpListAbs = r.memo(r.forwardRef((props, f_ref) => {
537
1135
  const nprop_gap = props.gap ?? 0;
538
- const nprop_lazy = props.lazy ?? false;
539
- const nprop_align = nprop_align_new(props.align);
540
- const nprop_justify = nprop_justify_new(props.justify);
541
- const nprop_direction = nprop_direction_new(props.direction);
542
- const nprop_style = r.useMemo(() => (props.stylemodule ? stylemap_new_remap(stylemap, props.stylemodule) : stylemap), [props.stylemodule]);
543
- const ctxstate = r.useContext(CmpCtxState_Open);
544
- if (!ctxstate) {
545
- throw new Error(`Using DDN dependend component outside of DDN Context`);
546
- }
1136
+ const nprop_lazy = props.lazy ?? true;
1137
+ const nprop_align = prop_align_new(props.align);
1138
+ const nprop_justify = prop_justify_new(props.justify);
1139
+ const nprop_direction = prop_direction_new(props.direction);
1140
+ const nprop_render_view = props.render_view ?? render_view_default$3;
1141
+ const nprop_clmap = r.useMemo(() => prop_clmap_new(props.clmap, prop_clmap_def_listabs), [props.clmap]);
1142
+ const nprop_clmap_content = r.useMemo(() => prop_clmap_new(props.clmap_content, prop_clmap_def_content), [props.clmap_content]);
1143
+ const nprop_transition_nosize = props.transition_nosize ?? false;
547
1144
  const l_ref = r.useRef(null);
1145
+ const l_ref_content = r.useRef(null);
1146
+ const ref_list = useRefO(l_ref);
1147
+ const ref_content = useRefO(l_ref_content);
1148
+ const open = useOpenInfer({});
548
1149
  const [visible, visible_set] = r.useState(false);
549
- const [revalign, revalign_set] = r.useState(false);
550
- const [revjustify, revjustify_set] = r.useState(false);
551
- const [maxheight, maxheight_set] = r.useState(null);
552
- const [maxwidth, maxwidth_set] = r.useState(null);
553
- r.useLayoutEffect(() => {
554
- const list = l_ref.current;
555
- const container = ctxstate.ref.current;
556
- if (list && container && ctxstate.open) {
557
- const container_rect = container.getBoundingClientRect();
558
- const axis_main = {
559
- list_size: list.offsetHeight,
560
- space_set: maxheight_set,
561
- screen_size: document.documentElement.clientHeight,
562
- container_pos: container_rect.y,
563
- container_size: container_rect.height,
564
- };
565
- const axis_cross = {
566
- list_size: list.offsetWidth,
567
- space_set: maxwidth_set,
568
- screen_size: document.documentElement.clientWidth,
569
- container_pos: container_rect.x,
570
- container_size: container_rect.width,
571
- };
572
- normalize_justify({
573
- axis_main,
574
- axis_cross,
575
- gap: nprop_gap,
576
- justify: nprop_justify,
577
- direction: nprop_direction,
578
- reverse_align_set: revalign_set,
579
- reverse_justify_set: revjustify_set,
580
- });
581
- normalize_align({
582
- axis_main,
583
- axis_cross,
584
- align: nprop_align,
585
- direction: nprop_direction,
586
- reverse_align_set: revalign_set,
587
- reverse_justify_set: revjustify_set,
588
- });
1150
+ const listapi = useListPosApiAbsolute({ ref_list, ref_content, clmap_content: nprop_clmap_content });
1151
+ const ctxstate_content = useCtxStateInitContent({
1152
+ ref_content: l_ref_content,
1153
+ });
1154
+ useDDNListInfer({
1155
+ visible,
1156
+ });
1157
+ useDDNShardInfer({
1158
+ isolated: false,
1159
+ ref: useRefO(l_ref),
1160
+ });
1161
+ useListPosRearrange({
1162
+ open,
1163
+ api: listapi.api,
1164
+ active: visible || open,
1165
+ rearrange_config: props.rearrange,
1166
+ api_config: {
1167
+ gap: nprop_gap,
1168
+ align: nprop_align,
1169
+ justify: nprop_justify,
1170
+ direction: nprop_direction,
1171
+ },
1172
+ });
1173
+ useFocusCaptureInfer({
1174
+ open,
1175
+ ref_target: useRefO(ctxstate_content.ref_content),
1176
+ });
1177
+ const ref = useRefMerge(l_ref, f_ref);
1178
+ const children = r.useMemo(() => {
1179
+ if (!nprop_lazy || visible || open) {
1180
+ if (typeof props.children === "function") {
1181
+ return props.children();
1182
+ }
1183
+ return props.children;
589
1184
  }
590
- }, [ctxstate.open, ctxstate.ref, nprop_gap, nprop_align, nprop_justify, nprop_direction]);
591
- const mref = r.useMemo(() => {
592
- return (element) => {
593
- l_ref.current = element;
594
- if (ref) {
595
- if (typeof ref === "object") {
596
- ref.current = element;
1185
+ return null;
1186
+ }, [nprop_lazy, visible, open, props.children]);
1187
+ const view_align = listapi.reverse.align ? prop_align_new_reversed(nprop_align) : nprop_align;
1188
+ const view_justify = listapi.reverse.justify ? prop_justify_new_reversed(nprop_justify) : nprop_justify;
1189
+ return jsx(CmpCtxState_Content, { value: ctxstate_content, children: nprop_render_view({
1190
+ ref,
1191
+ children,
1192
+ className: cl(nprop_clmap.__qyuddn, nprop_clmap.listabs, open && nprop_clmap._open, nprop_transition_nosize && nprop_clmap._transition_nosize, view_align === "end" && nprop_clmap._align_end, view_align === "start" && nprop_clmap._align_start, view_align === "center" && nprop_clmap._align_center, view_justify === "end" && nprop_clmap._justify_end, view_justify === "start" && nprop_clmap._justify_start, nprop_direction === "hor" && nprop_clmap._horizontal, nprop_direction === "ver" && nprop_clmap._vertical, props.className),
1193
+ style: {
1194
+ ["--gap"]: `${nprop_gap}px`,
1195
+ ...cssprops_new_size({
1196
+ size: listapi.size,
1197
+ open: open,
1198
+ direction: nprop_direction,
1199
+ }),
1200
+ },
1201
+ onTransitionStart: ev => {
1202
+ props.event_transition_change?.(ev.nativeEvent.propertyName, true);
1203
+ if (ev.nativeEvent.propertyName === "opacity" && open) {
1204
+ visible_set(true);
1205
+ props.event_visible_change?.(true);
597
1206
  }
598
- else {
599
- ref(element);
1207
+ },
1208
+ onTransitionEnd: ev => {
1209
+ props.event_transition_change?.(ev.nativeEvent.propertyName, false);
1210
+ if (ev.nativeEvent.propertyName === "opacity" && !open) {
1211
+ listapi.api.clear();
1212
+ visible_set(false);
1213
+ props.event_visible_change?.(false);
600
1214
  }
601
- }
602
- };
603
- }, [ref]);
1215
+ },
1216
+ }) });
1217
+ }));
1218
+
1219
+ const prop_portal_new = function (portal) {
1220
+ if (typeof portal === "string") {
1221
+ return document.getElementById(portal) ?? null;
1222
+ }
1223
+ if (portal) {
1224
+ return portal;
1225
+ }
1226
+ return null;
1227
+ };
1228
+
1229
+ const render_view_default$2 = function (props) {
1230
+ return jsx("div", { ...props });
1231
+ };
1232
+ const CmpListPortal = r.memo(r.forwardRef((props, f_ref) => {
1233
+ const nprop_gap = props.gap ?? 0;
1234
+ const nprop_lazy = props.lazy ?? true;
1235
+ const nprop_align = prop_align_new(props.align);
1236
+ const nprop_portal = prop_portal_new(props.portal);
1237
+ const nprop_justify = prop_justify_new(props.justify);
1238
+ const nprop_direction = prop_direction_new(props.direction);
1239
+ const nprop_transition_nopos = props.transition_nopos ?? false;
1240
+ const nprop_transition_nosize = props.transition_nosize ?? false;
1241
+ const nprop_render_view = props.render_view ?? render_view_default$2;
1242
+ const nprop_clmap = r.useMemo(() => prop_clmap_new(props.clmap, prop_clmap_def_listfix), [props.clmap]);
1243
+ const nprop_clmap_content = r.useMemo(() => prop_clmap_new(props.clmap_content, prop_clmap_def_content), [props.clmap_content]);
1244
+ const l_ref = r.useRef(null);
1245
+ const l_ref_content = r.useRef(null);
1246
+ const ref_list = useRefO(l_ref);
1247
+ const ref_content = useRefO(l_ref_content);
1248
+ const open = useOpenInfer({});
1249
+ const [visible, visible_set] = r.useState(false);
1250
+ const listapi = useListPosApiFixed({ ref_list, ref_content, clmap_content: nprop_clmap_content });
1251
+ const ctxstate_content = useCtxStateInitContent({
1252
+ ref_content: l_ref_content,
1253
+ });
1254
+ useDDNListInfer({
1255
+ visible: visible || open,
1256
+ });
1257
+ useDDNShardInfer({
1258
+ isolated: true,
1259
+ ref: useRefO(l_ref),
1260
+ });
1261
+ useListPosRearrange({
1262
+ open,
1263
+ api: listapi.api,
1264
+ active: visible || open,
1265
+ rearrange_config: props.rearrange,
1266
+ api_config: {
1267
+ gap: nprop_gap,
1268
+ align: nprop_align,
1269
+ justify: nprop_justify,
1270
+ direction: nprop_direction,
1271
+ },
1272
+ });
1273
+ useFocusCaptureInfer({
1274
+ open,
1275
+ ref_target: useRefO(ctxstate_content.ref_content),
1276
+ });
1277
+ const ref = useRefMerge(l_ref, f_ref);
604
1278
  const children = r.useMemo(() => {
605
- if (!nprop_lazy || visible || ctxstate.open) {
1279
+ if (!nprop_lazy || visible || open) {
606
1280
  if (typeof props.children === "function") {
607
1281
  return props.children();
608
1282
  }
609
1283
  return props.children;
610
1284
  }
611
1285
  return null;
612
- }, [nprop_lazy, visible, ctxstate.open, props.children]);
613
- return jsx("div", { ref: mref, tabIndex: props.tabIndex, className: cl("__qyuddn", props.className, nprop_style.listabs, ctxstate.open && nprop_style.listabs_open, ((nprop_align === "end" && !revalign) || (nprop_align === "start" && revalign)) && nprop_style.listabs_align_end, ((nprop_align === "start" && !revalign) || (nprop_align === "end" && revalign)) && nprop_style.listabs_align_start, nprop_align === "center" && nprop_style.listabs_align_center, ((nprop_justify === "end") !== revjustify) && nprop_style.listabs_justify_end, ((nprop_justify === "start") !== revjustify) && nprop_style.listabs_justify_start, nprop_direction === "hor" && nprop_style.listabs_horizontal, nprop_direction === "ver" && nprop_style.listabs_vertical), style: {
614
- ["--gap"]: `${nprop_gap}px`,
615
- maxWidth: maxwidth === null ? undefined : `${maxwidth}px`,
616
- maxHeight: maxheight === null ? undefined : `${maxheight}px`,
617
- }, onTransitionStart: ev => {
618
- if (ev.nativeEvent.propertyName === "opacity" && ctxstate.open) {
619
- visible_set(true);
1286
+ }, [nprop_lazy, visible, open, props.children]);
1287
+ const view_align = listapi.reverse.align ? prop_align_new_reversed(nprop_align) : nprop_align;
1288
+ const view_justify = listapi.reverse.justify ? prop_justify_new_reversed(nprop_justify) : nprop_justify;
1289
+ if (nprop_portal) {
1290
+ return rdom.createPortal(jsx(CmpCtxState_Content.Provider, { value: ctxstate_content, children: nprop_render_view({
1291
+ ref,
1292
+ children,
1293
+ className: cl(nprop_clmap.__qyuddn, nprop_clmap.listfix, open && nprop_clmap._open, nprop_transition_nopos && nprop_clmap._transition_nopos, nprop_transition_nosize && nprop_clmap._transition_nosize, view_align === "end" && nprop_clmap._align_end, view_align === "start" && nprop_clmap._align_start, view_align === "center" && nprop_clmap._align_center, view_justify === "end" && nprop_clmap._justify_end, view_justify === "start" && nprop_clmap._justify_start, nprop_direction === "hor" && nprop_clmap._horizontal, nprop_direction === "ver" && nprop_clmap._vertical, props.className),
1294
+ style: {
1295
+ ["--gap"]: `${nprop_gap}px`,
1296
+ ...cssprops_new_position(listapi.position),
1297
+ ...cssprops_new_size({
1298
+ size: listapi.size,
1299
+ open: open,
1300
+ direction: nprop_direction,
1301
+ }),
1302
+ },
1303
+ onTransitionStart: ev => {
1304
+ props.event_transition_change?.(ev.nativeEvent.propertyName, true);
1305
+ if (ev.nativeEvent.propertyName === "opacity" && open) {
1306
+ visible_set(true);
1307
+ props.event_visible_change?.(true);
1308
+ }
1309
+ },
1310
+ onTransitionEnd: ev => {
1311
+ props.event_transition_change?.(ev.nativeEvent.propertyName, false);
1312
+ if (ev.nativeEvent.propertyName === "opacity" && !open) {
1313
+ listapi.api.clear();
1314
+ visible_set(false);
1315
+ props.event_visible_change?.(false);
1316
+ }
1317
+ },
1318
+ }) }), nprop_portal);
1319
+ }
1320
+ return null;
1321
+ }));
1322
+
1323
+ const render_view_default$1 = function (props) {
1324
+ return jsx("div", { ...props });
1325
+ };
1326
+ const CmpContent = r.memo(r.forwardRef((props, f_ref) => {
1327
+ const nprop_container = props.render_view ?? render_view_default$1;
1328
+ const nprop_clmap = r.useMemo(() => prop_clmap_new(props.clmap, prop_clmap_def_content), [props.clmap]);
1329
+ const ctxstate_content = useCtxStateContent();
1330
+ const ref = useRefMerge(f_ref, ctxstate_content.ref_content);
1331
+ return jsxs(Fragment, { children: [props.focus_noguards
1332
+ ? null
1333
+ : jsx("input", { "data-focusguard": true, tabIndex: 0, className: cl(nprop_clmap.__qyuddn, nprop_clmap.focusguard) }), nprop_container({
1334
+ ref: ref,
1335
+ children: props.children,
1336
+ tabIndex: 0,
1337
+ className: cl(nprop_clmap.__qyuddn, nprop_clmap.content, props.className),
1338
+ }), props.focus_noguards
1339
+ ? null
1340
+ : jsx("input", { "data-focusguard": true, tabIndex: 0, className: cl(nprop_clmap.__qyuddn, nprop_clmap.focusguard) })] });
1341
+ }));
1342
+
1343
+ const refs_unpack = function* (src) {
1344
+ for (const ref of src) {
1345
+ const element = ref();
1346
+ if (element) {
1347
+ yield element;
1348
+ }
1349
+ }
1350
+ };
1351
+ const element_outside = function (element, shards) {
1352
+ for (const ref of shards) {
1353
+ if (ref === element || ref.contains(element)) {
1354
+ return false;
1355
+ }
1356
+ }
1357
+ return true;
1358
+ };
1359
+ const useCloseEvtRoot = function (params) {
1360
+ const { ctxstate_open, ctxstate_refs, ctxstate_config } = params;
1361
+ const nconfig_blur = ctxstate_config.closeevt.blur ?? true;
1362
+ const nconfig_click = ctxstate_config.closeevt.click ?? true;
1363
+ const nconfig_resize = ctxstate_config.closeevt.resize ?? true;
1364
+ const nconfig_escape = ctxstate_config.closeevt.escape ?? true;
1365
+ const open = useOpen({ ctxstate_open, ctxstate_refs, });
1366
+ r.useEffect(() => {
1367
+ if (params.active && open) {
1368
+ const controller = new AbortController();
1369
+ if (nconfig_blur) {
1370
+ document.addEventListener("focusin", ev => {
1371
+ if (ev.target instanceof Element) {
1372
+ if (ev.target.hasAttribute("data-focusguard")) {
1373
+ if (element_outside(ev.target, refs_unpack(ctxstate_refs.register.it_down))) {
1374
+ ctxstate_open.open_set(false);
1375
+ }
1376
+ }
1377
+ else if (element_outside(ev.target, refs_unpack(ctxstate_refs.register.it_context))) {
1378
+ ctxstate_open.open_set(false);
1379
+ }
1380
+ }
1381
+ }, { signal: controller.signal });
620
1382
  }
621
- }, onTransitionEnd: ev => {
622
- if (ev.nativeEvent.propertyName === "opacity" && !ctxstate.open) {
623
- revalign_set(false);
624
- revjustify_set(false);
625
- maxwidth_set(null);
626
- maxheight_set(null);
627
- visible_set(false);
1383
+ if (nconfig_click) {
1384
+ document.addEventListener("click", ev => {
1385
+ const shards = refs_unpack(ctxstate_refs.register.it_context);
1386
+ if (ev.target instanceof Element) {
1387
+ if (element_outside(ev.target, shards)) {
1388
+ ctxstate_open.open_set(false);
1389
+ }
1390
+ }
1391
+ }, { signal: controller.signal });
628
1392
  }
629
- }, children: children });
1393
+ if (nconfig_escape) {
1394
+ document.addEventListener("keydown", ev => {
1395
+ if (ev.key.toLowerCase() === "escape") {
1396
+ ctxstate_open.open_set(false);
1397
+ }
1398
+ }, { signal: controller.signal });
1399
+ }
1400
+ if (nconfig_resize) {
1401
+ window.addEventListener("resize", () => {
1402
+ ctxstate_open.open_set(false);
1403
+ }, { signal: controller.signal });
1404
+ }
1405
+ return () => {
1406
+ controller.abort();
1407
+ };
1408
+ }
1409
+ }, [
1410
+ open,
1411
+ ctxstate_refs.register,
1412
+ ctxstate_open.open_set,
1413
+ params.active,
1414
+ nconfig_click,
1415
+ nconfig_resize,
1416
+ nconfig_escape,
1417
+ nconfig_blur,
1418
+ ]);
1419
+ };
1420
+
1421
+ const prop_clmap_def_container = {
1422
+ __qyuddn: "__qyuddn",
1423
+ container: "container",
1424
+ };
1425
+
1426
+ const render_view_default = function (props) {
1427
+ return jsx("div", { ...props });
1428
+ };
1429
+ const CmpContainer = r.memo(r.forwardRef((props, f_ref) => {
1430
+ const nprop_clmap = r.useMemo(() => prop_clmap_new(props.clmap, prop_clmap_def_container), [props.clmap]);
1431
+ const nprop_render_view = props.render_view ?? render_view_default;
1432
+ const l_ref = r.useRef(null);
1433
+ const ctxstate_open = useCtxStateInitOpen({
1434
+ open: props.open,
1435
+ open_set: props.open_set,
1436
+ });
1437
+ const ctxstate_refs = useCtxStateInitRefs({
1438
+ container_real: true
1439
+ });
1440
+ const ctxstate_config = useCtxStateInitConfig({
1441
+ focus: props.focus,
1442
+ closeevt: props.closeevt,
1443
+ });
1444
+ useDDNRoot({
1445
+ active: true,
1446
+ ref: useRefO(l_ref),
1447
+ ctxstate_refs,
1448
+ });
1449
+ useDDNShard({
1450
+ isolated: true,
1451
+ ref: useRefO(l_ref),
1452
+ ctxstate_refs,
1453
+ ctxstate_open,
1454
+ ctxstate_config,
1455
+ });
1456
+ useCloseEvtRoot({
1457
+ active: true,
1458
+ ctxstate_open,
1459
+ ctxstate_refs,
1460
+ ctxstate_config,
1461
+ });
1462
+ const ref = useRefMerge(l_ref, f_ref);
1463
+ return jsx(CmpCtxState_Config.Provider, { value: ctxstate_config, children: jsx(CmpCtxState_Open.Provider, { value: ctxstate_open, children: jsx(CmpCtxState_Refs.Provider, { value: ctxstate_refs, children: nprop_render_view({
1464
+ ref,
1465
+ children: props.children,
1466
+ className: cl(nprop_clmap.__qyuddn, nprop_clmap.container, props.className),
1467
+ }) }) }) });
630
1468
  }));
631
1469
 
632
- export { CmpButton, CmpContainer, CmpCtxState_Open, CmpListAbs, CmpListFix, useDropdownCloseEvents };
1470
+ const CmpContainerVirtual = r.memo((props) => {
1471
+ const ctxstate_open = useCtxStateInitOpen({
1472
+ open: props.open,
1473
+ open_set: props.open_set,
1474
+ });
1475
+ const ctxstate_refs = useCtxStateInitRefs({
1476
+ container_real: false,
1477
+ });
1478
+ const ctxstate_config = useCtxStateInitConfig({
1479
+ focus: props.focus,
1480
+ closeevt: props.closeevt,
1481
+ });
1482
+ useCloseEvtRoot({
1483
+ active: true,
1484
+ ctxstate_refs,
1485
+ ctxstate_open,
1486
+ ctxstate_config,
1487
+ });
1488
+ return jsx(CmpCtxState_Config.Provider, { value: ctxstate_config, children: jsx(CmpCtxState_Open.Provider, { value: ctxstate_open, children: jsx(CmpCtxState_Refs.Provider, { value: ctxstate_refs, children: props.children }) }) });
1489
+ });
1490
+
1491
+ const useCloseEvtRootInfer = function (params) {
1492
+ const ctxstate_refs = useCtxStateRefs();
1493
+ const ctxstate_open = useCtxStateOpen();
1494
+ const ctxstate_config = useCtxStateConfig();
1495
+ useCloseEvtRoot({
1496
+ ...params,
1497
+ ctxstate_refs,
1498
+ ctxstate_open,
1499
+ ctxstate_config,
1500
+ });
1501
+ };
1502
+
1503
+ const useCloseEvtShardInfer = function (params) {
1504
+ const ctxstate_refs = useCtxStateRefs();
1505
+ const ctxstate_open = useCtxStateOpen();
1506
+ const ctxstate_config = useCtxStateConfig();
1507
+ useCloseEvtShard({
1508
+ ...params,
1509
+ ctxstate_refs,
1510
+ ctxstate_open,
1511
+ ctxstate_config,
1512
+ });
1513
+ };
1514
+
1515
+ export { CmpButton, CmpButtonVirtual, CmpContainer, CmpContainerVirtual, CmpContent, CmpCtxState_Config, CmpCtxState_Content, CmpCtxState_Open, CmpCtxState_Refs, CmpListAbs, CmpListFix, CmpListPortal, cssprops_new_position, cssprops_new_size, prop_align_new, prop_align_new_reversed, prop_clmap_def_container, prop_clmap_def_content, prop_clmap_def_listabs, prop_clmap_def_listfix, prop_clmap_new, prop_direction_new, prop_justify_new, prop_justify_new_reversed, prop_portal_new, useCloseEvtRoot, useCloseEvtRootInfer, useCloseEvtShard, useCloseEvtShardInfer, useCtxStateConfig, useCtxStateContent, useCtxStateInitConfig, useCtxStateInitContent, useCtxStateInitOpen, useCtxStateInitRefs, useCtxStateOpen, useCtxStateRefs, useDDNList, useDDNListInfer, useDDNRoot, useDDNRootInfer, useDDNShard, useDDNShardInfer, useFocusCapture, useFocusCaptureInfer, useListPosApiAbsolute, useListPosApiFixed, useListPosRearrange, useOpen, useOpenInfer };