@mindlogic-ai/logician-ui 3.0.0-alpha.16 → 3.0.0-alpha.18
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/components/Icon/icons/language.svg.js +1 -1
- package/dist/components/Icon/icons/language.svg.js.map +1 -1
- package/dist/components/Icon/icons/language.svg.mjs +1 -1
- package/dist/components/Icon/icons/language.svg.mjs.map +1 -1
- package/dist/components/Popover/Popover.d.ts +19 -0
- package/dist/components/Popover/Popover.d.ts.map +1 -0
- package/dist/components/Popover/Popover.js +26 -0
- package/dist/components/Popover/Popover.js.map +1 -0
- package/dist/components/Popover/Popover.mjs +24 -0
- package/dist/components/Popover/Popover.mjs.map +1 -0
- package/dist/components/Popover/Popover.types.d.ts +11 -0
- package/dist/components/Popover/Popover.types.d.ts.map +1 -0
- package/dist/components/Popover/Popover.types.js +13 -0
- package/dist/components/Popover/Popover.types.js.map +1 -0
- package/dist/components/Popover/Popover.types.mjs +10 -0
- package/dist/components/Popover/Popover.types.mjs.map +1 -0
- package/dist/components/Popover/PopoverContent.d.ts +3 -0
- package/dist/components/Popover/PopoverContent.d.ts.map +1 -0
- package/dist/components/Popover/PopoverContent.js +17 -0
- package/dist/components/Popover/PopoverContent.js.map +1 -0
- package/dist/components/Popover/PopoverContent.mjs +15 -0
- package/dist/components/Popover/PopoverContent.mjs.map +1 -0
- package/dist/components/Popover/index.d.ts +3 -0
- package/dist/components/Popover/index.d.ts.map +1 -0
- package/dist/components/ScaledContext/ScaledContext.d.ts +3 -0
- package/dist/components/ScaledContext/ScaledContext.d.ts.map +1 -0
- package/dist/components/ScaledContext/ScaledContext.js +45 -0
- package/dist/components/ScaledContext/ScaledContext.js.map +1 -0
- package/dist/components/ScaledContext/ScaledContext.mjs +43 -0
- package/dist/components/ScaledContext/ScaledContext.mjs.map +1 -0
- package/dist/components/ScaledContext/ScaledContext.types.d.ts +3 -0
- package/dist/components/ScaledContext/ScaledContext.types.d.ts.map +1 -0
- package/dist/components/ScaledContext/index.d.ts +3 -0
- package/dist/components/ScaledContext/index.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Icon/icons/language.svg +1 -1
- package/src/components/Popover/Popover.stories.tsx +141 -0
- package/src/components/Popover/Popover.tsx +29 -0
- package/src/components/Popover/Popover.types.ts +18 -0
- package/src/components/Popover/PopoverContent.tsx +20 -0
- package/src/components/Popover/index.ts +2 -0
- package/src/components/ScaledContext/ScaledContext.stories.tsx +135 -0
- package/src/components/ScaledContext/ScaledContext.tsx +55 -0
- package/src/components/ScaledContext/ScaledContext.types.ts +3 -0
- package/src/components/ScaledContext/index.ts +2 -0
- package/src/index.ts +2 -0
|
@@ -30,7 +30,7 @@ var SvgLanguage = function SvgLanguage(props) {
|
|
|
30
30
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
31
31
|
xmlns: "http://www.w3.org/2000/svg",
|
|
32
32
|
fill: "none",
|
|
33
|
-
viewBox: "
|
|
33
|
+
viewBox: "2.4 2.4 15.2 15.2"
|
|
34
34
|
}, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
|
|
35
35
|
stroke: "currentColor",
|
|
36
36
|
strokeWidth: 1.2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language.svg.js","sources":["../../../../src/components/Icon/icons/language.svg"],"sourcesContent":["<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"
|
|
1
|
+
{"version":3,"file":"language.svg.js","sources":["../../../../src/components/Icon/icons/language.svg"],"sourcesContent":["<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"2.4 2.4 15.2 15.2\"><path stroke=\"currentColor\" stroke-width=\"1.2\" d=\"M10 17a7 7 0 1 0 0-14m0 14a7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I,WAAW,EAAE,GAAG;AACpB,IAAI,CAAC,EAAE;AACP,GAAG,CAAC,CAAC,CAAC;AACN;;;;"}
|
|
@@ -7,7 +7,7 @@ var SvgLanguage = function SvgLanguage(props) {
|
|
|
7
7
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
8
8
|
xmlns: "http://www.w3.org/2000/svg",
|
|
9
9
|
fill: "none",
|
|
10
|
-
viewBox: "
|
|
10
|
+
viewBox: "2.4 2.4 15.2 15.2"
|
|
11
11
|
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
12
12
|
stroke: "currentColor",
|
|
13
13
|
strokeWidth: 1.2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language.svg.mjs","sources":["../../../../src/components/Icon/icons/language.svg"],"sourcesContent":["<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"
|
|
1
|
+
{"version":3,"file":"language.svg.mjs","sources":["../../../../src/components/Icon/icons/language.svg"],"sourcesContent":["<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"2.4 2.4 15.2 15.2\"><path stroke=\"currentColor\" stroke-width=\"1.2\" d=\"M10 17a7 7 0 1 0 0-14m0 14a7 7 0 1 1 0-14m0 14c-1.691 0-3.062-3.134-3.062-7S8.308 3 10 3m0 14c1.691 0 3.063-3.134 3.063-7S11.69 3 10 3M4.313 13.402c1.282-.734 3.413-1.214 5.824-1.214 2.517 0 4.728.523 5.988 1.312M4.313 6.598c1.282.734 3.413 1.215 5.824 1.215 2.517 0 4.728-.524 5.988-1.313\"/></svg>"],"names":[],"mappings":";;;AAAA,IAAI,KAAK;AACT,SAAS,QAAQ,GAAG,EAAE,OAAO,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAEhR,IAAC,WAAW,GAAG,SAAS,WAAW,CAAC,KAAK,EAAE;AAC9C,EAAE,oBAAoB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC;AAC1D,IAAI,KAAK,EAAE,4BAA4B;AACvC,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE;AACb,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,KAAK,gBAAgB,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE;AACxE,IAAI,MAAM,EAAE,cAAc;AAC1B,IAAI,WAAW,EAAE,GAAG;AACpB,IAAI,CAAC,EAAE;AACP,GAAG,CAAC,CAAC,CAAC;AACN;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Popover as ChakraPopover } from '@chakra-ui/react';
|
|
2
|
+
import { PopoverProps } from './Popover.types';
|
|
3
|
+
export declare const Popover: {
|
|
4
|
+
({ baseFontSize, children, ...props }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
} & {
|
|
7
|
+
Anchor: import("react").ForwardRefExoticComponent<ChakraPopover.AnchorProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
|
+
Trigger: import("react").ForwardRefExoticComponent<ChakraPopover.TriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
Content: import("react").ForwardRefExoticComponent<ChakraPopover.ContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
10
|
+
Arrow: import("react").ForwardRefExoticComponent<ChakraPopover.ArrowProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
|
+
ArrowTip: import("react").ForwardRefExoticComponent<ChakraPopover.ArrowTipProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
|
+
CloseTrigger: import("react").ForwardRefExoticComponent<ChakraPopover.CloseTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
13
|
+
Header: import("react").ForwardRefExoticComponent<ChakraPopover.HeaderProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
Body: import("react").ForwardRefExoticComponent<ChakraPopover.BodyProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
Title: import("react").ForwardRefExoticComponent<ChakraPopover.TitleProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
16
|
+
Description: import("react").ForwardRefExoticComponent<ChakraPopover.DescriptionProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
17
|
+
Footer: import("react").ForwardRefExoticComponent<ChakraPopover.FooterProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=Popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAkB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAa/D,eAAO,MAAM,OAAO;2CAPjB,YAAY;;;;;;;;;;;;;;CAmBb,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var react = require('@chakra-ui/react');
|
|
6
|
+
var PopoverContent = require('./PopoverContent.js');
|
|
7
|
+
var Popover_types = require('./Popover.types.js');
|
|
8
|
+
|
|
9
|
+
const PopoverBase = ({ baseFontSize = '14px', children, ...props }) => (jsxRuntime.jsx(Popover_types.PopoverContext.Provider, { value: { baseFontSize }, children: jsxRuntime.jsx(react.Popover.Root, { ...props, children: children }) }));
|
|
10
|
+
PopoverBase.displayName = 'Popover';
|
|
11
|
+
const Popover = Object.assign(PopoverBase, {
|
|
12
|
+
Anchor: react.Popover.Anchor,
|
|
13
|
+
Trigger: react.Popover.Trigger,
|
|
14
|
+
Content: PopoverContent.PopoverContent,
|
|
15
|
+
Arrow: react.Popover.Arrow,
|
|
16
|
+
ArrowTip: react.Popover.ArrowTip,
|
|
17
|
+
CloseTrigger: react.Popover.CloseTrigger,
|
|
18
|
+
Header: react.Popover.Header,
|
|
19
|
+
Body: react.Popover.Body,
|
|
20
|
+
Title: react.Popover.Title,
|
|
21
|
+
Description: react.Popover.Description,
|
|
22
|
+
Footer: react.Popover.Footer,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
exports.Popover = Popover;
|
|
26
|
+
//# sourceMappingURL=Popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.js","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":[null],"names":["_jsx","PopoverContext","ChakraPopover","PopoverContent"],"mappings":";;;;;;;;AAKA,MAAM,WAAW,GAAG,CAAC,EACnB,YAAY,GAAG,MAAM,EACrB,QAAQ,EACR,GAAG,KAAK,EACK,MACbA,cAAA,CAACC,4BAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,YAAY,EAAE,YAC9CD,cAAA,CAACE,aAAa,CAAC,IAAI,OAAK,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAsB,EAAA,CACtC,CAC3B;AACD,WAAW,CAAC,WAAW,GAAG,SAAS;MAEtB,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;IAChD,MAAM,EAAEA,aAAa,CAAC,MAAM;IAC5B,OAAO,EAAEA,aAAa,CAAC,OAAO;AAC9B,IAAA,OAAO,EAAEC,6BAAc;IACvB,KAAK,EAAED,aAAa,CAAC,KAAK;IAC1B,QAAQ,EAAEA,aAAa,CAAC,QAAQ;IAChC,YAAY,EAAEA,aAAa,CAAC,YAAY;IACxC,MAAM,EAAEA,aAAa,CAAC,MAAM;IAC5B,IAAI,EAAEA,aAAa,CAAC,IAAI;IACxB,KAAK,EAAEA,aAAa,CAAC,KAAK;IAC1B,WAAW,EAAEA,aAAa,CAAC,WAAW;IACtC,MAAM,EAAEA,aAAa,CAAC,MAAM;AAC7B,CAAA;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Popover as Popover$1 } from '@chakra-ui/react';
|
|
4
|
+
import { PopoverContent } from './PopoverContent.mjs';
|
|
5
|
+
import { PopoverContext } from './Popover.types.mjs';
|
|
6
|
+
|
|
7
|
+
const PopoverBase = ({ baseFontSize = '14px', children, ...props }) => (jsx(PopoverContext.Provider, { value: { baseFontSize }, children: jsx(Popover$1.Root, { ...props, children: children }) }));
|
|
8
|
+
PopoverBase.displayName = 'Popover';
|
|
9
|
+
const Popover = Object.assign(PopoverBase, {
|
|
10
|
+
Anchor: Popover$1.Anchor,
|
|
11
|
+
Trigger: Popover$1.Trigger,
|
|
12
|
+
Content: PopoverContent,
|
|
13
|
+
Arrow: Popover$1.Arrow,
|
|
14
|
+
ArrowTip: Popover$1.ArrowTip,
|
|
15
|
+
CloseTrigger: Popover$1.CloseTrigger,
|
|
16
|
+
Header: Popover$1.Header,
|
|
17
|
+
Body: Popover$1.Body,
|
|
18
|
+
Title: Popover$1.Title,
|
|
19
|
+
Description: Popover$1.Description,
|
|
20
|
+
Footer: Popover$1.Footer,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { Popover };
|
|
24
|
+
//# sourceMappingURL=Popover.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.mjs","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":[null],"names":["_jsx","ChakraPopover"],"mappings":";;;;;;AAKA,MAAM,WAAW,GAAG,CAAC,EACnB,YAAY,GAAG,MAAM,EACrB,QAAQ,EACR,GAAG,KAAK,EACK,MACbA,GAAA,CAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,YAAY,EAAE,YAC9CA,GAAA,CAACC,SAAa,CAAC,IAAI,OAAK,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAsB,EAAA,CACtC,CAC3B;AACD,WAAW,CAAC,WAAW,GAAG,SAAS;MAEtB,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;IAChD,MAAM,EAAEA,SAAa,CAAC,MAAM;IAC5B,OAAO,EAAEA,SAAa,CAAC,OAAO;AAC9B,IAAA,OAAO,EAAE,cAAc;IACvB,KAAK,EAAEA,SAAa,CAAC,KAAK;IAC1B,QAAQ,EAAEA,SAAa,CAAC,QAAQ;IAChC,YAAY,EAAEA,SAAa,CAAC,YAAY;IACxC,MAAM,EAAEA,SAAa,CAAC,MAAM;IAC5B,IAAI,EAAEA,SAAa,CAAC,IAAI;IACxB,KAAK,EAAEA,SAAa,CAAC,KAAK;IAC1B,WAAW,EAAEA,SAAa,CAAC,WAAW;IACtC,MAAM,EAAEA,SAAa,CAAC,MAAM;AAC7B,CAAA;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover as ChakraPopover } from '@chakra-ui/react';
|
|
3
|
+
export interface PopoverContextValue {
|
|
4
|
+
baseFontSize: string | number;
|
|
5
|
+
}
|
|
6
|
+
export declare const PopoverContext: React.Context<PopoverContextValue>;
|
|
7
|
+
export declare const usePopoverContext: () => PopoverContextValue;
|
|
8
|
+
export type PopoverProps = React.ComponentPropsWithoutRef<typeof ChakraPopover.Root> & {
|
|
9
|
+
baseFontSize?: string | number;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=Popover.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.types.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE5D,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,cAAc,oCAEzB,CAAC;AAEH,eAAO,MAAM,iBAAiB,2BAAyC,CAAC;AAExE,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,wBAAwB,CACvD,OAAO,aAAa,CAAC,IAAI,CAC1B,GAAG;IACF,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
const PopoverContext = React.createContext({
|
|
7
|
+
baseFontSize: '14px',
|
|
8
|
+
});
|
|
9
|
+
const usePopoverContext = () => React.useContext(PopoverContext);
|
|
10
|
+
|
|
11
|
+
exports.PopoverContext = PopoverContext;
|
|
12
|
+
exports.usePopoverContext = usePopoverContext;
|
|
13
|
+
//# sourceMappingURL=Popover.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.types.js","sources":["../../../src/components/Popover/Popover.types.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAOO,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAAsB;AACrE,IAAA,YAAY,EAAE,MAAM;AACrB,CAAA;AAEM,MAAM,iBAAiB,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,cAAc;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
const PopoverContext = React__default.createContext({
|
|
5
|
+
baseFontSize: '14px',
|
|
6
|
+
});
|
|
7
|
+
const usePopoverContext = () => React__default.useContext(PopoverContext);
|
|
8
|
+
|
|
9
|
+
export { PopoverContext, usePopoverContext };
|
|
10
|
+
//# sourceMappingURL=Popover.types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.types.mjs","sources":["../../../src/components/Popover/Popover.types.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;AAOO,MAAM,cAAc,GAAGA,cAAK,CAAC,aAAa,CAAsB;AACrE,IAAA,YAAY,EAAE,MAAM;AACrB,CAAA;AAEM,MAAM,iBAAiB,GAAG,MAAMA,cAAK,CAAC,UAAU,CAAC,cAAc;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopoverContent.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/PopoverContent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAuB,MAAM,kBAAkB,CAAC;AAKjF,eAAO,MAAM,cAAc,uHAY1B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var react = require('@chakra-ui/react');
|
|
7
|
+
var ScaledContext = require('../ScaledContext/ScaledContext.js');
|
|
8
|
+
var Popover_types = require('./Popover.types.js');
|
|
9
|
+
|
|
10
|
+
const PopoverContent = React.forwardRef(({ children, ...props }, ref) => {
|
|
11
|
+
const { baseFontSize } = Popover_types.usePopoverContext();
|
|
12
|
+
return (jsxRuntime.jsx(react.Popover.Positioner, { children: jsxRuntime.jsx(react.Popover.Content, { ref: ref, ...props, children: jsxRuntime.jsx(ScaledContext.ScaledContext, { fontSize: baseFontSize, children: children }) }) }));
|
|
13
|
+
});
|
|
14
|
+
PopoverContent.displayName = 'Popover.Content';
|
|
15
|
+
|
|
16
|
+
exports.PopoverContent = PopoverContent;
|
|
17
|
+
//# sourceMappingURL=PopoverContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopoverContent.js","sources":["../../../src/components/Popover/PopoverContent.tsx"],"sourcesContent":[null],"names":["forwardRef","usePopoverContext","_jsx","ChakraPopover","ScaledContext"],"mappings":";;;;;;;;;AAMO,MAAM,cAAc,GAAGA,gBAAU,CACtC,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;AAC9B,IAAA,MAAM,EAAE,YAAY,EAAE,GAAGC,+BAAiB,EAAE;AAE5C,IAAA,QACEC,cAAA,CAACC,aAAa,CAAC,UAAU,EAAA,EAAA,QAAA,EACvBD,cAAA,CAACC,aAAa,CAAC,OAAO,EAAA,EAAC,GAAG,EAAE,GAAG,EAAA,GAAM,KAAK,EAAA,QAAA,EACxCD,cAAA,CAACE,2BAAa,EAAA,EAAC,QAAQ,EAAE,YAAY,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAiB,EAAA,CAC3C,EAAA,CACC;AAE/B,CAAC;AAEH,cAAc,CAAC,WAAW,GAAG,iBAAiB;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { Popover } from '@chakra-ui/react';
|
|
5
|
+
import { ScaledContext } from '../ScaledContext/ScaledContext.mjs';
|
|
6
|
+
import { usePopoverContext } from './Popover.types.mjs';
|
|
7
|
+
|
|
8
|
+
const PopoverContent = forwardRef(({ children, ...props }, ref) => {
|
|
9
|
+
const { baseFontSize } = usePopoverContext();
|
|
10
|
+
return (jsx(Popover.Positioner, { children: jsx(Popover.Content, { ref: ref, ...props, children: jsx(ScaledContext, { fontSize: baseFontSize, children: children }) }) }));
|
|
11
|
+
});
|
|
12
|
+
PopoverContent.displayName = 'Popover.Content';
|
|
13
|
+
|
|
14
|
+
export { PopoverContent };
|
|
15
|
+
//# sourceMappingURL=PopoverContent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopoverContent.mjs","sources":["../../../src/components/Popover/PopoverContent.tsx"],"sourcesContent":[null],"names":["_jsx","ChakraPopover"],"mappings":";;;;;;;AAMO,MAAM,cAAc,GAAG,UAAU,CACtC,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;AAC9B,IAAA,MAAM,EAAE,YAAY,EAAE,GAAG,iBAAiB,EAAE;AAE5C,IAAA,QACEA,GAAA,CAACC,OAAa,CAAC,UAAU,EAAA,EAAA,QAAA,EACvBD,GAAA,CAACC,OAAa,CAAC,OAAO,EAAA,EAAC,GAAG,EAAE,GAAG,EAAA,GAAM,KAAK,EAAA,QAAA,EACxCD,GAAA,CAAC,aAAa,EAAA,EAAC,QAAQ,EAAE,YAAY,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAiB,EAAA,CAC3C,EAAA,CACC;AAE/B,CAAC;AAEH,cAAc,CAAC,WAAW,GAAG,iBAAiB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScaledContext.d.ts","sourceRoot":"","sources":["../../../src/components/ScaledContext/ScaledContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAqC1C,eAAO,MAAM,aAAa,4GAazB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var react = require('@chakra-ui/react');
|
|
7
|
+
|
|
8
|
+
const SCOPED_CATEGORIES = new Set(['spacing', 'sizes']);
|
|
9
|
+
const LENGTH_RE = /^(-?[\d.]+)(r?em)$/;
|
|
10
|
+
// NOTE: relies on system.tokens.cssVarMap and system.tokens.allTokens,
|
|
11
|
+
// which are internal Chakra v3 APIs. If Chakra renames these structures in a
|
|
12
|
+
// future release, getScopedVars will return {} and scaling will silently stop
|
|
13
|
+
// working. The null-check on `base` below guards the most likely failure mode.
|
|
14
|
+
function getScopedVars(system) {
|
|
15
|
+
const base = system.tokens.cssVarMap.get('base');
|
|
16
|
+
if (!base)
|
|
17
|
+
return {};
|
|
18
|
+
const result = {};
|
|
19
|
+
for (const token of system.tokens.allTokens) {
|
|
20
|
+
const { category, negative, virtual, cssVar } = token.extensions;
|
|
21
|
+
if (negative || virtual || !cssVar)
|
|
22
|
+
continue;
|
|
23
|
+
if (!SCOPED_CATEGORIES.has(category))
|
|
24
|
+
continue;
|
|
25
|
+
const value = base.get(cssVar.var);
|
|
26
|
+
if (!value)
|
|
27
|
+
continue;
|
|
28
|
+
const match = LENGTH_RE.exec(value);
|
|
29
|
+
if (!match)
|
|
30
|
+
continue;
|
|
31
|
+
result[cssVar.var] = `${match[1]}em`;
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
const ScaledContext = React.forwardRef(({ style, children, ...rest }, ref) => {
|
|
36
|
+
const system = react.useChakraContext();
|
|
37
|
+
// system is the Chakra context object, which is stable across renders
|
|
38
|
+
// (same reference for the lifetime of the provider). useMemo is correct here.
|
|
39
|
+
const scopedVars = React.useMemo(() => getScopedVars(system), [system]);
|
|
40
|
+
return (jsxRuntime.jsx(react.Box, { ref: ref, style: { ...scopedVars, ...style }, ...rest, children: children }));
|
|
41
|
+
});
|
|
42
|
+
ScaledContext.displayName = 'ScaledContext';
|
|
43
|
+
|
|
44
|
+
exports.ScaledContext = ScaledContext;
|
|
45
|
+
//# sourceMappingURL=ScaledContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScaledContext.js","sources":["../../../src/components/ScaledContext/ScaledContext.tsx"],"sourcesContent":[null],"names":["forwardRef","useChakraContext","_jsx","Box"],"mappings":";;;;;;;AAOA,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACvD,MAAM,SAAS,GAAG,oBAAoB;AAEtC;AACA;AACA;AACA;AACA,SAAS,aAAa,CACpB,MAA2C,EAAA;AAE3C,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC;AAChD,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,OAAO,EAAE;IAEpB,MAAM,MAAM,GAA2B,EAAE;IAEzC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;AAC3C,QAAA,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,UAAU;AAChE,QAAA,IAAI,QAAQ,IAAI,OAAO,IAAI,CAAC,MAAM;YAAE;AACpC,QAAA,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE;QAEtC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAuB;AACxD,QAAA,IAAI,CAAC,KAAK;YAAE;QAEZ,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;AACnC,QAAA,IAAI,CAAC,KAAK;YAAE;AAEZ,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAA,EAAG,KAAK,CAAC,CAAC,CAAC,CAAA,EAAA,CAAI;IACtC;AAEA,IAAA,OAAO,MAA6B;AACtC;AAEO,MAAM,aAAa,GAAGA,gBAAU,CACrC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,KAAI;AACpC,IAAA,MAAM,MAAM,GAAGC,sBAAgB,EAAE;;;AAGjC,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAEvE,QACEC,eAACC,SAAG,EAAA,EAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,EAAE,EAAA,GAAM,IAAI,EAAA,QAAA,EACxD,QAAQ,EAAA,CACL;AAEV,CAAC;AAGH,aAAa,CAAC,WAAW,GAAG,eAAe;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React__default, { forwardRef } from 'react';
|
|
4
|
+
import { useChakraContext, Box } from '@chakra-ui/react';
|
|
5
|
+
|
|
6
|
+
const SCOPED_CATEGORIES = new Set(['spacing', 'sizes']);
|
|
7
|
+
const LENGTH_RE = /^(-?[\d.]+)(r?em)$/;
|
|
8
|
+
// NOTE: relies on system.tokens.cssVarMap and system.tokens.allTokens,
|
|
9
|
+
// which are internal Chakra v3 APIs. If Chakra renames these structures in a
|
|
10
|
+
// future release, getScopedVars will return {} and scaling will silently stop
|
|
11
|
+
// working. The null-check on `base` below guards the most likely failure mode.
|
|
12
|
+
function getScopedVars(system) {
|
|
13
|
+
const base = system.tokens.cssVarMap.get('base');
|
|
14
|
+
if (!base)
|
|
15
|
+
return {};
|
|
16
|
+
const result = {};
|
|
17
|
+
for (const token of system.tokens.allTokens) {
|
|
18
|
+
const { category, negative, virtual, cssVar } = token.extensions;
|
|
19
|
+
if (negative || virtual || !cssVar)
|
|
20
|
+
continue;
|
|
21
|
+
if (!SCOPED_CATEGORIES.has(category))
|
|
22
|
+
continue;
|
|
23
|
+
const value = base.get(cssVar.var);
|
|
24
|
+
if (!value)
|
|
25
|
+
continue;
|
|
26
|
+
const match = LENGTH_RE.exec(value);
|
|
27
|
+
if (!match)
|
|
28
|
+
continue;
|
|
29
|
+
result[cssVar.var] = `${match[1]}em`;
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
const ScaledContext = forwardRef(({ style, children, ...rest }, ref) => {
|
|
34
|
+
const system = useChakraContext();
|
|
35
|
+
// system is the Chakra context object, which is stable across renders
|
|
36
|
+
// (same reference for the lifetime of the provider). useMemo is correct here.
|
|
37
|
+
const scopedVars = React__default.useMemo(() => getScopedVars(system), [system]);
|
|
38
|
+
return (jsx(Box, { ref: ref, style: { ...scopedVars, ...style }, ...rest, children: children }));
|
|
39
|
+
});
|
|
40
|
+
ScaledContext.displayName = 'ScaledContext';
|
|
41
|
+
|
|
42
|
+
export { ScaledContext };
|
|
43
|
+
//# sourceMappingURL=ScaledContext.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScaledContext.mjs","sources":["../../../src/components/ScaledContext/ScaledContext.tsx"],"sourcesContent":[null],"names":["React","_jsx"],"mappings":";;;;;AAOA,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACvD,MAAM,SAAS,GAAG,oBAAoB;AAEtC;AACA;AACA;AACA;AACA,SAAS,aAAa,CACpB,MAA2C,EAAA;AAE3C,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC;AAChD,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,OAAO,EAAE;IAEp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Context.types.d.ts","sourceRoot":"","sources":["../../../src/components/ScaledContext/ScaledContext.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ScaledContext/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export * from './components/MaxLengthIndicator';
|
|
|
37
37
|
export * from './components/MDXEditor';
|
|
38
38
|
export * from './components/Menu';
|
|
39
39
|
export * from './components/Modal';
|
|
40
|
+
export * from './components/Popover';
|
|
40
41
|
export * from './components/MonthPicker';
|
|
41
42
|
export * from './components/Pagination';
|
|
42
43
|
export * from './components/PasswordInput';
|
|
@@ -47,6 +48,7 @@ export * from './components/Radio';
|
|
|
47
48
|
export * from './components/SeeMoreButton';
|
|
48
49
|
export * from './components/SegmentedControl';
|
|
49
50
|
export * from './components/SegmentedProgressBar';
|
|
51
|
+
export * from './components/ScaledContext';
|
|
50
52
|
export * from './components/Select';
|
|
51
53
|
export * from './components/Slider';
|
|
52
54
|
export * from './components/Spinner';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBA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,EAAE,EACF,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,IAAI,GACL,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -63,6 +63,7 @@ var ModalContent = require('./components/Modal/ModalContent/ModalContent.js');
|
|
|
63
63
|
var ModalFooter = require('./components/Modal/ModalFooter/ModalFooter.js');
|
|
64
64
|
var ModalHeader = require('./components/Modal/ModalHeader.js');
|
|
65
65
|
var ModalOverlay = require('./components/Modal/ModalOverlay.js');
|
|
66
|
+
var Popover = require('./components/Popover/Popover.js');
|
|
66
67
|
var constants = require('./components/MonthPicker/constants.js');
|
|
67
68
|
var MonthPicker = require('./components/MonthPicker/MonthPicker.js');
|
|
68
69
|
var Pagination = require('./components/Pagination/Pagination.js');
|
|
@@ -76,6 +77,7 @@ var SeeMoreButton = require('./components/SeeMoreButton/SeeMoreButton.js');
|
|
|
76
77
|
var SegmentedControl = require('./components/SegmentedControl/SegmentedControl.js');
|
|
77
78
|
var ProgressSegment = require('./components/SegmentedProgressBar/ProgressSegment.js');
|
|
78
79
|
var SegmentedProgressBar = require('./components/SegmentedProgressBar/SegmentedProgressBar.js');
|
|
80
|
+
var ScaledContext = require('./components/ScaledContext/ScaledContext.js');
|
|
79
81
|
var Select = require('./components/Select/Select.js');
|
|
80
82
|
var Slider = require('./components/Slider/Slider.js');
|
|
81
83
|
var SliderControl = require('./components/Slider/SliderControl/SliderControl.js');
|
|
@@ -207,6 +209,7 @@ exports.ModalContent = ModalContent.ModalContent;
|
|
|
207
209
|
exports.ModalFooter = ModalFooter.ModalFooter;
|
|
208
210
|
exports.ModalHeader = ModalHeader.ModalHeader;
|
|
209
211
|
exports.ModalOverlay = ModalOverlay.ModalOverlay;
|
|
212
|
+
exports.Popover = Popover.Popover;
|
|
210
213
|
exports.MONTHS = constants.MONTHS;
|
|
211
214
|
exports.getDateFnsLocale = constants.getDateFnsLocale;
|
|
212
215
|
exports.getDayNames = constants.getDayNames;
|
|
@@ -225,6 +228,7 @@ exports.SeeMoreButton = SeeMoreButton.SeeMoreButton;
|
|
|
225
228
|
exports.SegmentedControl = SegmentedControl.SegmentedControl;
|
|
226
229
|
exports.ProgressSegment = ProgressSegment.ProgressSegment;
|
|
227
230
|
exports.SegmentedProgressBar = SegmentedProgressBar.SegmentedProgressBar;
|
|
231
|
+
exports.ScaledContext = ScaledContext.ScaledContext;
|
|
228
232
|
exports.Select = Select.Select;
|
|
229
233
|
exports.Slider = Slider.Slider;
|
|
230
234
|
exports.SliderControl = SliderControl.SliderControl;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -61,6 +61,7 @@ export { ModalContent } from './components/Modal/ModalContent/ModalContent.mjs';
|
|
|
61
61
|
export { ModalFooter } from './components/Modal/ModalFooter/ModalFooter.mjs';
|
|
62
62
|
export { ModalHeader } from './components/Modal/ModalHeader.mjs';
|
|
63
63
|
export { ModalOverlay } from './components/Modal/ModalOverlay.mjs';
|
|
64
|
+
export { Popover } from './components/Popover/Popover.mjs';
|
|
64
65
|
export { MONTHS, getDateFnsLocale, getDayNames, getDefaultDateFormat, getDefaultFullDateFormat, getMonthNames } from './components/MonthPicker/constants.mjs';
|
|
65
66
|
export { MonthPicker } from './components/MonthPicker/MonthPicker.mjs';
|
|
66
67
|
export { Pagination } from './components/Pagination/Pagination.mjs';
|
|
@@ -74,6 +75,7 @@ export { SeeMoreButton } from './components/SeeMoreButton/SeeMoreButton.mjs';
|
|
|
74
75
|
export { SegmentedControl } from './components/SegmentedControl/SegmentedControl.mjs';
|
|
75
76
|
export { ProgressSegment } from './components/SegmentedProgressBar/ProgressSegment.mjs';
|
|
76
77
|
export { SegmentedProgressBar } from './components/SegmentedProgressBar/SegmentedProgressBar.mjs';
|
|
78
|
+
export { ScaledContext } from './components/ScaledContext/ScaledContext.mjs';
|
|
77
79
|
export { Select } from './components/Select/Select.mjs';
|
|
78
80
|
export { Slider } from './components/Slider/Slider.mjs';
|
|
79
81
|
export { SliderControl } from './components/Slider/SliderControl/SliderControl.mjs';
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="2.4 2.4 15.2 15.2"><path stroke="currentColor" stroke-width="1.2" d="M10 17a7 7 0 1 0 0-14m0 14a7 7 0 1 1 0-14m0 14c-1.691 0-3.062-3.134-3.062-7S8.308 3 10 3m0 14c1.691 0 3.063-3.134 3.063-7S11.69 3 10 3M4.313 13.402c1.282-.734 3.413-1.214 5.824-1.214 2.517 0 4.728.523 5.988 1.312M4.313 6.598c1.282.734 3.413 1.215 5.824 1.215 2.517 0 4.728-.524 5.988-1.313"/></svg>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Stack, Text } from '@chakra-ui/react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
import { Checkbox } from '../Checkbox';
|
|
6
|
+
import { Popover } from './Popover';
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Components/Popover',
|
|
10
|
+
component: Popover,
|
|
11
|
+
parameters: { layout: 'centered' },
|
|
12
|
+
argTypes: {
|
|
13
|
+
baseFontSize: { control: 'text' },
|
|
14
|
+
},
|
|
15
|
+
} satisfies Meta<typeof Popover>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
args: { baseFontSize: '14px' },
|
|
23
|
+
render: args => (
|
|
24
|
+
<Popover {...args}>
|
|
25
|
+
<Popover.Trigger asChild>
|
|
26
|
+
<Button variant="outline">Open Popover</Button>
|
|
27
|
+
</Popover.Trigger>
|
|
28
|
+
<Popover.Content>
|
|
29
|
+
<Popover.Arrow>
|
|
30
|
+
<Popover.ArrowTip />
|
|
31
|
+
</Popover.Arrow>
|
|
32
|
+
<Popover.Title>Popover Title</Popover.Title>
|
|
33
|
+
<Popover.Description>
|
|
34
|
+
This is some popover content. Spacing and font sizes scale with{' '}
|
|
35
|
+
<code>baseFontSize</code>.
|
|
36
|
+
</Popover.Description>
|
|
37
|
+
</Popover.Content>
|
|
38
|
+
</Popover>
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const WithForm: Story = {
|
|
43
|
+
args: { baseFontSize: '14px' },
|
|
44
|
+
render: args => (
|
|
45
|
+
<Popover {...args}>
|
|
46
|
+
<Popover.Trigger asChild>
|
|
47
|
+
<Button variant="outline">Settings</Button>
|
|
48
|
+
</Popover.Trigger>
|
|
49
|
+
<Popover.Content>
|
|
50
|
+
<Popover.Arrow>
|
|
51
|
+
<Popover.ArrowTip />
|
|
52
|
+
</Popover.Arrow>
|
|
53
|
+
<Popover.Title>Preferences</Popover.Title>
|
|
54
|
+
<Stack gap={3} mt={2}>
|
|
55
|
+
<Checkbox>
|
|
56
|
+
<Checkbox.Control />
|
|
57
|
+
<Checkbox.Label>Enable notifications</Checkbox.Label>
|
|
58
|
+
</Checkbox>
|
|
59
|
+
<Checkbox>
|
|
60
|
+
<Checkbox.Control />
|
|
61
|
+
<Checkbox.Label>Auto-save</Checkbox.Label>
|
|
62
|
+
</Checkbox>
|
|
63
|
+
</Stack>
|
|
64
|
+
<Popover.Footer mt={4}>
|
|
65
|
+
<Button size="sm">Save</Button>
|
|
66
|
+
</Popover.Footer>
|
|
67
|
+
</Popover.Content>
|
|
68
|
+
</Popover>
|
|
69
|
+
),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const SmallFontSize: Story = {
|
|
73
|
+
args: { baseFontSize: '12px' },
|
|
74
|
+
render: args => (
|
|
75
|
+
<Popover {...args}>
|
|
76
|
+
<Popover.Trigger asChild>
|
|
77
|
+
<Button variant="outline">Compact (12px)</Button>
|
|
78
|
+
</Popover.Trigger>
|
|
79
|
+
<Popover.Content>
|
|
80
|
+
<Popover.Arrow>
|
|
81
|
+
<Popover.ArrowTip />
|
|
82
|
+
</Popover.Arrow>
|
|
83
|
+
<Popover.Title>Compact Popover</Popover.Title>
|
|
84
|
+
<Popover.Description>
|
|
85
|
+
Content and spacing scale down with the smaller base font size.
|
|
86
|
+
</Popover.Description>
|
|
87
|
+
</Popover.Content>
|
|
88
|
+
</Popover>
|
|
89
|
+
),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const LargeFontSize: Story = {
|
|
93
|
+
args: { baseFontSize: '18px' },
|
|
94
|
+
render: args => (
|
|
95
|
+
<Popover {...args}>
|
|
96
|
+
<Popover.Trigger asChild>
|
|
97
|
+
<Button variant="outline">Spacious (18px)</Button>
|
|
98
|
+
</Popover.Trigger>
|
|
99
|
+
<Popover.Content>
|
|
100
|
+
<Popover.Arrow>
|
|
101
|
+
<Popover.ArrowTip />
|
|
102
|
+
</Popover.Arrow>
|
|
103
|
+
<Popover.Title>Spacious Popover</Popover.Title>
|
|
104
|
+
<Popover.Description>
|
|
105
|
+
Content and spacing scale up with the larger base font size.
|
|
106
|
+
</Popover.Description>
|
|
107
|
+
</Popover.Content>
|
|
108
|
+
</Popover>
|
|
109
|
+
),
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const Comparison: Story = {
|
|
113
|
+
args: { baseFontSize: '14px' },
|
|
114
|
+
parameters: {
|
|
115
|
+
docs: {
|
|
116
|
+
description: {
|
|
117
|
+
story: 'The same popover content at different base font sizes, shown side by side.',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
render: () => (
|
|
122
|
+
<Stack direction="row" gap={4}>
|
|
123
|
+
{(['12px', '14px', '18px'] as const).map(size => (
|
|
124
|
+
<Popover key={size} baseFontSize={size} open>
|
|
125
|
+
<Popover.Trigger asChild>
|
|
126
|
+
<Button variant="outline" size="sm">{size}</Button>
|
|
127
|
+
</Popover.Trigger>
|
|
128
|
+
<Popover.Content>
|
|
129
|
+
<Popover.Arrow>
|
|
130
|
+
<Popover.ArrowTip />
|
|
131
|
+
</Popover.Arrow>
|
|
132
|
+
<Popover.Title>Title</Popover.Title>
|
|
133
|
+
<Popover.Description>
|
|
134
|
+
Body text at {size}.
|
|
135
|
+
</Popover.Description>
|
|
136
|
+
</Popover.Content>
|
|
137
|
+
</Popover>
|
|
138
|
+
))}
|
|
139
|
+
</Stack>
|
|
140
|
+
),
|
|
141
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Popover as ChakraPopover } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
import { PopoverContent } from './PopoverContent';
|
|
4
|
+
import { PopoverContext, PopoverProps } from './Popover.types';
|
|
5
|
+
|
|
6
|
+
const PopoverBase = ({
|
|
7
|
+
baseFontSize = '14px',
|
|
8
|
+
children,
|
|
9
|
+
...props
|
|
10
|
+
}: PopoverProps) => (
|
|
11
|
+
<PopoverContext.Provider value={{ baseFontSize }}>
|
|
12
|
+
<ChakraPopover.Root {...props}>{children}</ChakraPopover.Root>
|
|
13
|
+
</PopoverContext.Provider>
|
|
14
|
+
);
|
|
15
|
+
PopoverBase.displayName = 'Popover';
|
|
16
|
+
|
|
17
|
+
export const Popover = Object.assign(PopoverBase, {
|
|
18
|
+
Anchor: ChakraPopover.Anchor,
|
|
19
|
+
Trigger: ChakraPopover.Trigger,
|
|
20
|
+
Content: PopoverContent,
|
|
21
|
+
Arrow: ChakraPopover.Arrow,
|
|
22
|
+
ArrowTip: ChakraPopover.ArrowTip,
|
|
23
|
+
CloseTrigger: ChakraPopover.CloseTrigger,
|
|
24
|
+
Header: ChakraPopover.Header,
|
|
25
|
+
Body: ChakraPopover.Body,
|
|
26
|
+
Title: ChakraPopover.Title,
|
|
27
|
+
Description: ChakraPopover.Description,
|
|
28
|
+
Footer: ChakraPopover.Footer,
|
|
29
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover as ChakraPopover } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
export interface PopoverContextValue {
|
|
5
|
+
baseFontSize: string | number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const PopoverContext = React.createContext<PopoverContextValue>({
|
|
9
|
+
baseFontSize: '14px',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const usePopoverContext = () => React.useContext(PopoverContext);
|
|
13
|
+
|
|
14
|
+
export type PopoverProps = React.ComponentPropsWithoutRef<
|
|
15
|
+
typeof ChakraPopover.Root
|
|
16
|
+
> & {
|
|
17
|
+
baseFontSize?: string | number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { Popover as ChakraPopover, PopoverContentProps } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { ScaledContext } from '../ScaledContext';
|
|
5
|
+
import { usePopoverContext } from './Popover.types';
|
|
6
|
+
|
|
7
|
+
export const PopoverContent = forwardRef<HTMLDivElement, PopoverContentProps>(
|
|
8
|
+
({ children, ...props }, ref) => {
|
|
9
|
+
const { baseFontSize } = usePopoverContext();
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ChakraPopover.Positioner>
|
|
13
|
+
<ChakraPopover.Content ref={ref} {...props}>
|
|
14
|
+
<ScaledContext fontSize={baseFontSize}>{children}</ScaledContext>
|
|
15
|
+
</ChakraPopover.Content>
|
|
16
|
+
</ChakraPopover.Positioner>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
PopoverContent.displayName = 'Popover.Content';
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Box, HStack, Stack, Text } from '@chakra-ui/react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
import { Checkbox } from '../Checkbox';
|
|
6
|
+
import { ScaledContext } from './ScaledContext';
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Setup/ScaledContext',
|
|
10
|
+
component: ScaledContext,
|
|
11
|
+
parameters: { layout: 'centered' },
|
|
12
|
+
argTypes: {
|
|
13
|
+
fontSize: { control: 'text' },
|
|
14
|
+
},
|
|
15
|
+
} satisfies Meta<typeof ScaledContext>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
const SampleContent = () => (
|
|
22
|
+
<Stack gap={3} p={3} borderWidth="1px" borderColor="gray.300" borderRadius="md">
|
|
23
|
+
<Button variant="outline">Button</Button>
|
|
24
|
+
<Checkbox>
|
|
25
|
+
<Checkbox.Control />
|
|
26
|
+
<Checkbox.Label>Checkbox</Checkbox.Label>
|
|
27
|
+
</Checkbox>
|
|
28
|
+
</Stack>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const Default: Story = {
|
|
32
|
+
args: { fontSize: '1rem' },
|
|
33
|
+
render: args => (
|
|
34
|
+
<ScaledContext {...args}>
|
|
35
|
+
<SampleContent />
|
|
36
|
+
</ScaledContext>
|
|
37
|
+
),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const ScalingRem: Story = {
|
|
41
|
+
args: { fontSize: '1rem' },
|
|
42
|
+
parameters: {
|
|
43
|
+
docs: {
|
|
44
|
+
description: {
|
|
45
|
+
story:
|
|
46
|
+
'Spacing and size tokens are converted from `rem` to `em`, so they scale proportionally with `fontSize`.',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
render: () => (
|
|
51
|
+
<HStack align="start" gap={8} flexWrap="wrap">
|
|
52
|
+
{(['0.75rem', '1rem', '1.25rem', '1.5rem'] as const).map(size => (
|
|
53
|
+
<Box key={size}>
|
|
54
|
+
<Text fontSize="xs" color="gray.500" mb={2} fontFamily="mono">
|
|
55
|
+
{size}
|
|
56
|
+
</Text>
|
|
57
|
+
<ScaledContext fontSize={size}>
|
|
58
|
+
<SampleContent />
|
|
59
|
+
</ScaledContext>
|
|
60
|
+
</Box>
|
|
61
|
+
))}
|
|
62
|
+
</HStack>
|
|
63
|
+
),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const ScalingPx: Story = {
|
|
67
|
+
args: { fontSize: '16px' },
|
|
68
|
+
parameters: {
|
|
69
|
+
docs: {
|
|
70
|
+
description: {
|
|
71
|
+
story: 'px values work too — spacing tokens still scale relative to the given font size.',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
render: () => (
|
|
76
|
+
<HStack align="start" gap={8} flexWrap="wrap">
|
|
77
|
+
{(['12px', '14px', '16px', '20px', '24px'] as const).map(size => (
|
|
78
|
+
<Box key={size}>
|
|
79
|
+
<Text fontSize="xs" color="gray.500" mb={2} fontFamily="mono">
|
|
80
|
+
{size}
|
|
81
|
+
</Text>
|
|
82
|
+
<ScaledContext fontSize={size}>
|
|
83
|
+
<SampleContent />
|
|
84
|
+
</ScaledContext>
|
|
85
|
+
</Box>
|
|
86
|
+
))}
|
|
87
|
+
</HStack>
|
|
88
|
+
),
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const NestedScaling: Story = {
|
|
92
|
+
args: { fontSize: '0.875rem' },
|
|
93
|
+
parameters: {
|
|
94
|
+
docs: {
|
|
95
|
+
description: {
|
|
96
|
+
story:
|
|
97
|
+
'ScaledContext can be nested. Each level scales relative to its own fontSize, allowing isolated UI regions to have independent densities.',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
render: () => (
|
|
102
|
+
<ScaledContext
|
|
103
|
+
fontSize="0.875rem"
|
|
104
|
+
p={4}
|
|
105
|
+
borderWidth="1px"
|
|
106
|
+
borderColor="gray.200"
|
|
107
|
+
borderRadius="md"
|
|
108
|
+
>
|
|
109
|
+
<Stack gap={3}>
|
|
110
|
+
<Text fontSize="xs" color="gray.500" fontFamily="mono">
|
|
111
|
+
Outer: 0.875rem (compact)
|
|
112
|
+
</Text>
|
|
113
|
+
<Button variant="outline">Outer Button</Button>
|
|
114
|
+
<ScaledContext
|
|
115
|
+
fontSize="1.25rem"
|
|
116
|
+
p={3}
|
|
117
|
+
borderWidth="1px"
|
|
118
|
+
borderColor="primary.light"
|
|
119
|
+
borderRadius="md"
|
|
120
|
+
>
|
|
121
|
+
<Stack gap={3}>
|
|
122
|
+
<Text fontSize="xs" color="gray.500" fontFamily="mono">
|
|
123
|
+
Inner: 1.25rem (spacious)
|
|
124
|
+
</Text>
|
|
125
|
+
<Button variant="outline">Inner Button</Button>
|
|
126
|
+
<Checkbox>
|
|
127
|
+
<Checkbox.Control />
|
|
128
|
+
<Checkbox.Label>Inner Checkbox</Checkbox.Label>
|
|
129
|
+
</Checkbox>
|
|
130
|
+
</Stack>
|
|
131
|
+
</ScaledContext>
|
|
132
|
+
</Stack>
|
|
133
|
+
</ScaledContext>
|
|
134
|
+
),
|
|
135
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Box, useChakraContext } from '@chakra-ui/react';
|
|
5
|
+
|
|
6
|
+
import { ScaledContextProps } from './ScaledContext.types';
|
|
7
|
+
|
|
8
|
+
const SCOPED_CATEGORIES = new Set(['spacing', 'sizes']);
|
|
9
|
+
const LENGTH_RE = /^(-?[\d.]+)(r?em)$/;
|
|
10
|
+
|
|
11
|
+
// NOTE: relies on system.tokens.cssVarMap and system.tokens.allTokens,
|
|
12
|
+
// which are internal Chakra v3 APIs. If Chakra renames these structures in a
|
|
13
|
+
// future release, getScopedVars will return {} and scaling will silently stop
|
|
14
|
+
// working. The null-check on `base` below guards the most likely failure mode.
|
|
15
|
+
function getScopedVars(
|
|
16
|
+
system: ReturnType<typeof useChakraContext>,
|
|
17
|
+
): React.CSSProperties {
|
|
18
|
+
const base = system.tokens.cssVarMap.get('base');
|
|
19
|
+
if (!base) return {};
|
|
20
|
+
|
|
21
|
+
const result: Record<string, string> = {};
|
|
22
|
+
|
|
23
|
+
for (const token of system.tokens.allTokens) {
|
|
24
|
+
const { category, negative, virtual, cssVar } = token.extensions;
|
|
25
|
+
if (negative || virtual || !cssVar) continue;
|
|
26
|
+
if (!SCOPED_CATEGORIES.has(category)) continue;
|
|
27
|
+
|
|
28
|
+
const value = base.get(cssVar.var) as string | undefined;
|
|
29
|
+
if (!value) continue;
|
|
30
|
+
|
|
31
|
+
const match = LENGTH_RE.exec(value);
|
|
32
|
+
if (!match) continue;
|
|
33
|
+
|
|
34
|
+
result[cssVar.var] = `${match[1]}em`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return result as React.CSSProperties;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const ScaledContext = forwardRef<HTMLDivElement, ScaledContextProps>(
|
|
41
|
+
({ style, children, ...rest }, ref) => {
|
|
42
|
+
const system = useChakraContext();
|
|
43
|
+
// system is the Chakra context object, which is stable across renders
|
|
44
|
+
// (same reference for the lifetime of the provider). useMemo is correct here.
|
|
45
|
+
const scopedVars = React.useMemo(() => getScopedVars(system), [system]);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Box ref={ref} style={{ ...scopedVars, ...style }} {...rest}>
|
|
49
|
+
{children}
|
|
50
|
+
</Box>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
ScaledContext.displayName = 'ScaledContext';
|
package/src/index.ts
CHANGED
|
@@ -55,6 +55,7 @@ export * from './components/MaxLengthIndicator';
|
|
|
55
55
|
export * from './components/MDXEditor';
|
|
56
56
|
export * from './components/Menu';
|
|
57
57
|
export * from './components/Modal';
|
|
58
|
+
export * from './components/Popover';
|
|
58
59
|
export * from './components/MonthPicker';
|
|
59
60
|
|
|
60
61
|
// Navigation Components
|
|
@@ -73,6 +74,7 @@ export * from './components/Radio';
|
|
|
73
74
|
export * from './components/SeeMoreButton';
|
|
74
75
|
export * from './components/SegmentedControl';
|
|
75
76
|
export * from './components/SegmentedProgressBar';
|
|
77
|
+
export * from './components/ScaledContext';
|
|
76
78
|
export * from './components/Select';
|
|
77
79
|
export * from './components/Slider';
|
|
78
80
|
export * from './components/Spinner';
|