@adam-milo/ui 1.0.23 → 1.0.24
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.
- package/dist/index.cjs +1 -1
- package/dist/index.js +18 -9
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +53 -59
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +50 -104
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +108 -76
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +77 -26
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +22 -462
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +466 -109
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +111 -30
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +42 -12
- package/dist/index18.cjs +1 -0
- package/dist/index18.js +14 -0
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +20 -299
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +298 -13
- package/dist/index22.cjs +1 -0
- package/dist/index22.js +16 -0
- package/dist/index25.cjs +1 -0
- package/dist/index25.js +1193 -0
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +2 -2
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +7 -19
- package/dist/index36.cjs +1 -0
- package/dist/index36.js +21 -0
- package/dist/index38.cjs +1 -0
- package/dist/index38.js +6 -0
- package/dist/index39.cjs +1 -0
- package/dist/index39.js +11 -0
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +1 -1
- package/dist/index40.cjs +1 -0
- package/dist/index40.js +70 -0
- package/dist/index41.cjs +1 -0
- package/dist/index41.js +39 -0
- package/dist/index42.cjs +1 -0
- package/dist/index42.js +64 -0
- package/dist/index43.cjs +1 -0
- package/dist/index43.js +10 -0
- package/dist/index44.cjs +1 -0
- package/dist/index44.js +212 -0
- package/dist/index45.cjs +1 -0
- package/dist/index45.js +29 -0
- package/dist/index46.cjs +1 -0
- package/dist/index46.js +208 -0
- package/dist/index47.cjs +1 -0
- package/dist/index47.js +14 -0
- package/dist/index48.cjs +1 -0
- package/dist/index48.js +293 -0
- package/dist/index49.cjs +1 -0
- package/dist/index49.js +18 -0
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +1 -1
- package/dist/index50.cjs +1 -0
- package/dist/index50.js +43 -0
- package/dist/index51.cjs +1 -0
- package/dist/index51.js +89 -0
- package/dist/index52.cjs +1 -0
- package/dist/index52.js +14 -0
- package/dist/index53.cjs +1 -0
- package/dist/index53.js +71 -0
- package/dist/index54.cjs +1 -0
- package/dist/index54.js +6 -0
- package/dist/index55.cjs +1 -0
- package/dist/index55.js +14 -0
- package/dist/index56.cjs +1 -0
- package/dist/index56.js +34 -0
- package/dist/index57.cjs +1 -0
- package/dist/index57.js +122 -0
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +11 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +17 -0
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +2 -2
- package/dist/index60.cjs +1 -0
- package/dist/index60.js +297 -0
- package/dist/index61.cjs +1 -0
- package/dist/index61.js +25 -0
- package/dist/index62.cjs +1 -0
- package/dist/index62.js +39 -0
- package/dist/index63.cjs +1 -0
- package/dist/index63.js +625 -0
- package/dist/index64.cjs +1 -0
- package/dist/index64.js +39 -0
- package/dist/index65.cjs +1 -0
- package/dist/index65.js +38 -0
- package/dist/index66.cjs +1 -0
- package/dist/index66.js +7 -0
- package/dist/index67.cjs +1 -0
- package/dist/index67.js +10 -0
- package/dist/index68.cjs +1 -0
- package/dist/index68.js +5 -0
- package/dist/index69.cjs +1 -0
- package/dist/index69.js +35 -0
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +1 -1
- package/dist/index70.cjs +1 -0
- package/dist/index70.js +180 -0
- package/dist/index71.cjs +1 -0
- package/dist/index71.js +21 -0
- package/dist/index72.cjs +1 -0
- package/dist/index72.js +721 -0
- package/dist/index73.cjs +1 -0
- package/dist/index73.js +154 -0
- package/dist/index74.cjs +1 -0
- package/dist/index74.js +173 -0
- package/dist/index75.cjs +1 -0
- package/dist/index75.js +88 -0
- package/dist/index76.cjs +1 -0
- package/dist/index76.js +47 -0
- package/dist/index77.cjs +1 -0
- package/dist/index77.js +13 -0
- package/dist/index78.cjs +1 -0
- package/dist/index78.js +19 -0
- package/dist/index79.cjs +1 -0
- package/dist/index79.js +102 -0
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +1 -1
- package/dist/index80.cjs +1 -0
- package/dist/index80.js +11 -0
- package/dist/index81.cjs +1 -0
- package/dist/index81.js +29 -0
- package/dist/index82.cjs +1 -0
- package/dist/index82.js +16 -0
- package/dist/index83.cjs +1 -0
- package/dist/index83.js +48 -0
- package/dist/index84.cjs +1 -0
- package/dist/index84.js +9 -0
- package/dist/index85.cjs +1 -0
- package/dist/index85.js +37 -0
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +224 -35
- package/dist/src/components/forms/select/Select.component.d.ts +100 -0
- package/dist/src/components/forms/select/Select.component.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/dist/index19.cjs +0 -1
- package/dist/index19.js +0 -22
- package/dist/index30.cjs +0 -1
- package/dist/index30.js +0 -9
package/dist/index3.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),t=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),t=require("./index20.cjs"),i=require("./index21.cjs"),r=a.forwardRef(({validateEmail:r=!0,invalidEmailMessage:l="Not a valid email address",validate:d,"data-cy":s,"data-testid":u,...n},c)=>{const o=a.useCallback(e=>{if(e)return t.validate(e)?void 0:l},[l]),m=a.useCallback(e=>r?d?o(e)||d(e):o(e):null==d?void 0:d(e),[r,d,o]);return e.jsx(i.Input,{ref:c,type:"email",validate:m,"data-cy":s||"email-input","data-testid":u||"email-input",...n})});r.displayName="EmailInput",exports.EmailInput=r;
|
package/dist/index3.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useCallback } from "react";
|
|
3
|
-
import { validate } from "./
|
|
4
|
-
import { Input } from "./
|
|
3
|
+
import { validate } from "./index20.js";
|
|
4
|
+
import { Input } from "./index21.js";
|
|
5
5
|
const EmailInput = forwardRef(
|
|
6
6
|
({
|
|
7
7
|
validateEmail = true,
|
package/dist/index33.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});process.env.NODE_ENV;exports.devWarn=e=>{};
|
package/dist/index33.js
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
func.apply(context, args);
|
|
8
|
-
timeoutId = null;
|
|
9
|
-
}, wait);
|
|
10
|
-
};
|
|
11
|
-
debounced.cancel = () => {
|
|
12
|
-
if (timeoutId) {
|
|
13
|
-
clearTimeout(timeoutId);
|
|
14
|
-
timeoutId = null;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
return debounced;
|
|
18
|
-
}
|
|
1
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
2
|
+
const devWarn = (message) => {
|
|
3
|
+
if (isDev) {
|
|
4
|
+
console.warn(message);
|
|
5
|
+
}
|
|
6
|
+
};
|
|
19
7
|
export {
|
|
20
|
-
|
|
8
|
+
devWarn
|
|
21
9
|
};
|
package/dist/index36.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.debounce=function(e,t){let l=null;const n=function(...n){l&&clearTimeout(l);const o=this;l=setTimeout(()=>{e.apply(o,n),l=null},t)};return n.cancel=()=>{l&&(clearTimeout(l),l=null)},n};
|
package/dist/index36.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function debounce(func, wait) {
|
|
2
|
+
let timeoutId = null;
|
|
3
|
+
const debounced = function(...args) {
|
|
4
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
5
|
+
const context = this;
|
|
6
|
+
timeoutId = setTimeout(() => {
|
|
7
|
+
func.apply(context, args);
|
|
8
|
+
timeoutId = null;
|
|
9
|
+
}, wait);
|
|
10
|
+
};
|
|
11
|
+
debounced.cancel = () => {
|
|
12
|
+
if (timeoutId) {
|
|
13
|
+
clearTimeout(timeoutId);
|
|
14
|
+
timeoutId = null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return debounced;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
debounce
|
|
21
|
+
};
|
package/dist/index38.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.clamp=function(t,[e,r]){return Math.min(r,Math.max(e,t))};
|
package/dist/index38.js
ADDED
package/dist/index39.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.composeEventHandlers=function(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(null==e||e(r),!1===n||!r.defaultPrevented)return null==t?void 0:t(r)}};
|
package/dist/index39.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
2
|
+
return function handleEvent(event) {
|
|
3
|
+
originalEventHandler == null ? void 0 : originalEventHandler(event);
|
|
4
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
5
|
+
return ourEventHandler == null ? void 0 : ourEventHandler(event);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
composeEventHandlers
|
|
11
|
+
};
|
package/dist/index4.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),s=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),s=require("./index21.cjs"),r=t.forwardRef(({showToggle:t=!0,"data-cy":r,"data-testid":a,...o},d)=>e.jsx(s.Input,{ref:d,type:"password",showPasswordToggle:t,"data-cy":r||"password-input","data-testid":a||"password-input",...o}));r.displayName="PasswordInput",exports.PasswordInput=r;
|
package/dist/index4.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import { Input } from "./
|
|
3
|
+
import { Input } from "./index21.js";
|
|
4
4
|
const PasswordInput = forwardRef(
|
|
5
5
|
({ showToggle = true, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
|
|
6
6
|
return /* @__PURE__ */ jsx(
|
package/dist/index40.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("./index42.cjs"),t=require("./index41.cjs"),o=require("./index51.cjs"),c=require("react/jsx-runtime");exports.createCollection=function(n){const l=n+"CollectionProvider",[i,s]=r.createContextScope(l),[u,a]=i(l,{collectionRef:{current:null},itemMap:new Map}),f=r=>{const{scope:t,children:o}=r,n=e.useRef(null),l=e.useRef(new Map).current;return c.jsx(u,{scope:t,itemMap:l,collectionRef:n,children:o})};f.displayName=l;const d=n+"CollectionSlot",p=o.createSlot(d),m=e.forwardRef((e,r)=>{const{scope:o,children:n}=e,l=a(d,o),i=t.useComposedRefs(r,l.collectionRef);return c.jsx(p,{ref:i,children:n})});m.displayName=d;const x=n+"CollectionItemSlot",R="data-radix-collection-item",C=o.createSlot(x),S=e.forwardRef((r,o)=>{const{scope:n,children:l,...i}=r,s=e.useRef(null),u=t.useComposedRefs(o,s),f=a(x,n);return e.useEffect(()=>(f.itemMap.set(s,{ref:s,...i}),()=>{f.itemMap.delete(s)})),c.jsx(C,{[R]:"",ref:u,children:l})});return S.displayName=x,[{Provider:f,Slot:m,ItemSlot:S},function(r){const t=a(n+"CollectionConsumer",r);return e.useCallback(()=>{const e=t.collectionRef.current;if(!e)return[];const r=Array.from(e.querySelectorAll(`[${R}]`));return Array.from(t.itemMap.values()).sort((e,t)=>r.indexOf(e.ref.current)-r.indexOf(t.ref.current))},[t.collectionRef,t.itemMap])},s]};
|
package/dist/index40.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { createContextScope } from "./index42.js";
|
|
3
|
+
import { useComposedRefs } from "./index41.js";
|
|
4
|
+
import { createSlot } from "./index51.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
function createCollection(name) {
|
|
7
|
+
const PROVIDER_NAME = name + "CollectionProvider";
|
|
8
|
+
const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);
|
|
9
|
+
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
|
|
10
|
+
PROVIDER_NAME,
|
|
11
|
+
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
|
|
12
|
+
);
|
|
13
|
+
const CollectionProvider = (props) => {
|
|
14
|
+
const { scope, children } = props;
|
|
15
|
+
const ref = React__default.useRef(null);
|
|
16
|
+
const itemMap = React__default.useRef(/* @__PURE__ */ new Map()).current;
|
|
17
|
+
return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
18
|
+
};
|
|
19
|
+
CollectionProvider.displayName = PROVIDER_NAME;
|
|
20
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
21
|
+
const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);
|
|
22
|
+
const CollectionSlot = React__default.forwardRef(
|
|
23
|
+
(props, forwardedRef) => {
|
|
24
|
+
const { scope, children } = props;
|
|
25
|
+
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
26
|
+
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
27
|
+
return /* @__PURE__ */ jsx(CollectionSlotImpl, { ref: composedRefs, children });
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
31
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
32
|
+
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
33
|
+
const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);
|
|
34
|
+
const CollectionItemSlot = React__default.forwardRef(
|
|
35
|
+
(props, forwardedRef) => {
|
|
36
|
+
const { scope, children, ...itemData } = props;
|
|
37
|
+
const ref = React__default.useRef(null);
|
|
38
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
39
|
+
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
40
|
+
React__default.useEffect(() => {
|
|
41
|
+
context.itemMap.set(ref, { ref, ...itemData });
|
|
42
|
+
return () => void context.itemMap.delete(ref);
|
|
43
|
+
});
|
|
44
|
+
return /* @__PURE__ */ jsx(CollectionItemSlotImpl, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
48
|
+
function useCollection(scope) {
|
|
49
|
+
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
50
|
+
const getItems = React__default.useCallback(() => {
|
|
51
|
+
const collectionNode = context.collectionRef.current;
|
|
52
|
+
if (!collectionNode) return [];
|
|
53
|
+
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
54
|
+
const items = Array.from(context.itemMap.values());
|
|
55
|
+
const orderedItems = items.sort(
|
|
56
|
+
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
|
57
|
+
);
|
|
58
|
+
return orderedItems;
|
|
59
|
+
}, [context.collectionRef, context.itemMap]);
|
|
60
|
+
return getItems;
|
|
61
|
+
}
|
|
62
|
+
return [
|
|
63
|
+
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
|
64
|
+
useCollection,
|
|
65
|
+
createCollectionScope
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
createCollection
|
|
70
|
+
};
|
package/dist/index41.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const t=e(require("react"));function n(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function o(...e){return t=>{let o=!1;const r=e.map(e=>{const r=n(e,t);return o||"function"!=typeof r||(o=!0),r});if(o)return()=>{for(let t=0;t<r.length;t++){const o=r[t];"function"==typeof o?o():n(e[t],null)}}}}exports.composeRefs=o,exports.useComposedRefs=function(...e){return t.useCallback(o(...e),e)};
|
package/dist/index41.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
function setRef(ref, value) {
|
|
3
|
+
if (typeof ref === "function") {
|
|
4
|
+
return ref(value);
|
|
5
|
+
} else if (ref !== null && ref !== void 0) {
|
|
6
|
+
ref.current = value;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function composeRefs(...refs) {
|
|
10
|
+
return (node) => {
|
|
11
|
+
let hasCleanup = false;
|
|
12
|
+
const cleanups = refs.map((ref) => {
|
|
13
|
+
const cleanup = setRef(ref, node);
|
|
14
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
15
|
+
hasCleanup = true;
|
|
16
|
+
}
|
|
17
|
+
return cleanup;
|
|
18
|
+
});
|
|
19
|
+
if (hasCleanup) {
|
|
20
|
+
return () => {
|
|
21
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
22
|
+
const cleanup = cleanups[i];
|
|
23
|
+
if (typeof cleanup == "function") {
|
|
24
|
+
cleanup();
|
|
25
|
+
} else {
|
|
26
|
+
setRef(refs[i], null);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function useComposedRefs(...refs) {
|
|
34
|
+
return React.useCallback(composeRefs(...refs), refs);
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
composeRefs,
|
|
38
|
+
useComposedRefs
|
|
39
|
+
};
|
package/dist/index42.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("react/jsx-runtime");function o(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const o in e)if("default"!==o){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}return t.default=e,Object.freeze(t)}const n=o(e);function r(...e){const t=e[0];if(1===e.length)return t;const o=()=>{const o=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=o.reduce((t,{useScope:o,scopeName:n})=>({...t,...o(e)[`__scope${n}`]}),{});return n.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return o.scopeName=t.scopeName,o}exports.createContextScope=function(e,o=[]){let c=[];const u=()=>{const t=c.map(e=>n.createContext(e));return function(o){const r=(null==o?void 0:o[e])||t;return n.useMemo(()=>({[`__scope${e}`]:{...o,[e]:r}}),[o,r])}};return u.scopeName=e,[function(o,r){const u=n.createContext(r),s=c.length;c=[...c,r];const i=o=>{var r;const{scope:c,children:i,...l}=o,a=(null==(r=null==c?void 0:c[e])?void 0:r[s])||u,p=n.useMemo(()=>l,Object.values(l));return t.jsx(a.Provider,{value:p,children:i})};return i.displayName=o+"Provider",[i,function(t,c){var i;const l=(null==(i=null==c?void 0:c[e])?void 0:i[s])||u,a=n.useContext(l);if(a)return a;if(void 0!==r)return r;throw new Error(`\`${t}\` must be used within \`${o}\``)}]},r(u,...o)]};
|
package/dist/index42.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
4
|
+
let defaultContexts = [];
|
|
5
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
6
|
+
const BaseContext = React.createContext(defaultContext);
|
|
7
|
+
const index = defaultContexts.length;
|
|
8
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
9
|
+
const Provider = (props) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const { scope, children, ...context } = props;
|
|
12
|
+
const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index]) || BaseContext;
|
|
13
|
+
const value = React.useMemo(() => context, Object.values(context));
|
|
14
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
|
|
15
|
+
};
|
|
16
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
17
|
+
function useContext2(consumerName, scope) {
|
|
18
|
+
var _a;
|
|
19
|
+
const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index]) || BaseContext;
|
|
20
|
+
const context = React.useContext(Context);
|
|
21
|
+
if (context) return context;
|
|
22
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
23
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
24
|
+
}
|
|
25
|
+
return [Provider, useContext2];
|
|
26
|
+
}
|
|
27
|
+
const createScope = () => {
|
|
28
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
29
|
+
return React.createContext(defaultContext);
|
|
30
|
+
});
|
|
31
|
+
return function useScope(scope) {
|
|
32
|
+
const contexts = (scope == null ? void 0 : scope[scopeName]) || scopeContexts;
|
|
33
|
+
return React.useMemo(
|
|
34
|
+
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
35
|
+
[scope, contexts]
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
createScope.scopeName = scopeName;
|
|
40
|
+
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
41
|
+
}
|
|
42
|
+
function composeContextScopes(...scopes) {
|
|
43
|
+
const baseScope = scopes[0];
|
|
44
|
+
if (scopes.length === 1) return baseScope;
|
|
45
|
+
const createScope = () => {
|
|
46
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
47
|
+
useScope: createScope2(),
|
|
48
|
+
scopeName: createScope2.scopeName
|
|
49
|
+
}));
|
|
50
|
+
return function useComposedScopes(overrideScopes) {
|
|
51
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
52
|
+
const scopeProps = useScope(overrideScopes);
|
|
53
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
54
|
+
return { ...nextScopes2, ...currentScope };
|
|
55
|
+
}, {});
|
|
56
|
+
return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
createScope.scopeName = baseScope.scopeName;
|
|
60
|
+
return createScope;
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
createContextScope
|
|
64
|
+
};
|
package/dist/index43.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");function t(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}require("react/jsx-runtime");const r=t(e);var o=r.createContext(void 0);exports.useDirection=function(e){const t=r.useContext(o);return e||t||"ltr"};
|
package/dist/index43.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import "react/jsx-runtime";
|
|
3
|
+
var DirectionContext = React.createContext(void 0);
|
|
4
|
+
function useDirection(localDir) {
|
|
5
|
+
const globalDir = React.useContext(DirectionContext);
|
|
6
|
+
return localDir || globalDir || "ltr";
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
useDirection
|
|
10
|
+
};
|
package/dist/index44.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./index39.cjs"),n=require("./index50.cjs"),r=require("./index41.cjs"),s=require("./index52.cjs"),i=require("./index59.cjs"),o=require("react/jsx-runtime");function u(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const a=u(e);var l,c="dismissableLayer.update",d="dismissableLayer.pointerDownOutside",v="dismissableLayer.focusOutside",f=a.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),b=a.forwardRef((e,u)=>{const{disableOutsidePointerEvents:b=!1,onEscapeKeyDown:m,onPointerDownOutside:y,onFocusOutside:h,onInteractOutside:w,onDismiss:D,...C}=e,g=a.useContext(f),[O,P]=a.useState(null),L=(null==O?void 0:O.ownerDocument)??(null==globalThis?void 0:globalThis.document),[,x]=a.useState({}),j=r.useComposedRefs(u,e=>P(e)),T=Array.from(g.layers),[R]=[...g.layersWithOutsidePointerEventsDisabled].slice(-1),S=T.indexOf(R),q=O?T.indexOf(O):-1,W=g.layersWithOutsidePointerEventsDisabled.size>0,k=q>=S,B=function(e,t=(null==globalThis?void 0:globalThis.document)){const n=s.useCallbackRef(e),r=a.useRef(!1),i=a.useRef(()=>{});return a.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){E(d,n,s,{discrete:!0})};const s={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...g.branches].some(e=>e.contains(t));k&&!n&&(null==y||y(e),null==w||w(e),e.defaultPrevented||null==D||D())},L),z=function(e,t=(null==globalThis?void 0:globalThis.document)){const n=s.useCallbackRef(e),r=a.useRef(!1);return a.useEffect(()=>{const e=e=>{if(e.target&&!r.current){E(v,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...g.branches].some(e=>e.contains(t))||(null==h||h(e),null==w||w(e),e.defaultPrevented||null==D||D())},L);return i.useEscapeKeydown(e=>{q===g.layers.size-1&&(null==m||m(e),!e.defaultPrevented&&D&&(e.preventDefault(),D()))},L),a.useEffect(()=>{if(O)return b&&(0===g.layersWithOutsidePointerEventsDisabled.size&&(l=L.body.style.pointerEvents,L.body.style.pointerEvents="none"),g.layersWithOutsidePointerEventsDisabled.add(O)),g.layers.add(O),p(),()=>{b&&1===g.layersWithOutsidePointerEventsDisabled.size&&(L.body.style.pointerEvents=l)}},[O,L,b,g]),a.useEffect(()=>()=>{O&&(g.layers.delete(O),g.layersWithOutsidePointerEventsDisabled.delete(O),p())},[O,g]),a.useEffect(()=>{const e=()=>x({});return document.addEventListener(c,e),()=>document.removeEventListener(c,e)},[]),o.jsx(n.Primitive.div,{...C,ref:j,style:{pointerEvents:W?k?"auto":"none":void 0,...e.style},onFocusCapture:t.composeEventHandlers(e.onFocusCapture,z.onFocusCapture),onBlurCapture:t.composeEventHandlers(e.onBlurCapture,z.onBlurCapture),onPointerDownCapture:t.composeEventHandlers(e.onPointerDownCapture,B.onPointerDownCapture)})});b.displayName="DismissableLayer";var m=a.forwardRef((e,t)=>{const s=a.useContext(f),i=a.useRef(null),u=r.useComposedRefs(t,i);return a.useEffect(()=>{const e=i.current;if(e)return s.branches.add(e),()=>{s.branches.delete(e)}},[s.branches]),o.jsx(n.Primitive.div,{...e,ref:u})});function p(){const e=new CustomEvent(c);document.dispatchEvent(e)}function E(e,t,r,{discrete:s}){const i=r.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&i.addEventListener(e,t,{once:!0}),s?n.dispatchDiscreteCustomEvent(i,o):i.dispatchEvent(o)}m.displayName="DismissableLayerBranch",exports.DismissableLayer=b,exports.DismissableLayerBranch=m;
|
package/dist/index44.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { composeEventHandlers } from "./index39.js";
|
|
3
|
+
import { Primitive, dispatchDiscreteCustomEvent } from "./index50.js";
|
|
4
|
+
import { useComposedRefs } from "./index41.js";
|
|
5
|
+
import { useCallbackRef } from "./index52.js";
|
|
6
|
+
import { useEscapeKeydown } from "./index59.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var DISMISSABLE_LAYER_NAME = "DismissableLayer";
|
|
9
|
+
var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
10
|
+
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
11
|
+
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
12
|
+
var originalBodyPointerEvents;
|
|
13
|
+
var DismissableLayerContext = React.createContext({
|
|
14
|
+
layers: /* @__PURE__ */ new Set(),
|
|
15
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
16
|
+
branches: /* @__PURE__ */ new Set()
|
|
17
|
+
});
|
|
18
|
+
var DismissableLayer = React.forwardRef(
|
|
19
|
+
(props, forwardedRef) => {
|
|
20
|
+
const {
|
|
21
|
+
disableOutsidePointerEvents = false,
|
|
22
|
+
onEscapeKeyDown,
|
|
23
|
+
onPointerDownOutside,
|
|
24
|
+
onFocusOutside,
|
|
25
|
+
onInteractOutside,
|
|
26
|
+
onDismiss,
|
|
27
|
+
...layerProps
|
|
28
|
+
} = props;
|
|
29
|
+
const context = React.useContext(DismissableLayerContext);
|
|
30
|
+
const [node, setNode] = React.useState(null);
|
|
31
|
+
const ownerDocument = (node == null ? void 0 : node.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document);
|
|
32
|
+
const [, force] = React.useState({});
|
|
33
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
34
|
+
const layers = Array.from(context.layers);
|
|
35
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
|
|
36
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
37
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
38
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
39
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
40
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
41
|
+
const target = event.target;
|
|
42
|
+
const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
43
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
44
|
+
onPointerDownOutside == null ? void 0 : onPointerDownOutside(event);
|
|
45
|
+
onInteractOutside == null ? void 0 : onInteractOutside(event);
|
|
46
|
+
if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
|
|
47
|
+
}, ownerDocument);
|
|
48
|
+
const focusOutside = useFocusOutside((event) => {
|
|
49
|
+
const target = event.target;
|
|
50
|
+
const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
51
|
+
if (isFocusInBranch) return;
|
|
52
|
+
onFocusOutside == null ? void 0 : onFocusOutside(event);
|
|
53
|
+
onInteractOutside == null ? void 0 : onInteractOutside(event);
|
|
54
|
+
if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
|
|
55
|
+
}, ownerDocument);
|
|
56
|
+
useEscapeKeydown((event) => {
|
|
57
|
+
const isHighestLayer = index === context.layers.size - 1;
|
|
58
|
+
if (!isHighestLayer) return;
|
|
59
|
+
onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
|
|
60
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
onDismiss();
|
|
63
|
+
}
|
|
64
|
+
}, ownerDocument);
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
if (!node) return;
|
|
67
|
+
if (disableOutsidePointerEvents) {
|
|
68
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
69
|
+
originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
70
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
71
|
+
}
|
|
72
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
73
|
+
}
|
|
74
|
+
context.layers.add(node);
|
|
75
|
+
dispatchUpdate();
|
|
76
|
+
return () => {
|
|
77
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
78
|
+
ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}, [node, ownerDocument, disableOutsidePointerEvents, context]);
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
return () => {
|
|
84
|
+
if (!node) return;
|
|
85
|
+
context.layers.delete(node);
|
|
86
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
87
|
+
dispatchUpdate();
|
|
88
|
+
};
|
|
89
|
+
}, [node, context]);
|
|
90
|
+
React.useEffect(() => {
|
|
91
|
+
const handleUpdate = () => force({});
|
|
92
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
93
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
94
|
+
}, []);
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
Primitive.div,
|
|
97
|
+
{
|
|
98
|
+
...layerProps,
|
|
99
|
+
ref: composedRefs,
|
|
100
|
+
style: {
|
|
101
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
102
|
+
...props.style
|
|
103
|
+
},
|
|
104
|
+
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
105
|
+
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
106
|
+
onPointerDownCapture: composeEventHandlers(
|
|
107
|
+
props.onPointerDownCapture,
|
|
108
|
+
pointerDownOutside.onPointerDownCapture
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
115
|
+
var BRANCH_NAME = "DismissableLayerBranch";
|
|
116
|
+
var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
|
|
117
|
+
const context = React.useContext(DismissableLayerContext);
|
|
118
|
+
const ref = React.useRef(null);
|
|
119
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
120
|
+
React.useEffect(() => {
|
|
121
|
+
const node = ref.current;
|
|
122
|
+
if (node) {
|
|
123
|
+
context.branches.add(node);
|
|
124
|
+
return () => {
|
|
125
|
+
context.branches.delete(node);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}, [context.branches]);
|
|
129
|
+
return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
|
|
130
|
+
});
|
|
131
|
+
DismissableLayerBranch.displayName = BRANCH_NAME;
|
|
132
|
+
function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
|
|
133
|
+
const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
|
|
134
|
+
const isPointerInsideReactTreeRef = React.useRef(false);
|
|
135
|
+
const handleClickRef = React.useRef(() => {
|
|
136
|
+
});
|
|
137
|
+
React.useEffect(() => {
|
|
138
|
+
const handlePointerDown = (event) => {
|
|
139
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
140
|
+
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
141
|
+
handleAndDispatchCustomEvent(
|
|
142
|
+
POINTER_DOWN_OUTSIDE,
|
|
143
|
+
handlePointerDownOutside,
|
|
144
|
+
eventDetail,
|
|
145
|
+
{ discrete: true }
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
const eventDetail = { originalEvent: event };
|
|
149
|
+
if (event.pointerType === "touch") {
|
|
150
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
151
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
152
|
+
ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
|
|
153
|
+
} else {
|
|
154
|
+
handleAndDispatchPointerDownOutsideEvent2();
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
158
|
+
}
|
|
159
|
+
isPointerInsideReactTreeRef.current = false;
|
|
160
|
+
};
|
|
161
|
+
const timerId = window.setTimeout(() => {
|
|
162
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
163
|
+
}, 0);
|
|
164
|
+
return () => {
|
|
165
|
+
window.clearTimeout(timerId);
|
|
166
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
167
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
168
|
+
};
|
|
169
|
+
}, [ownerDocument, handlePointerDownOutside]);
|
|
170
|
+
return {
|
|
171
|
+
// ensures we check React component tree (not just DOM tree)
|
|
172
|
+
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function useFocusOutside(onFocusOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
|
|
176
|
+
const handleFocusOutside = useCallbackRef(onFocusOutside);
|
|
177
|
+
const isFocusInsideReactTreeRef = React.useRef(false);
|
|
178
|
+
React.useEffect(() => {
|
|
179
|
+
const handleFocus = (event) => {
|
|
180
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
181
|
+
const eventDetail = { originalEvent: event };
|
|
182
|
+
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
183
|
+
discrete: false
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
ownerDocument.addEventListener("focusin", handleFocus);
|
|
188
|
+
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
189
|
+
}, [ownerDocument, handleFocusOutside]);
|
|
190
|
+
return {
|
|
191
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
192
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function dispatchUpdate() {
|
|
196
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
197
|
+
document.dispatchEvent(event);
|
|
198
|
+
}
|
|
199
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
200
|
+
const target = detail.originalEvent.target;
|
|
201
|
+
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
202
|
+
if (handler) target.addEventListener(name, handler, { once: true });
|
|
203
|
+
if (discrete) {
|
|
204
|
+
dispatchDiscreteCustomEvent(target, event);
|
|
205
|
+
} else {
|
|
206
|
+
target.dispatchEvent(event);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export {
|
|
210
|
+
DismissableLayer,
|
|
211
|
+
DismissableLayerBranch
|
|
212
|
+
};
|
package/dist/index45.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const t=e(require("react"));var n=0;function r(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}exports.useFocusGuards=function(){t.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??r()),document.body.insertAdjacentElement("beforeend",e[1]??r()),n++,()=>{1===n&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),n--}},[])};
|
package/dist/index45.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
var count = 0;
|
|
3
|
+
function useFocusGuards() {
|
|
4
|
+
React.useEffect(() => {
|
|
5
|
+
const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
|
|
6
|
+
document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
|
|
7
|
+
document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
|
|
8
|
+
count++;
|
|
9
|
+
return () => {
|
|
10
|
+
if (count === 1) {
|
|
11
|
+
document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
|
|
12
|
+
}
|
|
13
|
+
count--;
|
|
14
|
+
};
|
|
15
|
+
}, []);
|
|
16
|
+
}
|
|
17
|
+
function createFocusGuard() {
|
|
18
|
+
const element = document.createElement("span");
|
|
19
|
+
element.setAttribute("data-radix-focus-guard", "");
|
|
20
|
+
element.tabIndex = 0;
|
|
21
|
+
element.style.outline = "none";
|
|
22
|
+
element.style.opacity = "0";
|
|
23
|
+
element.style.position = "fixed";
|
|
24
|
+
element.style.pointerEvents = "none";
|
|
25
|
+
return element;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
useFocusGuards
|
|
29
|
+
};
|
package/dist/index46.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./index41.cjs"),n=require("./index50.cjs"),o=require("./index52.cjs"),r=require("react/jsx-runtime");function u(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const c=u(e);var s="focusScope.autoFocusOnMount",i="focusScope.autoFocusOnUnmount",a={bubbles:!1,cancelable:!0},d=c.forwardRef((e,u)=>{const{loop:d=!1,trapped:m=!1,onMountAutoFocus:E,onUnmountAutoFocus:b,...y}=e,[T,g]=c.useState(null),S=o.useCallbackRef(E),L=o.useCallbackRef(b),h=c.useRef(null),F=t.useComposedRefs(u,e=>g(e)),N=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(m){let e=function(e){if(N.paused||!T)return;const t=e.target;T.contains(t)?h.current=t:v(h.current,{select:!0})},t=function(e){if(N.paused||!T)return;const t=e.relatedTarget;null!==t&&(T.contains(t)||v(h.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&v(T)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const o=new MutationObserver(n);return T&&o.observe(T,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),o.disconnect()}}},[m,T,N.paused]),c.useEffect(()=>{if(T){p.add(N);const t=document.activeElement;if(!T.contains(t)){const n=new CustomEvent(s,a);T.addEventListener(s,S),T.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(v(o,{select:t}),document.activeElement!==n)return}((e=l(T),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&v(T))}return()=>{T.removeEventListener(s,S),setTimeout(()=>{const e=new CustomEvent(i,a);T.addEventListener(i,L),T.dispatchEvent(e),e.defaultPrevented||v(t??document.body,{select:!0}),T.removeEventListener(i,L),p.remove(N)},0)}}var e},[T,S,L,N]);const x=c.useCallback(e=>{if(!d&&!m)return;if(N.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[o,r]=function(e){const t=l(e),n=f(t,e),o=f(t.reverse(),e);return[n,o]}(t);o&&r?e.shiftKey||n!==r?e.shiftKey&&n===o&&(e.preventDefault(),d&&v(r,{select:!0})):(e.preventDefault(),d&&v(o,{select:!0})):n===t&&e.preventDefault()}},[d,m,N.paused]);return r.jsx(n.Primitive.div,{tabIndex:-1,...y,ref:F,onKeyDown:x})});function l(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function f(e,t){for(const n of e)if(!m(n,{upTo:t}))return n}function m(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function v(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}d.displayName="FocusScope";var p=function(){let e=[];return{add(t){const n=e[0];t!==n&&(null==n||n.pause()),e=E(e,t),e.unshift(t)},remove(t){var n;e=E(e,t),null==(n=e[0])||n.resume()}}}();function E(e,t){const n=[...e],o=n.indexOf(t);return-1!==o&&n.splice(o,1),n}exports.FocusScope=d;
|