@adam-milo/ui 1.0.29 → 1.0.30

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 (66) hide show
  1. package/dist/index27.cjs +1 -1
  2. package/dist/index27.js +21 -21
  3. package/dist/index42.cjs +1 -1
  4. package/dist/index42.js +3 -8
  5. package/dist/index43.cjs +1 -1
  6. package/dist/index43.js +7 -66
  7. package/dist/index44.cjs +1 -1
  8. package/dist/index44.js +66 -35
  9. package/dist/index45.cjs +1 -1
  10. package/dist/index45.js +31 -56
  11. package/dist/index46.cjs +1 -1
  12. package/dist/index46.js +60 -6
  13. package/dist/index47.cjs +1 -1
  14. package/dist/index47.js +6 -208
  15. package/dist/index48.cjs +1 -1
  16. package/dist/index48.js +203 -20
  17. package/dist/index49.cjs +1 -1
  18. package/dist/index49.js +23 -202
  19. package/dist/index50.cjs +1 -1
  20. package/dist/index50.js +204 -10
  21. package/dist/index51.cjs +1 -1
  22. package/dist/index51.js +10 -289
  23. package/dist/index52.cjs +1 -1
  24. package/dist/index52.js +288 -13
  25. package/dist/index53.cjs +1 -1
  26. package/dist/index53.js +14 -39
  27. package/dist/index54.cjs +1 -1
  28. package/dist/index54.js +36 -82
  29. package/dist/index55.cjs +1 -1
  30. package/dist/index55.js +84 -9
  31. package/dist/index56.cjs +1 -1
  32. package/dist/index56.js +8 -65
  33. package/dist/index57.cjs +1 -1
  34. package/dist/index57.js +68 -3
  35. package/dist/index58.cjs +1 -1
  36. package/dist/index58.js +3 -11
  37. package/dist/index59.cjs +1 -1
  38. package/dist/index59.js +11 -31
  39. package/dist/index60.cjs +1 -1
  40. package/dist/index60.js +30 -118
  41. package/dist/index61.cjs +1 -1
  42. package/dist/index61.js +120 -9
  43. package/dist/index62.cjs +1 -0
  44. package/dist/index62.js +11 -0
  45. package/dist/index63.cjs +1 -1
  46. package/dist/index63.js +1 -1
  47. package/dist/index65.cjs +1 -1
  48. package/dist/index65.js +1 -1
  49. package/dist/index66.cjs +1 -1
  50. package/dist/index66.js +1 -1
  51. package/dist/index80.cjs +1 -1
  52. package/dist/index80.js +1 -1
  53. package/dist/index81.cjs +1 -1
  54. package/dist/index81.js +1 -1
  55. package/dist/index86.cjs +1 -1
  56. package/dist/index86.js +12 -33
  57. package/dist/index87.cjs +1 -1
  58. package/dist/index87.js +44 -12
  59. package/dist/index88.cjs +1 -1
  60. package/dist/index88.js +5 -44
  61. package/dist/index89.cjs +1 -1
  62. package/dist/index89.js +33 -5
  63. package/dist/src/components/forms/radio/Radio.component.d.ts.map +1 -1
  64. package/package.json +2 -1
  65. package/dist/index41.cjs +0 -1
  66. package/dist/index41.js +0 -6
package/dist/index51.js CHANGED
@@ -1,293 +1,14 @@
1
1
  import * as React from "react";
