@qyu/reactcmp-dropdown 1.2.0 → 2.0.1

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