2
- import { useFloating, offset, shift, flip, size, arrow, hide, limitShift } from "./index64.js";
3
- import { Root } from "./index65.js";
4
- import { useComposedRefs } from "./index44.js";
5
- import { createContextScope } from "./index45.js";
6
- import { Primitive } from "./index53.js";
7
- import { useCallbackRef } from "./index55.js";
8
- import { useLayoutEffect as useLayoutEffect2 } from "./index57.js";
9
- import { useSize } from "./index66.js";
10
- import { jsx } from "react/jsx-runtime";
11
- import { autoUpdate } from "./index67.js";
12
- var POPPER_NAME = "Popper";
13
- var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
14
- var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
15
- var Popper = (props) => {
16
- const { __scopePopper, children } = props;
17
- const [anchor, setAnchor] = React.useState(null);
18
- return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
19
- };
20
- Popper.displayName = POPPER_NAME;
21
- var ANCHOR_NAME = "PopperAnchor";
22
- var PopperAnchor = React.forwardRef(
23
- (props, forwardedRef) => {
24
- const { __scopePopper, virtualRef, ...anchorProps } = props;
25
- const context = usePopperContext(ANCHOR_NAME, __scopePopper);
26
- const ref = React.useRef(null);
27
- const composedRefs = useComposedRefs(forwardedRef, ref);
28
- const anchorRef = React.useRef(null);
29
- React.useEffect(() => {
30
- const previousAnchor = anchorRef.current;
31
- anchorRef.current = (virtualRef == null ? void 0 : virtualRef.current) || ref.current;
32
- if (previousAnchor !== anchorRef.current) {
33
- context.onAnchorChange(anchorRef.current);
34
- }
35
- });
36
- return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
37
- }
38
- );
39
- PopperAnchor.displayName = ANCHOR_NAME;
40
- var CONTENT_NAME = "PopperContent";
41
- var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
42
- var PopperContent = React.forwardRef(
43
- (props, forwardedRef) => {
44
- var _a, _b, _c, _d, _e, _f;
45
- const {
46
- __scopePopper,
47
- side = "bottom",
48
- sideOffset = 0,
49
- align = "center",
50
- alignOffset = 0,
51
- arrowPadding = 0,
52
- avoidCollisions = true,
53
- collisionBoundary = [],
54
- collisionPadding: collisionPaddingProp = 0,
55
- sticky = "partial",
56
- hideWhenDetached = false,
57
- updatePositionStrategy = "optimized",
58
- onPlaced,
59
- ...contentProps
60
- } = props;
61
- const context = usePopperContext(CONTENT_NAME, __scopePopper);
62
- const [content, setContent] = React.useState(null);
63
- const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
64
- const [arrow$1, setArrow] = React.useState(null);
65
- const arrowSize = useSize(arrow$1);
66
- const arrowWidth = (arrowSize == null ? void 0 : arrowSize.width) ?? 0;
67
- const arrowHeight = (arrowSize == null ? void 0 : arrowSize.height) ?? 0;
68
- const desiredPlacement = side + (align !== "center" ? "-" + align : "");
69
- const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
70
- const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
71
- const hasExplicitBoundaries = boundary.length > 0;
72
- const detectOverflowOptions = {
73
- padding: collisionPadding,
74
- boundary: boundary.filter(isNotNull),
75
- // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
76
- altBoundary: hasExplicitBoundaries
77
- };
78
- const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
79
- // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
80
- strategy: "fixed",
81
- placement: desiredPlacement,
82
- whileElementsMounted: (...args) => {
83
- const cleanup = autoUpdate(...args, {
84
- animationFrame: updatePositionStrategy === "always"
85
- });
86
- return cleanup;
87
- },
88
- elements: {
89
- reference: context.anchor
90
- },
91
- middleware: [
92
- offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
93
- avoidCollisions && shift({
94
- mainAxis: true,
95
- crossAxis: false,
96
- limiter: sticky === "partial" ? limitShift() : void 0,
97
- ...detectOverflowOptions
98
- }),
99
- avoidCollisions && flip({ ...detectOverflowOptions }),
100
- size({
101
- ...detectOverflowOptions,
102
- apply: ({ elements, rects, availableWidth, availableHeight }) => {
103
- const { width: anchorWidth, height: anchorHeight } = rects.reference;
104
- const contentStyle = elements.floating.style;
105
- contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
106
- contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
107
- contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
108
- contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
109
- }
110
- }),
111
- arrow$1 && arrow({ element: arrow$1, padding: arrowPadding }),
112
- transformOrigin({ arrowWidth, arrowHeight }),
113
- hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
114
- ]
115
- });
116
- const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
117
- const handlePlaced = useCallbackRef(onPlaced);
118
- useLayoutEffect2(() => {
119
- if (isPositioned) {
120
- handlePlaced == null ? void 0 : handlePlaced();
121
- }
122
- }, [isPositioned, handlePlaced]);
123
- const arrowX = (_a = middlewareData.arrow) == null ? void 0 : _a.x;
124
- const arrowY = (_b = middlewareData.arrow) == null ? void 0 : _b.y;
125
- const cannotCenterArrow = ((_c = middlewareData.arrow) == null ? void 0 : _c.centerOffset) !== 0;
126
- const [contentZIndex, setContentZIndex] = React.useState();
127
- useLayoutEffect2(() => {
128
- if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
129
- }, [content]);
130
- return /* @__PURE__ */ jsx(
131
- "div",
132
- {
133
- ref: refs.setFloating,
134
- "data-radix-popper-content-wrapper": "",
135
- style: {
136
- ...floatingStyles,
137
- transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
138
- // keep off the page when measuring
139
- minWidth: "max-content",
140
- zIndex: contentZIndex,
141
- ["--radix-popper-transform-origin"]: [
142
- (_d = middlewareData.transformOrigin) == null ? void 0 : _d.x,
143
- (_e = middlewareData.transformOrigin) == null ? void 0 : _e.y
144
- ].join(" "),
145
- // hide the content if using the hide middleware and should be hidden
146
- // set visibility to hidden and disable pointer events so the UI behaves
147
- // as if the PopperContent isn't there at all
148
- ...((_f = middlewareData.hide) == null ? void 0 : _f.referenceHidden) && {
149
- visibility: "hidden",
150
- pointerEvents: "none"
151
- }
152
- },
153
- dir: props.dir,
154
- children: /* @__PURE__ */ jsx(
155
- PopperContentProvider,
156
- {
157
- scope: __scopePopper,
158
- placedSide,
159
- onArrowChange: setArrow,
160
- arrowX,
161
- arrowY,
162
- shouldHideArrow: cannotCenterArrow,
163
- children: /* @__PURE__ */ jsx(
164
- Primitive.div,
165
- {
166
- "data-side": placedSide,
167
- "data-align": placedAlign,
168
- ...contentProps,
169
- ref: composedRefs,
170
- style: {
171
- ...contentProps.style,
172
- // if the PopperContent hasn't been placed yet (not all measurements done)
173
- // we prevent animations so that users's animation don't kick in too early referring wrong sides
174
- animation: !isPositioned ? "none" : void 0
175
- }
176
- }
177
- )
178
- }
179
- )
180
- }
181
- );
182
- }
183
- );
184
- PopperContent.displayName = CONTENT_NAME;
185
- var ARROW_NAME = "PopperArrow";
186
- var OPPOSITE_SIDE = {
187
- top: "bottom",
188
- right: "left",
189
- bottom: "top",
190
- left: "right"
191
- };
192
- var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
193
- const { __scopePopper, ...arrowProps } = props;
194
- const contentContext = useContentContext(ARROW_NAME, __scopePopper);
195
- const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
196
- return (
197
- // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
198
- // doesn't report size as we'd expect on SVG elements.
199
- // it reports their bounding box which is effectively the largest path inside the SVG.
200
- /* @__PURE__ */ jsx(
201
- "span",
202
- {
203
- ref: contentContext.onArrowChange,
204
- style: {
205
- position: "absolute",
206
- left: contentContext.arrowX,
207
- top: contentContext.arrowY,
208
- [baseSide]: 0,
209
- transformOrigin: {
210
- top: "",
211
- right: "0 0",
212
- bottom: "center 0",
213
- left: "100% 0"
214
- }[contentContext.placedSide],
215
- transform: {
216
- top: "translateY(100%)",
217
- right: "translateY(50%) rotate(90deg) translateX(-50%)",
218
- bottom: `rotate(180deg)`,
219
- left: "translateY(50%) rotate(-90deg) translateX(50%)"
220
- }[contentContext.placedSide],
221
- visibility: contentContext.shouldHideArrow ? "hidden" : void 0
222
- },
223
- children: /* @__PURE__ */ jsx(
224
- Root,
225
- {
226
- ...arrowProps,
227
- ref: forwardedRef,
228
- style: {
229
- ...arrowProps.style,
230
- // ensures the element can be measured correctly (mostly for if SVG)
231
- display: "block"
232
- }
233
- }
234
- )
235
- }
236
- )
237
- );
238
- });
239
- PopperArrow.displayName = ARROW_NAME;
240
- function isNotNull(value) {
241
- return value !== null;
242
- }
243
- var transformOrigin = (options) => ({
244
- name: "transformOrigin",
245
- options,
246
- fn(data) {
247
- var _a, _b, _c;
248
- const { placement, rects, middlewareData } = data;
249
- const cannotCenterArrow = ((_a = middlewareData.arrow) == null ? void 0 : _a.centerOffset) !== 0;
250
- const isArrowHidden = cannotCenterArrow;
251
- const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
252
- const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
253
- const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
254
- const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
255
- const arrowXCenter = (((_b = middlewareData.arrow) == null ? void 0 : _b.x) ?? 0) + arrowWidth / 2;
256
- const arrowYCenter = (((_c = middlewareData.arrow) == null ? void 0 : _c.y) ?? 0) + arrowHeight / 2;
257
- let x = "";
258
- let y = "";
259
- if (placedSide === "bottom") {
260
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
261
- y = `${-arrowHeight}px`;
262
- } else if (placedSide === "top") {
263
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
264
- y = `${rects.floating.height + arrowHeight}px`;
265
- } else if (placedSide === "right") {
266
- x = `${-arrowHeight}px`;
267
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
268
- } else if (placedSide === "left") {
269
- x = `${rects.floating.width + arrowHeight}px`;
270
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
271
- }
272
- return { data: { x, y } };
273
- }
274
- });
275
- function getSideAndAlignFromPlacement(placement) {
276
- const [side, align = "center"] = placement.split("-");
277
- return [side, align];
2
+ import { useLayoutEffect as useLayoutEffect2 } from "./index58.js";
3
+ var useReactId = React[" useId ".trim().toString()] || (() => void 0);
4
+ var count = 0;
5
+ function useId(deterministicId) {
6
+ const [id, setId] = React.useState(useReactId());
7
+ useLayoutEffect2(() => {
8
+ setId((reactId) => reactId ?? String(count++));
9
+ }, [deterministicId]);
10
+ return deterministicId || (id ? `radix-${id}` : "");
278
11
  }
279
- var Root2 = Popper;
280
- var Anchor = PopperAnchor;
281
- var Content = PopperContent;
282
- var Arrow = PopperArrow;
283
12
  export {
284
- Anchor,
285
- Arrow,
286
- Content,
287
- Popper,
288
- PopperAnchor,
289
- PopperArrow,
290
- PopperContent,
291
- Root2 as Root,
292
- createPopperScope
13
+ useId
293
14
  };
package/dist/index52.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("react-dom"),r=require("./index53.cjs"),o=require("./index57.cjs"),i=require("react/jsx-runtime");function n(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)}const a=n(e);var c=a.forwardRef((e,n)=>{var c;const{container:l,...u}=e,[s,d]=a.useState(!1);o.useLayoutEffect(()=>d(!0),[]);const f=l||s&&(null==(c=null==globalThis?void 0:globalThis.document)?void 0:c.body);return f?t.createPortal(i.jsx(r.Primitive.div,{...u,ref:n}),f):null});c.displayName="Portal",exports.Portal=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("./index64.cjs"),t=require("./index65.cjs"),o=require("./index45.cjs"),i=require("./index46.cjs"),n=require("./index54.cjs"),a=require("./index56.cjs"),s=require("./index58.cjs"),l=require("./index66.cjs"),d=require("react/jsx-runtime"),p=require("./index67.cjs");function c(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}return r.default=e,Object.freeze(r)}const u=c(e);var f="Popper",[h,x]=i.createContextScope(f),[g,m]=h(f),y=e=>{const{__scopePopper:r,children:t}=e,[o,i]=u.useState(null);return d.jsx(g,{scope:r,anchor:o,onAnchorChange:i,children:t})};y.displayName=f;var w="PopperAnchor",v=u.forwardRef((e,r)=>{const{__scopePopper:t,virtualRef:i,...a}=e,s=m(w,t),l=u.useRef(null),p=o.useComposedRefs(r,l),c=u.useRef(null);return u.useEffect(()=>{const e=c.current;c.current=(null==i?void 0:i.current)||l.current,e!==c.current&&s.onAnchorChange(c.current)}),i?null:d.jsx(n.Primitive.div,{...a,ref:p})});v.displayName=w;var P="PopperContent",[b,j]=h(P),S=u.forwardRef((e,t)=>{var i,c,f,h,x,g;const{__scopePopper:y,side:w="bottom",sideOffset:v=0,align:j="center",alignOffset:S=0,arrowPadding:A=0,avoidCollisions:O=!0,collisionBoundary:C=[],collisionPadding:_=0,sticky:H="partial",hideWhenDetached:z=!1,updatePositionStrategy:E="optimized",onPlaced:W,...Y}=e,D=m(P,y),[N,X]=u.useState(null),k=o.useComposedRefs(t,e=>X(e)),[F,M]=u.useState(null),B=l.useSize(F),I=(null==B?void 0:B.width)??0,L=(null==B?void 0:B.height)??0,T=w+("center"!==j?"-"+j:""),U="number"==typeof _?_:{top:0,right:0,bottom:0,left:0,..._},G=Array.isArray(C)?C:[C],J=G.length>0,K={padding:U,boundary:G.filter(q),altBoundary:J},{refs:Q,floatingStyles:V,placement:Z,isPositioned:ee,middlewareData:re}=r.useFloating({strategy:"fixed",placement:T,whileElementsMounted:(...e)=>p.autoUpdate(...e,{animationFrame:"always"===E}),elements:{reference:D.anchor},middleware:[r.offset({mainAxis:v+L,alignmentAxis:S}),O&&r.shift({mainAxis:!0,crossAxis:!1,limiter:"partial"===H?r.limitShift():void 0,...K}),O&&r.flip({...K}),r.size({...K,apply:({elements:e,rects:r,availableWidth:t,availableHeight:o})=>{const{width:i,height:n}=r.reference,a=e.floating.style;a.setProperty("--radix-popper-available-width",`${t}px`),a.setProperty("--radix-popper-available-height",`${o}px`),a.setProperty("--radix-popper-anchor-width",`${i}px`),a.setProperty("--radix-popper-anchor-height",`${n}px`)}}),F&&r.arrow({element:F,padding:A}),R({arrowWidth:I,arrowHeight:L}),z&&r.hide({strategy:"referenceHidden",...K})]}),[te,oe]=$(Z),ie=a.useCallbackRef(W);s.useLayoutEffect(()=>{ee&&(null==ie||ie())},[ee,ie]);const ne=null==(i=re.arrow)?void 0:i.x,ae=null==(c=re.arrow)?void 0:c.y,se=0!==(null==(f=re.arrow)?void 0:f.centerOffset),[le,de]=u.useState();return s.useLayoutEffect(()=>{N&&de(window.getComputedStyle(N).zIndex)},[N]),d.jsx("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:ee?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[null==(h=re.transformOrigin)?void 0:h.x,null==(x=re.transformOrigin)?void 0:x.y].join(" "),...(null==(g=re.hide)?void 0:g.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(b,{scope:y,placedSide:te,onArrowChange:M,arrowX:ne,arrowY:ae,shouldHideArrow:se,children:d.jsx(n.Primitive.div,{"data-side":te,"data-align":oe,...Y,ref:k,style:{...Y.style,animation:ee?void 0:"none"}})})})});S.displayName=P;var A="PopperArrow",O={top:"bottom",right:"left",bottom:"top",left:"right"},C=u.forwardRef(function(e,r){const{__scopePopper:o,...i}=e,n=j(A,o),a=O[n.placedSide];return d.jsx("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:d.jsx(t.Root,{...i,ref:r,style:{...i.style,display:"block"}})})});function q(e){return null!==e}C.displayName=A;var R=e=>({name:"transformOrigin",options:e,fn(r){var t,o,i;const{placement:n,rects:a,middlewareData:s}=r,l=0!==(null==(t=s.arrow)?void 0:t.centerOffset),d=l?0:e.arrowWidth,p=l?0:e.arrowHeight,[c,u]=$(n),f={start:"0%",center:"50%",end:"100%"}[u],h=((null==(o=s.arrow)?void 0:o.x)??0)+d/2,x=((null==(i=s.arrow)?void 0:i.y)??0)+p/2;let g="",m="";return"bottom"===c?(g=l?f:`${h}px`,m=-p+"px"):"top"===c?(g=l?f:`${h}px`,m=`${a.floating.height+p}px`):"right"===c?(g=-p+"px",m=l?f:`${x}px`):"left"===c&&(g=`${a.floating.width+p}px`,m=l?f:`${x}px`),{data:{x:g,y:m}}}});function $(e){const[r,t="center"]=e.split("-");return[r,t]}var _=y,H=v,z=S,E=C;exports.Anchor=H,exports.Arrow=E,exports.Content=z,exports.Popper=y,exports.PopperAnchor=v,exports.PopperArrow=C,exports.PopperContent=S,exports.Root=_,exports.createPopperScope=x;
package/dist/index52.js CHANGED
@@ -1,18 +1,293 @@
1
1
  import * as React from "react";
2
- import ReactDOM__default from "react-dom";
3
- import { Primitive } from "./index53.js";
4
- import { useLayoutEffect as useLayoutEffect2 } from "./index57.js";
2
+ import { useFloating, offset, shift, flip, size, arrow, hide, limitShift } from "./index64.js";
3
+ import { Root } from "./index65.js";
4
+ import { useComposedRefs } from "./index45.js";
5
+ import { createContextScope } from "./index46.js";
6
+ import { Primitive } from "./index54.js";
7
+ import { useCallbackRef } from "./index56.js";
8
+ import { useLayoutEffect as useLayoutEffect2 } from "./index58.js";
9
+ import { useSize } from "./index66.js";
5
10
  import { jsx } from "react/jsx-runtime";
6
- var PORTAL_NAME = "Portal";
7
- var Portal = React.forwardRef((props, forwardedRef) => {
8
- var _a;
9
- const { container: containerProp, ...portalProps } = props;
10
- const [mounted, setMounted] = React.useState(false);
11
- useLayoutEffect2(() => setMounted(true), []);
12
- const container = containerProp || mounted && ((_a = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : _a.body);
13
- return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
11
+ import { autoUpdate } from "./index67.js";
12
+ var POPPER_NAME = "Popper";
13
+ var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
14
+ var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
15
+ var Popper = (props) => {
16
+ const { __scopePopper, children } = props;
17
+ const [anchor, setAnchor] = React.useState(null);
18
+ return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
19
+ };
20
+ Popper.displayName = POPPER_NAME;
21
+ var ANCHOR_NAME = "PopperAnchor";
22
+ var PopperAnchor = React.forwardRef(
23
+ (props, forwardedRef) => {
24
+ const { __scopePopper, virtualRef, ...anchorProps } = props;
25
+ const context = usePopperContext(ANCHOR_NAME, __scopePopper);
26
+ const ref = React.useRef(null);
27
+ const composedRefs = useComposedRefs(forwardedRef, ref);
28
+ const anchorRef = React.useRef(null);
29
+ React.useEffect(() => {
30
+ const previousAnchor = anchorRef.current;
31
+ anchorRef.current = (virtualRef == null ? void 0 : virtualRef.current) || ref.current;
32
+ if (previousAnchor !== anchorRef.current) {
33
+ context.onAnchorChange(anchorRef.current);
34
+ }
35
+ });
36
+ return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
37
+ }
38
+ );
39
+ PopperAnchor.displayName = ANCHOR_NAME;
40
+ var CONTENT_NAME = "PopperContent";
41
+ var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
42
+ var PopperContent = React.forwardRef(
43
+ (props, forwardedRef) => {
44
+ var _a, _b, _c, _d, _e, _f;
45
+ const {
46
+ __scopePopper,
47
+ side = "bottom",
48
+ sideOffset = 0,
49
+ align = "center",
50
+ alignOffset = 0,
51
+ arrowPadding = 0,
52
+ avoidCollisions = true,
53
+ collisionBoundary = [],
54
+ collisionPadding: collisionPaddingProp = 0,
55
+ sticky = "partial",
56
+ hideWhenDetached = false,
57
+ updatePositionStrategy = "optimized",
58
+ onPlaced,
59
+ ...contentProps
60
+ } = props;
61
+ const context = usePopperContext(CONTENT_NAME, __scopePopper);
62
+ const [content, setContent] = React.useState(null);
63
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
64
+ const [arrow$1, setArrow] = React.useState(null);
65
+ const arrowSize = useSize(arrow$1);
66
+ const arrowWidth = (arrowSize == null ? void 0 : arrowSize.width) ?? 0;
67
+ const arrowHeight = (arrowSize == null ? void 0 : arrowSize.height) ?? 0;
68
+ const desiredPlacement = side + (align !== "center" ? "-" + align : "");
69
+ const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
70
+ const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
71
+ const hasExplicitBoundaries = boundary.length > 0;
72
+ const detectOverflowOptions = {
73
+ padding: collisionPadding,
74
+ boundary: boundary.filter(isNotNull),
75
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
76
+ altBoundary: hasExplicitBoundaries
77
+ };
78
+ const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
79
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
80
+ strategy: "fixed",
81
+ placement: desiredPlacement,
82
+ whileElementsMounted: (...args) => {
83
+ const cleanup = autoUpdate(...args, {
84
+ animationFrame: updatePositionStrategy === "always"
85
+ });
86
+ return cleanup;
87
+ },
88
+ elements: {
89
+ reference: context.anchor
90
+ },
91
+ middleware: [
92
+ offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
93
+ avoidCollisions && shift({
94
+ mainAxis: true,
95
+ crossAxis: false,
96
+ limiter: sticky === "partial" ? limitShift() : void 0,
97
+ ...detectOverflowOptions
98
+ }),
99
+ avoidCollisions && flip({ ...detectOverflowOptions }),
100
+ size({
101
+ ...detectOverflowOptions,
102
+ apply: ({ elements, rects, availableWidth, availableHeight }) => {
103
+ const { width: anchorWidth, height: anchorHeight } = rects.reference;
104
+ const contentStyle = elements.floating.style;
105
+ contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
106
+ contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
107
+ contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
108
+ contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
109
+ }
110
+ }),
111
+ arrow$1 && arrow({ element: arrow$1, padding: arrowPadding }),
112
+ transformOrigin({ arrowWidth, arrowHeight }),
113
+ hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
114
+ ]
115
+ });
116
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
117
+ const handlePlaced = useCallbackRef(onPlaced);
118
+ useLayoutEffect2(() => {
119
+ if (isPositioned) {
120
+ handlePlaced == null ? void 0 : handlePlaced();
121
+ }
122
+ }, [isPositioned, handlePlaced]);
123
+ const arrowX = (_a = middlewareData.arrow) == null ? void 0 : _a.x;
124
+ const arrowY = (_b = middlewareData.arrow) == null ? void 0 : _b.y;
125
+ const cannotCenterArrow = ((_c = middlewareData.arrow) == null ? void 0 : _c.centerOffset) !== 0;
126
+ const [contentZIndex, setContentZIndex] = React.useState();
127
+ useLayoutEffect2(() => {
128
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
129
+ }, [content]);
130
+ return /* @__PURE__ */ jsx(
131
+ "div",
132
+ {
133
+ ref: refs.setFloating,
134
+ "data-radix-popper-content-wrapper": "",
135
+ style: {
136
+ ...floatingStyles,
137
+ transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
138
+ // keep off the page when measuring
139
+ minWidth: "max-content",
140
+ zIndex: contentZIndex,
141
+ ["--radix-popper-transform-origin"]: [
142
+ (_d = middlewareData.transformOrigin) == null ? void 0 : _d.x,
143
+ (_e = middlewareData.transformOrigin) == null ? void 0 : _e.y
144
+ ].join(" "),
145
+ // hide the content if using the hide middleware and should be hidden
146
+ // set visibility to hidden and disable pointer events so the UI behaves
147
+ // as if the PopperContent isn't there at all
148
+ ...((_f = middlewareData.hide) == null ? void 0 : _f.referenceHidden) && {
149
+ visibility: "hidden",
150
+ pointerEvents: "none"
151
+ }
152
+ },
153
+ dir: props.dir,
154
+ children: /* @__PURE__ */ jsx(
155
+ PopperContentProvider,
156
+ {
157
+ scope: __scopePopper,
158
+ placedSide,
159
+ onArrowChange: setArrow,
160
+ arrowX,
161
+ arrowY,
162
+ shouldHideArrow: cannotCenterArrow,
163
+ children: /* @__PURE__ */ jsx(
164
+ Primitive.div,
165
+ {
166
+ "data-side": placedSide,
167
+ "data-align": placedAlign,
168
+ ...contentProps,
169
+ ref: composedRefs,
170
+ style: {
171
+ ...contentProps.style,
172
+ // if the PopperContent hasn't been placed yet (not all measurements done)
173
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
174
+ animation: !isPositioned ? "none" : void 0
175
+ }
176
+ }
177
+ )
178
+ }
179
+ )
180
+ }
181
+ );
182
+ }
183
+ );
184
+ PopperContent.displayName = CONTENT_NAME;
185
+ var ARROW_NAME = "PopperArrow";
186
+ var OPPOSITE_SIDE = {
187
+ top: "bottom",
188
+ right: "left",
189
+ bottom: "top",
190
+ left: "right"
191
+ };
192
+ var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
193
+ const { __scopePopper, ...arrowProps } = props;
194
+ const contentContext = useContentContext(ARROW_NAME, __scopePopper);
195
+ const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
196
+ return (
197
+ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
198
+ // doesn't report size as we'd expect on SVG elements.
199
+ // it reports their bounding box which is effectively the largest path inside the SVG.
200
+ /* @__PURE__ */ jsx(
201
+ "span",
202
+ {
203
+ ref: contentContext.onArrowChange,
204
+ style: {
205
+ position: "absolute",
206
+ left: contentContext.arrowX,
207
+ top: contentContext.arrowY,
208
+ [baseSide]: 0,
209
+ transformOrigin: {
210
+ top: "",
211
+ right: "0 0",
212
+ bottom: "center 0",
213
+ left: "100% 0"
214
+ }[contentContext.placedSide],
215
+ transform: {
216
+ top: "translateY(100%)",
217
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
218
+ bottom: `rotate(180deg)`,
219
+ left: "translateY(50%) rotate(-90deg) translateX(50%)"
220
+ }[contentContext.placedSide],
221
+ visibility: contentContext.shouldHideArrow ? "hidden" : void 0
222
+ },
223
+ children: /* @__PURE__ */ jsx(
224
+ Root,
225
+ {
226
+ ...arrowProps,
227
+ ref: forwardedRef,
228
+ style: {
229
+ ...arrowProps.style,
230
+ // ensures the element can be measured correctly (mostly for if SVG)
231
+ display: "block"
232
+ }
233
+ }
234
+ )
235
+ }
236
+ )
237
+ );
238
+ });
239
+ PopperArrow.displayName = ARROW_NAME;
240
+ function isNotNull(value) {
241
+ return value !== null;
242
+ }
243
+ var transformOrigin = (options) => ({
244
+ name: "transformOrigin",
245
+ options,
246
+ fn(data) {
247
+ var _a, _b, _c;
248
+ const { placement, rects, middlewareData } = data;
249
+ const cannotCenterArrow = ((_a = middlewareData.arrow) == null ? void 0 : _a.centerOffset) !== 0;
250
+ const isArrowHidden = cannotCenterArrow;
251
+ const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
252
+ const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
253
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
254
+ const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
255
+ const arrowXCenter = (((_b = middlewareData.arrow) == null ? void 0 : _b.x) ?? 0) + arrowWidth / 2;
256
+ const arrowYCenter = (((_c = middlewareData.arrow) == null ? void 0 : _c.y) ?? 0) + arrowHeight / 2;
257
+ let x = "";
258
+ let y = "";
259
+ if (placedSide === "bottom") {
260
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
261
+ y = `${-arrowHeight}px`;
262
+ } else if (placedSide === "top") {
263
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
264
+ y = `${rects.floating.height + arrowHeight}px`;
265
+ } else if (placedSide === "right") {
266
+ x = `${-arrowHeight}px`;
267
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
268
+ } else if (placedSide === "left") {
269
+ x = `${rects.floating.width + arrowHeight}px`;
270
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
271
+ }
272
+ return { data: { x, y } };
273
+ }
14
274
  });
15
- Portal.displayName = PORTAL_NAME;
275
+ function getSideAndAlignFromPlacement(placement) {
276
+ const [side, align = "center"] = placement.split("-");
277
+ return [side, align];
278
+ }
279
+ var Root2 = Popper;
280
+ var Anchor = PopperAnchor;
281
+ var Content = PopperContent;
282
+ var Arrow = PopperArrow;
16
283
  export {
17
- Portal
284
+ Anchor,
285
+ Arrow,
286
+ Content,
287
+ Popper,
288
+ PopperAnchor,
289
+ PopperArrow,
290
+ PopperContent,
291
+ Root2 as Root,
292
+ createPopperScope
18
293
  };
package/dist/index53.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("react-dom"),r=require("./index54.cjs"),i=require("react/jsx-runtime");function n(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}const o=n(e),c=n(t);var u=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=r.createSlot(`Primitive.${t}`),c=o.forwardRef((e,r)=>{const{asChild:o,...c}=e,u=o?n:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),i.jsx(u,{...c,ref:r})});return c.displayName=`Primitive.${t}`,{...e,[t]:c}},{});exports.Primitive=u,exports.dispatchDiscreteCustomEvent=function(e,t){e&&c.flushSync(()=>e.dispatchEvent(t))};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("react-dom"),r=require("./index54.cjs"),o=require("./index58.cjs"),i=require("react/jsx-runtime");function n(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)}const a=n(e);var c=a.forwardRef((e,n)=>{var c;const{container:l,...u}=e,[s,d]=a.useState(!1);o.useLayoutEffect(()=>d(!0),[]);const f=l||s&&(null==(c=null==globalThis?void 0:globalThis.document)?void 0:c.body);return f?t.createPortal(i.jsx(r.Primitive.div,{...u,ref:n}),f):null});c.displayName="Portal",exports.Portal=c;