@panneau/ui 5.0.0-alpha.8 → 5.0.0-alpha.9
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/README.md +17 -0
- package/dist/dialog/Dialog.css +5 -0
- package/dist/dialog/Dialog.d.ts.map +1 -1
- package/dist/dialog/Dialog.js +9 -4
- package/dist/dialog/Dialog.js.map +1 -1
- package/dist/dialog/Dialog.module.js +4 -2
- package/dist/dialog/Dialog.module.js.map +1 -1
- package/dist/popover/Popover.css +5 -0
- package/dist/popover/Popover.d.ts.map +1 -1
- package/dist/popover/Popover.js +9 -4
- package/dist/popover/Popover.js.map +1 -1
- package/dist/popover/Popover.module.js +4 -2
- package/dist/popover/Popover.module.js.map +1 -1
- package/dist/root/PanneauRoot.d.ts +19 -3
- package/dist/root/PanneauRoot.d.ts.map +1 -1
- package/dist/root/PanneauRoot.js +141 -112
- package/dist/root/PanneauRoot.js.map +1 -1
- package/dist/root/ThemeScope.d.ts.map +1 -1
- package/dist/root/ThemeScope.js +40 -38
- package/dist/root/ThemeScope.js.map +1 -1
- package/dist/utils/events.d.ts +4 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/events.js +9 -0
- package/dist/utils/events.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -288,6 +288,23 @@ Class names are stable and readable, without a hash, like Bootstrap's: target th
|
|
|
288
288
|
|
|
289
289
|
The theme model is described in [decision 0024](../../docs/decisions/0024-theme-model.md).
|
|
290
290
|
|
|
291
|
+
### Content Security Policy
|
|
292
|
+
|
|
293
|
+
Panneau runs under a strict Content Security Policy: it never needs `'unsafe-eval'` or inline scripts. For styles:
|
|
294
|
+
|
|
295
|
+
- **CSS Modules** are files of the packages, that the project's bundler serves as its other stylesheets (`style-src 'self'`).
|
|
296
|
+
- **Themes and fonts** are `<style>` elements (and a `<link>` for each font stylesheet) that `PanneauRoot` writes from the theme. With a policy without `'unsafe-inline'`, give them the page's nonce: `<PanneauRoot nonce={nonce}>`, or `nonce` of `<Panneau>` and `createPanneauApp()`. Without it, Panneau reads the nonce where React Aria does: `<meta property="csp-nonce" content="…">`, then `__webpack_nonce__`. The default theme writes no `<style>`.
|
|
297
|
+
- **React Aria** adds one `<style>` (`react-aria-pressable-style`) with the same nonce.
|
|
298
|
+
- **Inline `style` attributes** that components set (widths of progress bars, positions of popovers) go through the CSSOM, which `style-src` doesn't block.
|
|
299
|
+
|
|
300
|
+
```html
|
|
301
|
+
<meta property="csp-nonce" content="{{ $nonce }}" />
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
```text
|
|
305
|
+
Content-Security-Policy: default-src 'self'; style-src 'self' 'nonce-{{ $nonce }}'; img-src 'self' data: https:
|
|
306
|
+
```
|
|
307
|
+
|
|
291
308
|
## Primitives
|
|
292
309
|
|
|
293
310
|
`Heading`, `Text`, `Prose`, `Stack`, `Inline`, `Grid`, `Container`, `Divider`, `Button`, `IconButton`, `TextInput`, `TextArea`, `NumberInput`, `Slider`, `TagsInput`, `Select` (single or multiple), `ComboBox`, `Checkbox`, `Switch`, `RadioGroup`, `SegmentedControl`, `DatePicker`, `TimeInput`, `Fieldset`, `Dialog`, `Popover`, `Menu`, `PillTrigger`, `Tabs`, `Tooltip`, toasts (`useToast()`), `Alert`, `Badge`, `Spinner`, `Skeleton`, `LoadingRegion`, `Card`, `Disclosure` and `Icon`.
|
package/dist/dialog/Dialog.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../src/dialog/Dialog.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAKH,KAAK,iBAAiB,EACzB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../src/dialog/Dialog.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAA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AE,WAAW,sCAiEb;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/dialog/Dialog.js
CHANGED
|
@@ -3,6 +3,7 @@ import { messages } from "../intl/messages.js";
|
|
|
3
3
|
import { usePanneauIntl } from "../intl/usePanneauIntl.js";
|
|
4
4
|
import { usePortalContainer } from "../root/PanneauRoot.js";
|
|
5
5
|
import { IconButton } from "../icon-button/IconButton.js";
|
|
6
|
+
import { stopPropagation } from "../utils/events.js";
|
|
6
7
|
import Dialog_module_default from "./Dialog.module.js";
|
|
7
8
|
import { c } from "react/compiler-runtime";
|
|
8
9
|
import { X } from "lucide-react";
|
|
@@ -141,10 +142,14 @@ function Dialog$1(t0) {
|
|
|
141
142
|
} else t10 = $[31];
|
|
142
143
|
let t11;
|
|
143
144
|
if ($[32] !== role || $[33] !== t10 || $[34] !== t9) {
|
|
144
|
-
t11 = /* @__PURE__ */ jsx(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
children:
|
|
145
|
+
t11 = /* @__PURE__ */ jsx("div", {
|
|
146
|
+
className: Dialog_module_default.boundary,
|
|
147
|
+
onSubmit: stopPropagation,
|
|
148
|
+
children: /* @__PURE__ */ jsx(Dialog, {
|
|
149
|
+
role,
|
|
150
|
+
className: t9,
|
|
151
|
+
children: t10
|
|
152
|
+
})
|
|
148
153
|
});
|
|
149
154
|
$[32] = role;
|
|
150
155
|
$[33] = t10;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["X","ReactNode","Dialog","AriaDialog","Heading","Modal","ModalOverlay","ModalOverlayProps","IconButton","messages","usePanneauIntl","usePortalContainer","cx","styles","DialogProps","Pick","title","children","close","headerContent","footer","isDismissable","role","size","fullScreenOnPhone","className","overlayClassName","headerClassName","bodyClassName","footerClassName","t0","$","_c","props","t1","t2","t3","t4","undefined","intl","container","t5","overlay","t6","t7","t8","modal","t9","dialog","t10","t11","header","formatMessage","body","t12","t13","DialogTrigger","Dialog","_c","styles","_Fragment","AriaDialog"],"sources":["../../src/dialog/Dialog.tsx"],"sourcesContent":["import { X } from 'lucide-react';\nimport type { ReactNode } from 'react';\nimport {\n Dialog as AriaDialog,\n Heading,\n Modal,\n ModalOverlay,\n type ModalOverlayProps,\n} from 'react-aria-components';\n\nimport { IconButton } from '../icon-button/IconButton';\nimport { messages } from '../intl/messages';\nimport { usePanneauIntl } from '../intl/usePanneauIntl';\nimport { usePortalContainer } from '../root/PanneauRoot';\nimport { cx } from '../utils/cx';\nimport styles from './Dialog.module.css';\n\nexport interface DialogProps extends Pick<\n ModalOverlayProps,\n 'isOpen' | 'defaultOpen' | 'onOpenChange' | 'isKeyboardDismissDisabled'\n> {\n /** Heading of the dialog, which also labels it. */\n title: ReactNode;\n /** Content, or a function that gets `close()`. */\n children?: ReactNode | ((close: () => void) => ReactNode);\n /**\n * More content in the header, between the title and the close button: a switcher, a few\n * actions. On phones, it goes under the title. A function gets `close()`.\n */\n headerContent?: ReactNode | ((close: () => void) => ReactNode);\n /** Buttons at the bottom, or a function that gets `close()`. */\n footer?: ReactNode | ((close: () => void) => ReactNode);\n /**\n * Closes on a click outside and shows a close button. Defaults to true. Turn it off for dialogs\n * that need an answer.\n */\n isDismissable?: boolean;\n /** `alertdialog` for confirmations and interruptions. Defaults to `dialog`. */\n role?: 'dialog' | 'alertdialog';\n /** Maximum width: `sm`, `md` (the default), `lg`, or `xl` for pickers and editors. */\n size?: 'sm' | 'md' | 'lg' | 'xl';\n /**\n * On phones, takes the whole screen instead of opening as a sheet at the bottom: for dialogs\n * that need all the room they can get, such as pickers.\n */\n fullScreenOnPhone?: boolean;\n className?: string;\n overlayClassName?: string;\n headerClassName?: string;\n bodyClassName?: string;\n footerClassName?: string;\n}\n\n/**\n * A modal dialog. Controlled with `isOpen` and `onOpenChange`, or inside a `DialogTrigger` with\n * its button as the first child. It traps focus, closes with Escape, and returns focus when it\n * closes. On phones, it opens as a sheet at the bottom of the screen, or takes the whole screen with\n * `fullScreenOnPhone`.\n */\nexport function Dialog({\n title,\n children,\n headerContent,\n footer,\n isDismissable = true,\n role = 'dialog',\n size = 'md',\n fullScreenOnPhone = false,\n className,\n overlayClassName,\n headerClassName,\n bodyClassName,\n footerClassName,\n ...props\n}: DialogProps) {\n const intl = usePanneauIntl();\n const container = usePortalContainer();\n if (container === null) {\n return null;\n }\n return (\n <ModalOverlay\n {...props}\n isDismissable={isDismissable}\n className={cx(styles.overlay, overlayClassName)}\n UNSTABLE_portalContainer={container}\n >\n <Modal\n className={cx(\n styles.modal,\n styles[size],\n fullScreenOnPhone && styles.fullScreenOnPhone,\n )}\n >\n <AriaDialog role={role} className={cx('panneau-dialog', styles.dialog, className)}>\n {({ close }) => (\n <>\n <div className={cx(styles.header, headerClassName)}>\n <Heading slot=\"title\" className={styles.title}>\n {title}\n </Heading>\n {headerContent !== undefined && headerContent !== null ? (\n <div className={styles.headerContent}>\n {typeof headerContent === 'function'\n ? headerContent(close)\n : headerContent}\n </div>\n ) : null}\n {isDismissable ? (\n <IconButton\n icon={X}\n size=\"sm\"\n label={intl.formatMessage(messages.close)}\n showTooltip={false}\n onPress={close}\n />\n ) : null}\n </div>\n <div className={cx(styles.body, bodyClassName)}>\n {typeof children === 'function' ? children(close) : children}\n </div>\n {footer !== undefined && footer !== null ? (\n <div className={cx(styles.footer, footerClassName)}>\n {typeof footer === 'function' ? footer(close) : footer}\n </div>\n ) : null}\n </>\n )}\n </AriaDialog>\n </Modal>\n </ModalOverlay>\n );\n}\n\nexport { DialogTrigger } from 'react-aria-components';\n"],"mappings":";;;;;;;;;;;;;;;;;AA2DA,SAAOE,SAAA4B,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAJ;CAAA,IAAAX;CAAA,IAAAQ;CAAA,IAAAL;CAAA,IAAAS;CAAA,IAAAF;CAAA,IAAAR;CAAA,IAAAO;CAAA,IAAAO;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAr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U,IAAA;EAhDZc,MAAA,oBAAC,cAAD;GAAa,GACLtB;GACWZ;GACJ,WAAAoB;GACeD,0BAAAA;GAE1Bc,UAAAA;EANS,CAAA;EAiDEvB,EAAA,MAAAS;EAAAT,EAAA,MAAAV;EAAAU,EAAA,MAAAE;EAAAF,EAAA,MAAAuB;EAAAvB,EAAA,MAAAU;EAAAV,EAAA,MAAAwB;CAAA,OAAAA,MAAAxB,EAAA;CAAA,OAjDfwB;AAiDe"}
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["X","ReactNode","Dialog","AriaDialog","Heading","Modal","ModalOverlay","ModalOverlayProps","IconButton","messages","usePanneauIntl","usePortalContainer","cx","stopPropagation","styles","DialogProps","Pick","title","children","close","headerContent","footer","isDismissable","role","size","fullScreenOnPhone","className","overlayClassName","headerClassName","bodyClassName","footerClassName","t0","$","_c","props","t1","t2","t3","t4","undefined","intl","container","t5","overlay","t6","t7","t8","modal","t9","dialog","t10","t11","header","formatMessage","body","boundary","t12","t13","DialogTrigger","Dialog","_c","styles","_Fragment","AriaDialog"],"sources":["../../src/dialog/Dialog.tsx"],"sourcesContent":["import { X } from 'lucide-react';\nimport type { ReactNode } from 'react';\nimport {\n Dialog as AriaDialog,\n Heading,\n Modal,\n ModalOverlay,\n type ModalOverlayProps,\n} from 'react-aria-components';\n\nimport { IconButton } from '../icon-button/IconButton';\nimport { messages } from '../intl/messages';\nimport { usePanneauIntl } from '../intl/usePanneauIntl';\nimport { usePortalContainer } from '../root/PanneauRoot';\nimport { cx } from '../utils/cx';\nimport { stopPropagation } from '../utils/events';\nimport styles from './Dialog.module.css';\n\nexport interface DialogProps extends Pick<\n ModalOverlayProps,\n 'isOpen' | 'defaultOpen' | 'onOpenChange' | 'isKeyboardDismissDisabled'\n> {\n /** Heading of the dialog, which also labels it. */\n title: ReactNode;\n /** Content, or a function that gets `close()`. */\n children?: ReactNode | ((close: () => void) => ReactNode);\n /**\n * More content in the header, between the title and the close button: a switcher, a few\n * actions. On phones, it goes under the title. A function gets `close()`.\n */\n headerContent?: ReactNode | ((close: () => void) => ReactNode);\n /** Buttons at the bottom, or a function that gets `close()`. */\n footer?: ReactNode | ((close: () => void) => ReactNode);\n /**\n * Closes on a click outside and shows a close button. Defaults to true. Turn it off for dialogs\n * that need an answer.\n */\n isDismissable?: boolean;\n /** `alertdialog` for confirmations and interruptions. Defaults to `dialog`. */\n role?: 'dialog' | 'alertdialog';\n /** Maximum width: `sm`, `md` (the default), `lg`, or `xl` for pickers and editors. */\n size?: 'sm' | 'md' | 'lg' | 'xl';\n /**\n * On phones, takes the whole screen instead of opening as a sheet at the bottom: for dialogs\n * that need all the room they can get, such as pickers.\n */\n fullScreenOnPhone?: boolean;\n className?: string;\n overlayClassName?: string;\n headerClassName?: string;\n bodyClassName?: string;\n footerClassName?: string;\n}\n\n/**\n * A modal dialog. Controlled with `isOpen` and `onOpenChange`, or inside a `DialogTrigger` with\n * its button as the first child. It traps focus, closes with Escape, and returns focus when it\n * closes. On phones, it opens as a sheet at the bottom of the screen, or takes the whole screen with\n * `fullScreenOnPhone`.\n */\nexport function Dialog({\n title,\n children,\n headerContent,\n footer,\n isDismissable = true,\n role = 'dialog',\n size = 'md',\n fullScreenOnPhone = false,\n className,\n overlayClassName,\n headerClassName,\n bodyClassName,\n footerClassName,\n ...props\n}: DialogProps) {\n const intl = usePanneauIntl();\n const container = usePortalContainer();\n if (container === null) {\n return null;\n }\n return (\n <ModalOverlay\n {...props}\n isDismissable={isDismissable}\n className={cx(styles.overlay, overlayClassName)}\n UNSTABLE_portalContainer={container}\n >\n <Modal\n className={cx(\n styles.modal,\n styles[size],\n fullScreenOnPhone && styles.fullScreenOnPhone,\n )}\n >\n {/* React bubbles events through portals to the components around the dialog: a\n form in the dialog must not submit a form of the page (#146). */}\n <div className={styles.boundary} onSubmit={stopPropagation}>\n <AriaDialog\n role={role}\n className={cx('panneau-dialog', styles.dialog, className)}\n >\n {({ close }) => (\n <>\n <div className={cx(styles.header, headerClassName)}>\n <Heading slot=\"title\" className={styles.title}>\n {title}\n </Heading>\n {headerContent !== undefined && headerContent !== null ? (\n <div className={styles.headerContent}>\n {typeof headerContent === 'function'\n ? headerContent(close)\n : headerContent}\n </div>\n ) : null}\n {isDismissable ? (\n <IconButton\n icon={X}\n size=\"sm\"\n label={intl.formatMessage(messages.close)}\n showTooltip={false}\n onPress={close}\n />\n ) : null}\n </div>\n <div className={cx(styles.body, bodyClassName)}>\n {typeof children === 'function' ? children(close) : children}\n </div>\n {footer !== undefined && footer !== null ? (\n <div className={cx(styles.footer, footerClassName)}>\n {typeof footer === 'function' ? footer(close) : footer}\n </div>\n ) : null}\n </>\n )}\n </AriaDialog>\n </div>\n </Modal>\n </ModalOverlay>\n );\n}\n\nexport { DialogTrigger } from 'react-aria-components';\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4DA,SAAOE,SAAA6B,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAJ;CAAA,IAAAX;CAAA,IAAAQ;CAAA,IAAAL;CAAA,IAAAS;CAAA,IAAAF;CAAA,IAAAR;CAAA,IAAAO;CAAA,IAAAO;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAArB;CAAA,IAAAe,EAAA,OAAAD,IAAA;EAAgB,CAAA,CAAAd,OAAAC,UAAAE,eAAAC,QAAAC,eAAAa,IAAAZ,MAAAa,IAAAZ,MAAAa,IAAAZ,mBAAAa,IAAAZ,WAAAC,kBAAAC,iBAAAC,eAAAC,iBAAA,GAAAI,SAAAH;EAeTC,EAAA,KAAAD;EAAAC,EAAA,KAAAH;EAAAG,EAAA,KAAAd;EAAAc,EAAA,KAAAN;EAAAM,EAAA,KAAAX;EAAAW,EAAA,KAAAF;EAAAE,EAAA,KAAAJ;EAAAI,EAAA,KAAAZ;EAAAY,EAAA,KAAAL;EAAAK,EAAA,KAAAE;EAAAF,EAAA,MAAAG;EAAAH,EAAA,MAAAI;EAAAJ,EAAA,MAAAK;E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|
16
16
|
var fullScreenOnPhone = "panneau-dialog-full-screen-on-phone";
|
|
17
|
+
var boundary = "panneau-dialog-boundary";
|
|
17
18
|
var Dialog_module_default = {
|
|
18
19
|
overlay,
|
|
19
20
|
fade,
|
|
@@ -28,9 +29,10 @@ var Dialog_module_default = {
|
|
|
28
29
|
title,
|
|
29
30
|
body,
|
|
30
31
|
footer,
|
|
31
|
-
fullScreenOnPhone
|
|
32
|
+
fullScreenOnPhone,
|
|
33
|
+
boundary
|
|
32
34
|
};
|
|
33
35
|
//#endregion
|
|
34
|
-
export { body, Dialog_module_default as default, dialog, fade, footer, fullScreenOnPhone, header, headerContent, lg, modal, overlay, rise, sm, title, xl };
|
|
36
|
+
export { body, boundary, Dialog_module_default as default, dialog, fade, footer, fullScreenOnPhone, header, headerContent, lg, modal, overlay, rise, sm, title, xl };
|
|
35
37
|
|
|
36
38
|
//# sourceMappingURL=Dialog.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.module.js","names":[],"sources":["../../src/dialog/Dialog.module.css"],"sourcesContent":[".overlay {\n position: fixed;\n inset: 0;\n z-index: var(--panneau-z-overlay);\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100dvh;\n padding: var(--panneau-space-4);\n background-color: var(--panneau-dialog-backdrop, var(--panneau-color-backdrop));\n}\n\n.overlay[data-entering] {\n animation: fade var(--panneau-duration) ease-out;\n}\n\n.overlay[data-exiting] {\n animation: fade var(--panneau-duration) ease-in reverse;\n}\n\n.modal {\n display: flex;\n width: 100%;\n max-width: var(--panneau-dialog-width, 32rem);\n max-height: calc(100dvh - 2 * var(--panneau-space-4));\n outline: none;\n}\n\n.sm {\n max-width: var(--panneau-dialog-width-sm, 24rem);\n}\n\n.lg {\n max-width: var(--panneau-dialog-width-lg, 48rem);\n}\n\n.xl {\n max-width: var(--panneau-dialog-width-xl, 72rem);\n}\n\n.modal[data-entering] {\n animation: rise var(--panneau-duration) ease-out;\n}\n\n.dialog {\n display: flex;\n flex-direction: column;\n width: 100%;\n max-height: inherit;\n color: var(--panneau-color-text);\n background-color: var(--panneau-dialog-bg, var(--panneau-color-surface-raised));\n border-radius: var(--panneau-dialog-radius, var(--panneau-radius-lg));\n box-shadow: var(--panneau-dialog-shadow, var(--panneau-shadow-lg));\n outline: none;\n}\n\n.header {\n display: flex;\n align-items: flex-start;\n gap: var(--panneau-space-3);\n padding: var(--panneau-space-4) var(--panneau-space-4) 0\n var(--panneau-dialog-padding-x, var(--panneau-space-5));\n}\n\n.headerContent {\n display: flex;\n flex: 0 1 auto;\n align-items: center;\n gap: var(--panneau-space-2);\n min-width: 0;\n}\n\n.title {\n flex: 1 1 12rem;\n min-width: 0;\n padding-top: var(--panneau-space-1);\n font-size: var(--panneau-dialog-title-font-size, var(--panneau-font-size-lg));\n font-weight: var(--panneau-dialog-title-font-weight, var(--panneau-font-weight-bold));\n line-height: var(--panneau-line-height-tight);\n overflow-wrap: anywhere;\n margin: 0;\n}\n\n.body {\n flex: 1 1 auto;\n min-height: 0;\n padding: var(--panneau-space-3) var(--panneau-dialog-padding-x, var(--panneau-space-5))\n var(--panneau-space-4);\n overflow-y: auto;\n}\n\n.footer {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: var(--panneau-space-2);\n padding: var(--panneau-space-3) var(--panneau-dialog-padding-x, var(--panneau-space-5))\n var(--panneau-space-4);\n border-top: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n/* Phones: the dialog is a sheet at the bottom, with full-width buttons. */\n@media (max-width: 30rem) {\n .overlay {\n align-items: flex-end;\n padding: 0;\n }\n\n .modal,\n .sm,\n .lg,\n .xl {\n max-width: none;\n max-height: calc(100dvh - var(--panneau-space-8));\n }\n\n .dialog {\n border-end-start-radius: 0;\n border-end-end-radius: 0;\n padding-bottom: env(safe-area-inset-bottom);\n }\n\n /* The whole screen, under the notch. */\n .fullScreenOnPhone {\n height: 100dvh;\n max-height: 100dvh;\n }\n\n .fullScreenOnPhone .dialog {\n border-radius: 0;\n padding-top: env(safe-area-inset-top);\n }\n\n /* The header's content goes under the title and the close button. */\n .header {\n flex-wrap: wrap;\n }\n\n .headerContent {\n flex: 1 1 100%;\n order: 1;\n }\n\n .footer {\n flex-direction: column-reverse;\n }\n\n .footer > * {\n width: 100%;\n }\n}\n\n@keyframes fade {\n from {\n opacity: 0;\n }\n}\n\n@keyframes rise {\n from {\n opacity: 0;\n transform: translateY(0.5rem);\n }\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Dialog.module.js","names":[],"sources":["../../src/dialog/Dialog.module.css"],"sourcesContent":[".overlay {\n position: fixed;\n inset: 0;\n z-index: var(--panneau-z-overlay);\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100dvh;\n padding: var(--panneau-space-4);\n background-color: var(--panneau-dialog-backdrop, var(--panneau-color-backdrop));\n}\n\n.overlay[data-entering] {\n animation: fade var(--panneau-duration) ease-out;\n}\n\n.overlay[data-exiting] {\n animation: fade var(--panneau-duration) ease-in reverse;\n}\n\n.modal {\n display: flex;\n width: 100%;\n max-width: var(--panneau-dialog-width, 32rem);\n max-height: calc(100dvh - 2 * var(--panneau-space-4));\n outline: none;\n}\n\n.sm {\n max-width: var(--panneau-dialog-width-sm, 24rem);\n}\n\n.lg {\n max-width: var(--panneau-dialog-width-lg, 48rem);\n}\n\n.xl {\n max-width: var(--panneau-dialog-width-xl, 72rem);\n}\n\n.modal[data-entering] {\n animation: rise var(--panneau-duration) ease-out;\n}\n\n.dialog {\n display: flex;\n flex-direction: column;\n width: 100%;\n max-height: inherit;\n color: var(--panneau-color-text);\n background-color: var(--panneau-dialog-bg, var(--panneau-color-surface-raised));\n border-radius: var(--panneau-dialog-radius, var(--panneau-radius-lg));\n box-shadow: var(--panneau-dialog-shadow, var(--panneau-shadow-lg));\n outline: none;\n}\n\n.header {\n display: flex;\n align-items: flex-start;\n gap: var(--panneau-space-3);\n padding: var(--panneau-space-4) var(--panneau-space-4) 0\n var(--panneau-dialog-padding-x, var(--panneau-space-5));\n}\n\n.headerContent {\n display: flex;\n flex: 0 1 auto;\n align-items: center;\n gap: var(--panneau-space-2);\n min-width: 0;\n}\n\n.title {\n flex: 1 1 12rem;\n min-width: 0;\n padding-top: var(--panneau-space-1);\n font-size: var(--panneau-dialog-title-font-size, var(--panneau-font-size-lg));\n font-weight: var(--panneau-dialog-title-font-weight, var(--panneau-font-weight-bold));\n line-height: var(--panneau-line-height-tight);\n overflow-wrap: anywhere;\n margin: 0;\n}\n\n.body {\n flex: 1 1 auto;\n min-height: 0;\n padding: var(--panneau-space-3) var(--panneau-dialog-padding-x, var(--panneau-space-5))\n var(--panneau-space-4);\n overflow-y: auto;\n}\n\n.footer {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: var(--panneau-space-2);\n padding: var(--panneau-space-3) var(--panneau-dialog-padding-x, var(--panneau-space-5))\n var(--panneau-space-4);\n border-top: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n/* Phones: the dialog is a sheet at the bottom, with full-width buttons. */\n@media (max-width: 30rem) {\n .overlay {\n align-items: flex-end;\n padding: 0;\n }\n\n .modal,\n .sm,\n .lg,\n .xl {\n max-width: none;\n max-height: calc(100dvh - var(--panneau-space-8));\n }\n\n .dialog {\n border-end-start-radius: 0;\n border-end-end-radius: 0;\n padding-bottom: env(safe-area-inset-bottom);\n }\n\n /* The whole screen, under the notch. */\n .fullScreenOnPhone {\n height: 100dvh;\n max-height: 100dvh;\n }\n\n .fullScreenOnPhone .dialog {\n border-radius: 0;\n padding-top: env(safe-area-inset-top);\n }\n\n /* The header's content goes under the title and the close button. */\n .header {\n flex-wrap: wrap;\n }\n\n .headerContent {\n flex: 1 1 100%;\n order: 1;\n }\n\n .footer {\n flex-direction: column-reverse;\n }\n\n .footer > * {\n width: 100%;\n }\n}\n\n@keyframes fade {\n from {\n opacity: 0;\n }\n}\n\n@keyframes rise {\n from {\n opacity: 0;\n transform: translateY(0.5rem);\n }\n}\n\n/* Stops the events that React bubbles out of the overlay, without a box of its own. */\n.boundary {\n display: contents;\n}\n"],"mappings":""}
|
package/dist/popover/Popover.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../src/popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAEH,KAAK,YAAY,IAAI,gBAAgB,EAExC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../src/popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAEH,KAAK,YAAY,IAAI,gBAAgB,EAExC,MAAM,uBAAuB,CAAC;AAO/B,MAAM,WAAW,YAAa,SAAQ,IAAI,CACtC,gBAAgB,EAChB,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,0BAA0B,CAClE;IACG,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EACpB,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,eAAe,EACf,MAAU,EACV,GAAG,KAAK,EACX,EAAE,YAAY,sCAoBd;AAED,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,MAAU,EACV,GAAG,KAAK,EACX,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,GAAG,iBAAiB,CAAC,sCAetD;AAED,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/popover/Popover.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cx } from "../utils/cx.js";
|
|
2
2
|
import { usePortalContainer } from "../root/PanneauRoot.js";
|
|
3
|
+
import { stopPropagation } from "../utils/events.js";
|
|
3
4
|
import Popover_module_default from "./Popover.module.js";
|
|
4
5
|
import { c } from "react/compiler-runtime";
|
|
5
6
|
import { Dialog, DialogTrigger as PopoverTrigger, Popover } from "react-aria-components";
|
|
@@ -51,10 +52,14 @@ function Popover$1(t0) {
|
|
|
51
52
|
} else t3 = $[10];
|
|
52
53
|
let t4;
|
|
53
54
|
if ($[11] !== ariaLabel || $[12] !== children || $[13] !== t3) {
|
|
54
|
-
t4 = /* @__PURE__ */ jsx(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
children
|
|
55
|
+
t4 = /* @__PURE__ */ jsx("div", {
|
|
56
|
+
className: Popover_module_default.boundary,
|
|
57
|
+
onSubmit: stopPropagation,
|
|
58
|
+
children: /* @__PURE__ */ jsx(Dialog, {
|
|
59
|
+
"aria-label": ariaLabel,
|
|
60
|
+
className: t3,
|
|
61
|
+
children
|
|
62
|
+
})
|
|
58
63
|
});
|
|
59
64
|
$[11] = ariaLabel;
|
|
60
65
|
$[12] = children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","names":["ReactNode","Popover","AriaPopover","PopoverProps","AriaPopoverProps","Dialog","usePortalContainer","cx","styles","Omit","children","className","dialogClassName","t0","$","_c","ariaLabel","props","t1","offset","undefined","container","t2","popover","t3","dialog","t4","t5","PopoverSurface","DialogTrigger","PopoverTrigger","Popover","_c","styles","AriaPopover"],"sources":["../../src/popover/Popover.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport {\n Popover as AriaPopover,\n type PopoverProps as AriaPopoverProps,\n Dialog,\n} from 'react-aria-components';\n\nimport { usePortalContainer } from '../root/PanneauRoot';\nimport { cx } from '../utils/cx';\nimport styles from './Popover.module.css';\n\nexport interface PopoverProps extends Omit<\n AriaPopoverProps,\n 'className' | 'style' | 'children' | 'UNSTABLE_portalContainer'\n> {\n children?: ReactNode;\n /** Accessible label of the popover's dialog, when it has no heading. */\n 'aria-label'?: string;\n className?: string;\n dialogClassName?: string;\n}\n\n/**\n * A popover with free content, inside a `PopoverTrigger` with its button as the first child. Its\n * content is a non-modal dialog: focus moves into it and comes back to the button when it closes.\n */\nexport function Popover({\n children,\n 'aria-label': ariaLabel,\n className,\n dialogClassName,\n offset = 6,\n ...props\n}: PopoverProps) {\n const container = usePortalContainer();\n if (container === null) {\n return null;\n }\n return (\n <AriaPopover\n {...props}\n offset={offset}\n className={cx('panneau-popover', styles.popover, className)}\n UNSTABLE_portalContainer={container}\n >\n <Dialog aria-label={ariaLabel} className={cx(styles.dialog, dialogClassName)}>\n
|
|
1
|
+
{"version":3,"file":"Popover.js","names":["ReactNode","Popover","AriaPopover","PopoverProps","AriaPopoverProps","Dialog","usePortalContainer","cx","stopPropagation","styles","Omit","children","className","dialogClassName","t0","$","_c","ariaLabel","props","t1","offset","undefined","container","t2","popover","t3","dialog","t4","boundary","t5","PopoverSurface","DialogTrigger","PopoverTrigger","Popover","_c","styles","AriaPopover"],"sources":["../../src/popover/Popover.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport {\n Popover as AriaPopover,\n type PopoverProps as AriaPopoverProps,\n Dialog,\n} from 'react-aria-components';\n\nimport { usePortalContainer } from '../root/PanneauRoot';\nimport { cx } from '../utils/cx';\nimport { stopPropagation } from '../utils/events';\nimport styles from './Popover.module.css';\n\nexport interface PopoverProps extends Omit<\n AriaPopoverProps,\n 'className' | 'style' | 'children' | 'UNSTABLE_portalContainer'\n> {\n children?: ReactNode;\n /** Accessible label of the popover's dialog, when it has no heading. */\n 'aria-label'?: string;\n className?: string;\n dialogClassName?: string;\n}\n\n/**\n * A popover with free content, inside a `PopoverTrigger` with its button as the first child. Its\n * content is a non-modal dialog: focus moves into it and comes back to the button when it closes.\n */\nexport function Popover({\n children,\n 'aria-label': ariaLabel,\n className,\n dialogClassName,\n offset = 6,\n ...props\n}: PopoverProps) {\n const container = usePortalContainer();\n if (container === null) {\n return null;\n }\n return (\n <AriaPopover\n {...props}\n offset={offset}\n className={cx('panneau-popover', styles.popover, className)}\n UNSTABLE_portalContainer={container}\n >\n {/* Like a dialog: a form in the popover doesn't submit a form around it (#146). */}\n <div className={styles.boundary} onSubmit={stopPropagation}>\n <Dialog aria-label={ariaLabel} className={cx(styles.dialog, dialogClassName)}>\n {children}\n </Dialog>\n </div>\n </AriaPopover>\n );\n}\n\n/** The popover surface without a dialog, for listboxes and menus. */\nexport function PopoverSurface({\n children,\n className,\n offset = 6,\n ...props\n}: Omit<PopoverProps, 'aria-label' | 'dialogClassName'>) {\n const container = usePortalContainer();\n if (container === null) {\n return null;\n }\n return (\n <AriaPopover\n {...props}\n offset={offset}\n className={cx('panneau-popover', styles.popover, className)}\n UNSTABLE_portalContainer={container}\n >\n {children}\n </AriaPopover>\n );\n}\n\nexport { DialogTrigger as PopoverTrigger } from 'react-aria-components';\n"],"mappings":";;;;;;;;;;;;AA2BA,SAAOC,UAAAa,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAN;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAK;CAAA,IAAAC;CAAA,IAAAJ,EAAA,OAAAD,IAAA;EAAiB,CAAA,CAAAH,UAAA,cAAAM,WAAAL,WAAAC,iBAAAO,QAAAD,IAAA,GAAAD,SAAAJ;EAOTC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAF;EAAAE,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAA;EAAAF,YAAAF,EAAA;EAAAJ,WAAAI,EAAA;EAAAH,YAAAG,EAAA;EAAAF,kBAAAE,EAAA;EAAAG,QAAAH,EAAA;EAAAI,KAAAJ,EAAA;CAAA;CAFX,MAAAK,SAAAD,OAAAE,KAAAA,IAAA,IAAAF;CAGA,MAA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AAM;CAAA,IAAAC;CAAA,IAAAJ,EAAA,OAAAD,IAAA;EAAwB,CAAA,CAAAH,UAAAC,WAAAQ,QAAAD,IAAA,GAAAD,SAAAJ;EAKwBC,EAAA,KAAAD;EAAAC,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAA;EAAAR,WAAAI,EAAA;EAAAH,YAAAG,EAAA;EAAAG,QAAAH,EAAA;EAAAI,KAAAJ,EAAA;CAAA;CAFnD,MAAAK,SAAAD,OAAAE,KAAAA,IAAA,IAAAF;CAGA,MAAAG,YAAkBhB,mBAAmB;CACrC,IAAIgB,cAAc,MAAI,OACX;CACV,IAAAC;CAAA,IAAAR,EAAA,OAAAH,WAAA;EAKkBW,KAAAhB,GAAG,mBAAmBE,uBAAMe,SAAUZ,SAAS;EAACG,EAAA,KAAAH;EAAAG,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,IAAAU;CAAA,IAAAV,EAAA,OAAAJ,YAAAI,EAAA,OAAAO,aAAAP,EAAA,OAAAK,UAAAL,EAAA,QAAAG,SAAAH,EAAA,QAAAQ,IAAA;EAH/DE,KAAA,oBAACW,SAAD;GAAY,GACJlB;GACIE;GACG,WAAAG;GACeD,0BAAAA;GAEzBX;EANO,CAAA;EAOEI,EAAA,KAAAJ;EAAAI,EAAA,KAAAO;EAAAP,EAAA,KAAAK;EAAAL,EAAA,MAAAG;EAAAH,EAAA,MAAAQ;EAAAR,EAAA,MAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAPdU;AAOc"}
|
|
@@ -3,12 +3,14 @@ import "./Popover.css";
|
|
|
3
3
|
var popover = "panneau-popover";
|
|
4
4
|
var pop = "panneau-popover-pop";
|
|
5
5
|
var dialog = "panneau-popover-dialog";
|
|
6
|
+
var boundary = "panneau-popover-boundary";
|
|
6
7
|
var Popover_module_default = {
|
|
7
8
|
popover,
|
|
8
9
|
pop,
|
|
9
|
-
dialog
|
|
10
|
+
dialog,
|
|
11
|
+
boundary
|
|
10
12
|
};
|
|
11
13
|
//#endregion
|
|
12
|
-
export { Popover_module_default as default, dialog, pop, popover };
|
|
14
|
+
export { boundary, Popover_module_default as default, dialog, pop, popover };
|
|
13
15
|
|
|
14
16
|
//# sourceMappingURL=Popover.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.module.js","names":[],"sources":["../../src/popover/Popover.module.css"],"sourcesContent":[".popover {\n min-width: var(--trigger-width, 10rem);\n max-width: calc(100vw - 2 * var(--panneau-space-4));\n color: var(--panneau-color-text);\n background-color: var(--panneau-popover-bg, var(--panneau-color-surface-raised));\n border: var(--panneau-border-width) solid\n var(--panneau-popover-border-color, var(--panneau-color-border));\n border-radius: var(--panneau-popover-radius, var(--panneau-radius-lg));\n box-shadow: var(--panneau-popover-shadow, var(--panneau-shadow-lg));\n outline: none;\n overflow: auto;\n z-index: var(--panneau-z-overlay);\n}\n\n.popover[data-entering] {\n animation: pop var(--panneau-duration) ease-out;\n}\n\n.popover[data-exiting] {\n animation: pop var(--panneau-duration) ease-in reverse;\n}\n\n.dialog {\n padding: var(--panneau-popover-padding, var(--panneau-space-3));\n outline: none;\n}\n\n@keyframes pop {\n from {\n opacity: 0;\n transform: scale(0.97);\n }\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Popover.module.js","names":[],"sources":["../../src/popover/Popover.module.css"],"sourcesContent":[".popover {\n min-width: var(--trigger-width, 10rem);\n max-width: calc(100vw - 2 * var(--panneau-space-4));\n color: var(--panneau-color-text);\n background-color: var(--panneau-popover-bg, var(--panneau-color-surface-raised));\n border: var(--panneau-border-width) solid\n var(--panneau-popover-border-color, var(--panneau-color-border));\n border-radius: var(--panneau-popover-radius, var(--panneau-radius-lg));\n box-shadow: var(--panneau-popover-shadow, var(--panneau-shadow-lg));\n outline: none;\n overflow: auto;\n z-index: var(--panneau-z-overlay);\n}\n\n.popover[data-entering] {\n animation: pop var(--panneau-duration) ease-out;\n}\n\n.popover[data-exiting] {\n animation: pop var(--panneau-duration) ease-in reverse;\n}\n\n.dialog {\n padding: var(--panneau-popover-padding, var(--panneau-space-3));\n outline: none;\n}\n\n@keyframes pop {\n from {\n opacity: 0;\n transform: scale(0.97);\n }\n}\n\n/* Stops the events that React bubbles out of the overlay, without a box of its own. */\n.boundary {\n display: contents;\n}\n"],"mappings":""}
|
|
@@ -36,13 +36,29 @@ export interface PanneauRootProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
36
36
|
* to its own.
|
|
37
37
|
*/
|
|
38
38
|
messages?: Readonly<Record<string, string>> | null;
|
|
39
|
+
/**
|
|
40
|
+
* The nonce of the page's Content Security Policy, set on the `<style>` and `<link>` elements of
|
|
41
|
+
* themes and fonts, for a policy without `'unsafe-inline'` in `style-src`. Defaults to the
|
|
42
|
+
* nonce React Aria reads too: that of `<meta property="csp-nonce">`, or `__webpack_nonce__`.
|
|
43
|
+
*/
|
|
44
|
+
nonce?: string;
|
|
39
45
|
children?: ReactNode;
|
|
40
46
|
}
|
|
41
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The color scheme and density in effect, which a `ThemeScope` inherits when it doesn't set them,
|
|
49
|
+
* and the nonce of the styles of themes.
|
|
50
|
+
*/
|
|
42
51
|
export declare const ScopeContext: import("react").Context<{
|
|
43
52
|
colorScheme: ColorScheme;
|
|
44
53
|
density: Density;
|
|
54
|
+
nonce?: string | undefined;
|
|
45
55
|
}>;
|
|
56
|
+
/**
|
|
57
|
+
* The nonce of the page's Content Security Policy, where React Aria reads it: the `nonce` (or
|
|
58
|
+
* `content`) of `<meta property="csp-nonce">` or `<meta name="csp-nonce">`, or
|
|
59
|
+
* `__webpack_nonce__`. `undefined` without one, and on the server.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getPageNonce(): string | undefined;
|
|
46
62
|
/** Gives overlays a container: that of a root, or of a scope. */
|
|
47
63
|
export declare const PortalProvider: import("react").Provider<Element | null | undefined>;
|
|
48
64
|
/**
|
|
@@ -50,7 +66,7 @@ export declare const PortalProvider: import("react").Provider<Element | null | u
|
|
|
50
66
|
* fonts. React hoists them to the head and adds each once, however many roots or scopes use it.
|
|
51
67
|
* Returns the scope of the theme too, for `data-panneau-theme`.
|
|
52
68
|
*/
|
|
53
|
-
export declare function useThemeStyles(theme: Theme | null): {
|
|
69
|
+
export declare function useThemeStyles(theme: Theme | null, nonce?: string): {
|
|
54
70
|
scope?: string;
|
|
55
71
|
styles: ReactNode;
|
|
56
72
|
};
|
|
@@ -67,5 +83,5 @@ export declare function usePortalContainer(): Element | null | undefined;
|
|
|
67
83
|
* any token with its own class on the root. Without an `IntlProvider` above it, it provides one
|
|
68
84
|
* with Panneau's messages in its `locale`.
|
|
69
85
|
*/
|
|
70
|
-
export declare function PanneauRoot({ theme, colorScheme, density, iconLoader, locale, messages, className, children, ...props }: PanneauRootProps): import("react").JSX.Element;
|
|
86
|
+
export declare function PanneauRoot({ theme, colorScheme, density, iconLoader, locale, messages, nonce: givenNonce, className, children, ...props }: PanneauRootProps): import("react").JSX.Element;
|
|
71
87
|
//# sourceMappingURL=PanneauRoot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanneauRoot.d.ts","sourceRoot":"","sources":["../../src/root/PanneauRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAC;AAM1F,OAAO,EAAE,KAAK,eAAe,EAA0B,MAAM,oBAAoB,CAAC;AAElF,OAAO,EACH,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,KAAK,EAGb,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,gBAAiB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACpE;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1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AAW;aACf,OAAO;YACR,MAAM,GAAG,SAAS;EAI5B,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAYjD;AAED,iEAAiE;AACjE,eAAO,MAAM,cAAc,sDAAyB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,KAAK,CAAC,EAAE,MAAM,GACf;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CAkCvC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,GAAG,IAAI,GAAG,SAAS,CAE/D;AA6BD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,EACxB,KAAY,EACZ,WAAqB,EACrB,OAAgB,EAChB,UAAiB,EACjB,MAAM,EACN,QAAQ,EACR,KAAK,EAAE,UAAU,EACjB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,gBAAgB,+BA4ClB"}
|
package/dist/root/PanneauRoot.js
CHANGED
|
@@ -13,11 +13,25 @@ import { IntlContext, IntlProvider } from "react-intl";
|
|
|
13
13
|
//#region src/root/PanneauRoot.tsx
|
|
14
14
|
/** `undefined` outside of a root, `null` while the root's container isn't mounted yet. */
|
|
15
15
|
var PortalContext = createContext(void 0);
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* The color scheme and density in effect, which a `ThemeScope` inherits when it doesn't set them,
|
|
18
|
+
* and the nonce of the styles of themes.
|
|
19
|
+
*/
|
|
17
20
|
var ScopeContext = createContext({
|
|
18
21
|
colorScheme: "light",
|
|
19
22
|
density: "auto"
|
|
20
23
|
});
|
|
24
|
+
/**
|
|
25
|
+
* The nonce of the page's Content Security Policy, where React Aria reads it: the `nonce` (or
|
|
26
|
+
* `content`) of `<meta property="csp-nonce">` or `<meta name="csp-nonce">`, or
|
|
27
|
+
* `__webpack_nonce__`. `undefined` without one, and on the server.
|
|
28
|
+
*/
|
|
29
|
+
function getPageNonce() {
|
|
30
|
+
if (typeof document === "undefined") return;
|
|
31
|
+
const meta = document.querySelector("meta[property=\"csp-nonce\"], meta[name=\"csp-nonce\"]");
|
|
32
|
+
const nonce = meta?.nonce || meta?.content || globalThis.__webpack_nonce__;
|
|
33
|
+
return nonce !== void 0 && nonce !== "" ? nonce : void 0;
|
|
34
|
+
}
|
|
21
35
|
/** Gives overlays a container: that of a root, or of a scope. */
|
|
22
36
|
var PortalProvider = PortalContext.Provider;
|
|
23
37
|
/**
|
|
@@ -25,12 +39,12 @@ var PortalProvider = PortalContext.Provider;
|
|
|
25
39
|
* fonts. React hoists them to the head and adds each once, however many roots or scopes use it.
|
|
26
40
|
* Returns the scope of the theme too, for `data-panneau-theme`.
|
|
27
41
|
*/
|
|
28
|
-
function useThemeStyles(theme) {
|
|
29
|
-
const $ = c(
|
|
42
|
+
function useThemeStyles(theme, nonce) {
|
|
43
|
+
const $ = c(17);
|
|
30
44
|
let t0;
|
|
31
45
|
let t1;
|
|
32
46
|
let t2;
|
|
33
|
-
if ($[0] !== theme) {
|
|
47
|
+
if ($[0] !== nonce || $[1] !== theme) {
|
|
34
48
|
const css = theme !== null ? getThemeCss(theme, "§") : "";
|
|
35
49
|
const scope = css !== "" ? hashString(css) : void 0;
|
|
36
50
|
const fontCss = getFontFaceCss(theme?.fonts);
|
|
@@ -38,50 +52,65 @@ function useThemeStyles(theme) {
|
|
|
38
52
|
t0 = scope !== void 0 ? /* @__PURE__ */ jsx("style", {
|
|
39
53
|
href: `panneau-theme-${scope}`,
|
|
40
54
|
precedence: "panneau",
|
|
55
|
+
nonce,
|
|
41
56
|
children: css.replaceAll("§", scope)
|
|
42
57
|
}) : null;
|
|
43
58
|
t1 = fontCss !== "" ? /* @__PURE__ */ jsx("style", {
|
|
44
59
|
href: `panneau-fonts-${hashString(fontCss)}`,
|
|
45
60
|
precedence: "panneau",
|
|
61
|
+
nonce,
|
|
46
62
|
children: fontCss
|
|
47
63
|
}) : null;
|
|
48
|
-
$[0] =
|
|
49
|
-
$[1] =
|
|
50
|
-
$[2] =
|
|
51
|
-
$[3] =
|
|
64
|
+
$[0] = nonce;
|
|
65
|
+
$[1] = theme;
|
|
66
|
+
$[2] = t0;
|
|
67
|
+
$[3] = t1;
|
|
68
|
+
$[4] = t2;
|
|
52
69
|
} else {
|
|
53
|
-
t0 = $[
|
|
54
|
-
t1 = $[
|
|
55
|
-
t2 = $[
|
|
70
|
+
t0 = $[2];
|
|
71
|
+
t1 = $[3];
|
|
72
|
+
t2 = $[4];
|
|
56
73
|
}
|
|
57
74
|
let t3;
|
|
58
|
-
if ($[
|
|
59
|
-
|
|
60
|
-
$[
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
if ($[5] !== nonce || $[6] !== theme?.fonts) {
|
|
76
|
+
let t4;
|
|
77
|
+
if ($[8] !== nonce) {
|
|
78
|
+
t4 = (href) => /* @__PURE__ */ jsx("link", {
|
|
79
|
+
rel: "stylesheet",
|
|
80
|
+
href,
|
|
81
|
+
precedence: "panneau",
|
|
82
|
+
nonce
|
|
83
|
+
}, href);
|
|
84
|
+
$[8] = nonce;
|
|
85
|
+
$[9] = t4;
|
|
86
|
+
} else t4 = $[9];
|
|
87
|
+
t3 = getFontStylesheets(theme?.fonts).map(t4);
|
|
88
|
+
$[5] = nonce;
|
|
89
|
+
$[6] = theme?.fonts;
|
|
90
|
+
$[7] = t3;
|
|
91
|
+
} else t3 = $[7];
|
|
63
92
|
let t4;
|
|
64
|
-
if ($[
|
|
93
|
+
if ($[10] !== t0 || $[11] !== t1 || $[12] !== t3) {
|
|
65
94
|
t4 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
66
95
|
t0,
|
|
67
96
|
t1,
|
|
68
97
|
t3
|
|
69
98
|
] });
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
} else t4 = $[
|
|
99
|
+
$[10] = t0;
|
|
100
|
+
$[11] = t1;
|
|
101
|
+
$[12] = t3;
|
|
102
|
+
$[13] = t4;
|
|
103
|
+
} else t4 = $[13];
|
|
75
104
|
let t5;
|
|
76
|
-
if ($[
|
|
105
|
+
if ($[14] !== t2 || $[15] !== t4) {
|
|
77
106
|
t5 = {
|
|
78
107
|
scope: t2,
|
|
79
108
|
styles: t4
|
|
80
109
|
};
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
$[
|
|
84
|
-
} else t5 = $[
|
|
110
|
+
$[14] = t2;
|
|
111
|
+
$[15] = t4;
|
|
112
|
+
$[16] = t5;
|
|
113
|
+
} else t5 = $[16];
|
|
85
114
|
return t5;
|
|
86
115
|
}
|
|
87
116
|
/**
|
|
@@ -89,13 +118,6 @@ function useThemeStyles(theme) {
|
|
|
89
118
|
* without a root. It is `null` during the first render of a root: overlays wait for it, since
|
|
90
119
|
* React Aria hides everything outside of a modal from assistive technologies when it opens.
|
|
91
120
|
*/
|
|
92
|
-
function _temp(href) {
|
|
93
|
-
return /* @__PURE__ */ jsx("link", {
|
|
94
|
-
rel: "stylesheet",
|
|
95
|
-
href,
|
|
96
|
-
precedence: "panneau"
|
|
97
|
-
}, href);
|
|
98
|
-
}
|
|
99
121
|
function usePortalContainer() {
|
|
100
122
|
return use(PortalContext);
|
|
101
123
|
}
|
|
@@ -163,9 +185,10 @@ function PanneauIntlProvider(t0) {
|
|
|
163
185
|
* with Panneau's messages in its `locale`.
|
|
164
186
|
*/
|
|
165
187
|
function PanneauRoot(t0) {
|
|
166
|
-
const $ = c(
|
|
188
|
+
const $ = c(49);
|
|
167
189
|
let children;
|
|
168
190
|
let className;
|
|
191
|
+
let givenNonce;
|
|
169
192
|
let locale;
|
|
170
193
|
let messages;
|
|
171
194
|
let props;
|
|
@@ -174,125 +197,131 @@ function PanneauRoot(t0) {
|
|
|
174
197
|
let t3;
|
|
175
198
|
let t4;
|
|
176
199
|
if ($[0] !== t0) {
|
|
177
|
-
({theme: t1, colorScheme: t2, density: t3, iconLoader: t4, locale, messages, className, children, ...props} = t0);
|
|
200
|
+
({theme: t1, colorScheme: t2, density: t3, iconLoader: t4, locale, messages, nonce: givenNonce, className, children, ...props} = t0);
|
|
178
201
|
$[0] = t0;
|
|
179
202
|
$[1] = children;
|
|
180
203
|
$[2] = className;
|
|
181
|
-
$[3] =
|
|
182
|
-
$[4] =
|
|
183
|
-
$[5] =
|
|
184
|
-
$[6] =
|
|
185
|
-
$[7] =
|
|
186
|
-
$[8] =
|
|
187
|
-
$[9] =
|
|
204
|
+
$[3] = givenNonce;
|
|
205
|
+
$[4] = locale;
|
|
206
|
+
$[5] = messages;
|
|
207
|
+
$[6] = props;
|
|
208
|
+
$[7] = t1;
|
|
209
|
+
$[8] = t2;
|
|
210
|
+
$[9] = t3;
|
|
211
|
+
$[10] = t4;
|
|
188
212
|
} else {
|
|
189
213
|
children = $[1];
|
|
190
214
|
className = $[2];
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
215
|
+
givenNonce = $[3];
|
|
216
|
+
locale = $[4];
|
|
217
|
+
messages = $[5];
|
|
218
|
+
props = $[6];
|
|
219
|
+
t1 = $[7];
|
|
220
|
+
t2 = $[8];
|
|
221
|
+
t3 = $[9];
|
|
222
|
+
t4 = $[10];
|
|
198
223
|
}
|
|
199
224
|
const theme = t1 === void 0 ? null : t1;
|
|
200
225
|
const colorScheme = t2 === void 0 ? "light" : t2;
|
|
201
226
|
const density = t3 === void 0 ? "auto" : t3;
|
|
202
227
|
const iconLoader = t4 === void 0 ? null : t4;
|
|
228
|
+
const [pageNonce] = useState(getPageNonce);
|
|
229
|
+
const nonce = givenNonce ?? pageNonce;
|
|
203
230
|
const intl = use(IntlContext);
|
|
204
231
|
const [container, setContainer] = useState(null);
|
|
205
|
-
const { scope, styles: themeStyles } = useThemeStyles(theme);
|
|
232
|
+
const { scope, styles: themeStyles } = useThemeStyles(theme, nonce);
|
|
206
233
|
let t5;
|
|
207
|
-
if ($[
|
|
234
|
+
if ($[11] !== className) {
|
|
208
235
|
t5 = cx("panneau-root", PanneauRoot_module_default.root, PanneauRoot_module_default.container, className);
|
|
209
|
-
$[
|
|
210
|
-
$[
|
|
211
|
-
} else t5 = $[
|
|
236
|
+
$[11] = className;
|
|
237
|
+
$[12] = t5;
|
|
238
|
+
} else t5 = $[12];
|
|
212
239
|
const t6 = locale ?? intl?.locale;
|
|
213
240
|
let t7;
|
|
214
|
-
if ($[
|
|
241
|
+
if ($[13] !== colorScheme || $[14] !== density || $[15] !== nonce) {
|
|
215
242
|
t7 = {
|
|
216
243
|
colorScheme,
|
|
217
|
-
density
|
|
244
|
+
density,
|
|
245
|
+
nonce
|
|
218
246
|
};
|
|
219
|
-
$[
|
|
220
|
-
$[
|
|
221
|
-
$[
|
|
222
|
-
|
|
247
|
+
$[13] = colorScheme;
|
|
248
|
+
$[14] = density;
|
|
249
|
+
$[15] = nonce;
|
|
250
|
+
$[16] = t7;
|
|
251
|
+
} else t7 = $[16];
|
|
223
252
|
let t8;
|
|
224
|
-
if ($[
|
|
253
|
+
if ($[17] !== colorScheme || $[18] !== density || $[19] !== scope) {
|
|
225
254
|
t8 = {
|
|
226
255
|
"data-color-scheme": colorScheme,
|
|
227
256
|
"data-density": density,
|
|
228
257
|
"data-panneau-theme": scope
|
|
229
258
|
};
|
|
230
|
-
$[
|
|
231
|
-
$[
|
|
232
|
-
$[
|
|
233
|
-
$[
|
|
234
|
-
} else t8 = $[
|
|
259
|
+
$[17] = colorScheme;
|
|
260
|
+
$[18] = density;
|
|
261
|
+
$[19] = scope;
|
|
262
|
+
$[20] = t8;
|
|
263
|
+
} else t8 = $[20];
|
|
235
264
|
let t9;
|
|
236
|
-
if ($[
|
|
265
|
+
if ($[21] !== children || $[22] !== t8) {
|
|
237
266
|
t9 = /* @__PURE__ */ jsx(ToastProvider, {
|
|
238
267
|
regionClassName: PanneauRoot_module_default.root,
|
|
239
268
|
regionProps: t8,
|
|
240
269
|
children
|
|
241
270
|
});
|
|
242
|
-
$[
|
|
243
|
-
$[
|
|
244
|
-
$[
|
|
245
|
-
} else t9 = $[
|
|
271
|
+
$[21] = children;
|
|
272
|
+
$[22] = t8;
|
|
273
|
+
$[23] = t9;
|
|
274
|
+
} else t9 = $[23];
|
|
246
275
|
let t10;
|
|
247
|
-
if ($[
|
|
276
|
+
if ($[24] !== container || $[25] !== t9) {
|
|
248
277
|
t10 = /* @__PURE__ */ jsx(PortalContext, {
|
|
249
278
|
value: container,
|
|
250
279
|
children: t9
|
|
251
280
|
});
|
|
252
|
-
$[
|
|
253
|
-
$[
|
|
254
|
-
$[
|
|
255
|
-
} else t10 = $[
|
|
281
|
+
$[24] = container;
|
|
282
|
+
$[25] = t9;
|
|
283
|
+
$[26] = t10;
|
|
284
|
+
} else t10 = $[26];
|
|
256
285
|
let t11;
|
|
257
|
-
if ($[
|
|
286
|
+
if ($[27] !== t10 || $[28] !== t7) {
|
|
258
287
|
t11 = /* @__PURE__ */ jsx(ScopeContext, {
|
|
259
288
|
value: t7,
|
|
260
289
|
children: t10
|
|
261
290
|
});
|
|
262
|
-
$[
|
|
263
|
-
$[
|
|
264
|
-
$[
|
|
265
|
-
} else t11 = $[
|
|
291
|
+
$[27] = t10;
|
|
292
|
+
$[28] = t7;
|
|
293
|
+
$[29] = t11;
|
|
294
|
+
} else t11 = $[29];
|
|
266
295
|
let t12;
|
|
267
|
-
if ($[
|
|
296
|
+
if ($[30] !== iconLoader || $[31] !== t11) {
|
|
268
297
|
t12 = /* @__PURE__ */ jsx(NamedIconLoaderContext, {
|
|
269
298
|
value: iconLoader,
|
|
270
299
|
children: t11
|
|
271
300
|
});
|
|
272
|
-
$[
|
|
273
|
-
$[
|
|
274
|
-
$[
|
|
275
|
-
} else t12 = $[
|
|
301
|
+
$[30] = iconLoader;
|
|
302
|
+
$[31] = t11;
|
|
303
|
+
$[32] = t12;
|
|
304
|
+
} else t12 = $[32];
|
|
276
305
|
let t13;
|
|
277
|
-
if ($[
|
|
306
|
+
if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
|
|
278
307
|
t13 = /* @__PURE__ */ jsx("div", {
|
|
279
308
|
ref: setContainer,
|
|
280
309
|
className: PanneauRoot_module_default.portal
|
|
281
310
|
});
|
|
282
|
-
$[
|
|
283
|
-
} else t13 = $[
|
|
311
|
+
$[33] = t13;
|
|
312
|
+
} else t13 = $[33];
|
|
284
313
|
let t14;
|
|
285
|
-
if ($[
|
|
314
|
+
if ($[34] !== t12 || $[35] !== t6) {
|
|
286
315
|
t14 = /* @__PURE__ */ jsxs(I18nProvider, {
|
|
287
316
|
locale: t6,
|
|
288
317
|
children: [t12, t13]
|
|
289
318
|
});
|
|
290
|
-
$[
|
|
291
|
-
$[
|
|
292
|
-
$[
|
|
293
|
-
} else t14 = $[
|
|
319
|
+
$[34] = t12;
|
|
320
|
+
$[35] = t6;
|
|
321
|
+
$[36] = t14;
|
|
322
|
+
} else t14 = $[36];
|
|
294
323
|
let t15;
|
|
295
|
-
if ($[
|
|
324
|
+
if ($[37] !== colorScheme || $[38] !== density || $[39] !== props || $[40] !== scope || $[41] !== t14 || $[42] !== t5 || $[43] !== themeStyles) {
|
|
296
325
|
t15 = /* @__PURE__ */ jsxs("div", {
|
|
297
326
|
...props,
|
|
298
327
|
className: t5,
|
|
@@ -301,34 +330,34 @@ function PanneauRoot(t0) {
|
|
|
301
330
|
"data-panneau-theme": scope,
|
|
302
331
|
children: [themeStyles, t14]
|
|
303
332
|
});
|
|
304
|
-
$[
|
|
305
|
-
$[
|
|
306
|
-
$[
|
|
307
|
-
$[
|
|
308
|
-
$[
|
|
309
|
-
$[
|
|
310
|
-
$[
|
|
311
|
-
$[
|
|
312
|
-
} else t15 = $[
|
|
333
|
+
$[37] = colorScheme;
|
|
334
|
+
$[38] = density;
|
|
335
|
+
$[39] = props;
|
|
336
|
+
$[40] = scope;
|
|
337
|
+
$[41] = t14;
|
|
338
|
+
$[42] = t5;
|
|
339
|
+
$[43] = themeStyles;
|
|
340
|
+
$[44] = t15;
|
|
341
|
+
} else t15 = $[44];
|
|
313
342
|
const root = t15;
|
|
314
343
|
if (intl === null || intl === void 0) {
|
|
315
344
|
let t16;
|
|
316
|
-
if ($[
|
|
345
|
+
if ($[45] !== locale || $[46] !== messages || $[47] !== root) {
|
|
317
346
|
t16 = /* @__PURE__ */ jsx(PanneauIntlProvider, {
|
|
318
347
|
locale,
|
|
319
348
|
messages,
|
|
320
349
|
children: root
|
|
321
350
|
});
|
|
322
|
-
$[
|
|
323
|
-
$[
|
|
324
|
-
$[
|
|
325
|
-
$[
|
|
326
|
-
} else t16 = $[
|
|
351
|
+
$[45] = locale;
|
|
352
|
+
$[46] = messages;
|
|
353
|
+
$[47] = root;
|
|
354
|
+
$[48] = t16;
|
|
355
|
+
} else t16 = $[48];
|
|
327
356
|
return t16;
|
|
328
357
|
}
|
|
329
358
|
return root;
|
|
330
359
|
}
|
|
331
360
|
//#endregion
|
|
332
|
-
export { PanneauRoot, PortalProvider, ScopeContext, usePortalContainer, useThemeStyles };
|
|
361
|
+
export { PanneauRoot, PortalProvider, ScopeContext, getPageNonce, usePortalContainer, useThemeStyles };
|
|
333
362
|
|
|
334
363
|
//# sourceMappingURL=PanneauRoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanneauRoot.js","names":["HTMLAttributes","ReactNode","createContext","use","useState","I18nProvider","IntlContext","IntlProvider","IntlShape","getPanneauMessages","NamedIconLoader","NamedIconLoaderContext","getFontFaceCss","getFontStylesheets","ColorScheme","Density","Theme","getThemeCss","hashString","ToastProvider","cx","styles","PanneauRootProps","HTMLDivElement","theme","colorScheme","density","iconLoader","locale","messages","Readonly","Record","children","PortalContext","Element","undefined","ScopeContext","PortalProvider","Provider","useThemeStyles","$","_c","t0","t1","t2","css","scope","fontCss","fonts","replaceAll","t3","map","_temp","t4","t5","href","usePortalContainer","PanneauIntlProvider","added","Object","keys","translated","length","t6","t7","PanneauRoot","className","props","intl","container","setContainer","themeStyles","root","t8","t9","t10","t11","t12","t13","Symbol","for","portal","t14","t15","t16","_c","_Fragment","styles"],"sources":["../../src/root/PanneauRoot.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, createContext, use, useState } from 'react';\nimport { I18nProvider } from 'react-aria-components';\nimport { IntlContext, IntlProvider, type IntlShape } from 'react-intl';\n\nimport { getPanneauMessages } from '@panneau/intl';\n\nimport { type NamedIconLoader, NamedIconLoaderContext } from '../icon/namedIcons';\nimport { getFontFaceCss, getFontStylesheets } from '../theme/fonts';\nimport {\n type ColorScheme,\n type Density,\n type Theme,\n getThemeCss,\n hashString,\n} from '../theme/theme';\nimport { ToastProvider } from '../toast/Toast';\nimport { cx } from '../utils/cx';\nimport styles from './PanneauRoot.module.css';\n\nexport interface PanneauRootProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Tokens, tones, variants and fonts that override the default theme: `bootstrapTheme`, or a\n * project's own (`defineTheme()`).\n */\n theme?: Theme | null;\n /** Defaults to `light`. `auto` follows the system setting. */\n colorScheme?: ColorScheme;\n /**\n * How much room controls and rows take: `compact`, `comfortable` or `touch`. Defaults to\n * `auto`: `touch` on touch screens, `comfortable` otherwise.\n */\n density?: Density;\n /**\n * Loads the icons that definitions name (`\"icon\": \"send\"`), for `getNamedIcon()`: pass\n * `lucideIconLoader` from `@panneau/ui/named-icons`, or a loader of only the icons the app\n * uses. Without it, named icons render an empty space.\n */\n iconLoader?: NamedIconLoader | null;\n /**\n * Locale of dates and numbers in React Aria components. Defaults to the react-intl locale, or\n * to the browser's without an `IntlProvider`.\n *\n * Without an `IntlProvider` above it, the root provides one, with the messages of every Panneau\n * package in this locale (English without a locale, or for a locale Panneau doesn't translate).\n * An app with its own `IntlProvider` adds them with `withPanneauMessages()` from\n * `@panneau/intl`.\n */\n locale?: string;\n /**\n * Messages added to Panneau's, by id, when the root provides the `IntlProvider`: those of\n * plugins (`loadMessages()` of `@panneau/core`). An app with its own `IntlProvider` adds them\n * to its own.\n */\n messages?: Readonly<Record<string, string>> | null;\n children?: ReactNode;\n}\n\n/** `undefined` outside of a root, `null` while the root's container isn't mounted yet. */\nconst PortalContext = createContext<Element | null | undefined>(undefined);\n\n/** The color scheme and density in effect, which a `ThemeScope` inherits when it doesn't set them. */\nexport const ScopeContext = createContext<{ colorScheme: ColorScheme; density: Density }>({\n colorScheme: 'light',\n density: 'auto',\n});\n\n/** Gives overlays a container: that of a root, or of a scope. */\nexport const PortalProvider = PortalContext.Provider;\n\n/**\n * The `<style>` and `<link>` elements of a theme: its CSS, scoped to `data-panneau-theme`, and its\n * fonts. React hoists them to the head and adds each once, however many roots or scopes use it.\n * Returns the scope of the theme too, for `data-panneau-theme`.\n */\nexport function useThemeStyles(theme: Theme | null): { scope?: string; styles: ReactNode } {\n const css = theme !== null ? getThemeCss(theme, '§') : '';\n const scope = css !== '' ? hashString(css) : undefined;\n const fontCss = getFontFaceCss(theme?.fonts);\n return {\n scope,\n styles: (\n <>\n {scope !== undefined ? (\n <style href={`panneau-theme-${scope}`} precedence=\"panneau\">\n {css.replaceAll('§', scope)}\n </style>\n ) : null}\n {fontCss !== '' ? (\n <style href={`panneau-fonts-${hashString(fontCss)}`} precedence=\"panneau\">\n {fontCss}\n </style>\n ) : null}\n {getFontStylesheets(theme?.fonts).map((href) => (\n <link key={href} rel=\"stylesheet\" href={href} precedence=\"panneau\" />\n ))}\n </>\n ),\n };\n}\n\n/**\n * The element overlays render into: the closest `PanneauRoot`'s or `ThemeScope`'s, or `undefined` for the body\n * without a root. It is `null` during the first render of a root: overlays wait for it, since\n * React Aria hides everything outside of a modal from assistive technologies when it opens.\n */\nexport function usePortalContainer(): Element | null | undefined {\n return use(PortalContext);\n}\n\n/**\n * An `IntlProvider` with Panneau's messages in a locale, for a root without one above it. A locale\n * Panneau doesn't translate gets English, so that react-intl doesn't report every message as\n * missing.\n */\nfunction PanneauIntlProvider({\n locale = 'en',\n messages: added,\n children,\n}: {\n locale?: string;\n messages?: Readonly<Record<string, string>> | null;\n children: ReactNode;\n}) {\n const messages = getPanneauMessages(locale);\n const translated = Object.keys(messages).length > 0;\n return (\n <IntlProvider\n locale={translated ? locale : 'en'}\n defaultLocale=\"en\"\n messages={{ ...(translated ? messages : getPanneauMessages('en')), ...added }}\n >\n {children}\n </IntlProvider>\n );\n}\n\n/**\n * The root of every Panneau interface. It scopes the base stylesheet and the design tokens to its\n * element (no global CSS), applies a theme and a color scheme, and hosts overlays and toasts so\n * that they get the tokens too. Panneau components must render inside one. A project can override\n * any token with its own class on the root. Without an `IntlProvider` above it, it provides one\n * with Panneau's messages in its `locale`.\n */\nexport function PanneauRoot({\n theme = null,\n colorScheme = 'light',\n density = 'auto',\n iconLoader = null,\n locale,\n messages,\n className,\n children,\n ...props\n}: PanneauRootProps) {\n const intl = use(IntlContext) as IntlShape | null | undefined;\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const { scope, styles: themeStyles } = useThemeStyles(theme);\n const root = (\n <div\n {...props}\n className={cx('panneau-root', styles.root, styles.container, className)}\n data-color-scheme={colorScheme}\n data-density={density}\n data-panneau-theme={scope}\n >\n {themeStyles}\n <I18nProvider locale={locale ?? intl?.locale}>\n <NamedIconLoaderContext value={iconLoader}>\n <ScopeContext value={{ colorScheme, density }}>\n <PortalContext value={container}>\n <ToastProvider\n regionClassName={styles.root}\n regionProps={{\n 'data-color-scheme': colorScheme,\n 'data-density': density,\n 'data-panneau-theme': scope,\n }}\n >\n {children}\n </ToastProvider>\n </PortalContext>\n </ScopeContext>\n </NamedIconLoaderContext>\n <div ref={setContainer} className={styles.portal} />\n </I18nProvider>\n </div>\n );\n if (intl === null || intl === undefined) {\n return (\n <PanneauIntlProvider locale={locale} messages={messages}>\n {root}\n </PanneauIntlProvider>\n );\n }\n return root;\n}\n"],"mappings":";;;;;;;;;;;;;;AA0DA,IAAMiC,gBAAgB/B,cAA0CiC,KAAAA,CAAS;;AAGzE,IAAaC,eAAelC,cAA8D;CACtFuB,aAAa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ArC,EAAA,MAAAuB;EAAAvB,EAAA,MAAA0C;CAAA,OAAAA,MAAA1C,EAAA;CAAA,IAAA2C;CAAA,IAAA3C,EAAA,QAAAf,eAAAe,EAAA,QAAAd,WAAAc,EAAA,QAAA2B,SAAA3B,EAAA,QAAAM,SAAAN,EAAA,QAAA0C,OAAA1C,EAAA,QAAAc,MAAAd,EAAA,QAAA+B,aAAA;EA1BnBY,MAAA,qBAAA,OAAA;GA2BM,GA1BEhB;GACO,WAAAb;GACQ7B,qBAAAA;GACLC,gBAAAA;GACMoB,sBAAAA;GALxB,UAAA,CAOKyB,aACDW,GAmBE;;EAAA1C,EAAA,MAAAf;EAAAe,EAAA,MAAAd;EAAAc,EAAA,MAAA2B;EAAA3B,EAAA,MAAAM;EAAAN,EAAA,MAAA0C;EAAA1C,EAAA,MAAAc;EAAAd,EAAA,MAAA+B;EAAA/B,EAAA,MAAA2C;CAAA,OAAAA,MAAA3C,EAAA;CA5BV,MAAAgC,OACIW;CA6BJ,IAAIf,SAAS,QAAQA,SAASjC,KAAAA,GAAS;EAAA,IAAAiD;EAAA,IAAA5C,EAAA,QAAAZ,UAAAY,EAAA,QAAAX,YAAAW,EAAA,QAAAgC,MAAA;GAE/BY,MAAA,oBAAC,qBAAD;IAA6BxD;IAAkBC;IAC1C2C,UAAAA;GADe,CAAA;GAEEhC,EAAA,MAAAZ;GAAAY,EAAA,MAAAX;GAAAW,EAAA,MAAAgC;GAAAhC,EAAA,MAAA4C;EAAA,OAAAA,MAAA5C,EAAA;EAAA,OAFtB4C;CAEsB;CAE7B,OACMZ;AAAI"}
|
|
1
|
+
{"version":3,"file":"PanneauRoot.js","names":["HTMLAttributes","ReactNode","createContext","use","useState","I18nProvider","IntlContext","IntlProvider","IntlShape","getPanneauMessages","NamedIconLoader","NamedIconLoaderContext","getFontFaceCss","getFontStylesheets","ColorScheme","Density","Theme","getThemeCss","hashString","ToastProvider","cx","styles","PanneauRootProps","HTMLDivElement","theme","colorScheme","density","iconLoader","locale","messages","Readonly","Record","nonce","children","PortalContext","Element","undefined","ScopeContext","getPageNonce","document","meta","querySelector","HTMLMetaElement","content","globalThis","__webpack_nonce__","PortalProvider","Provider","useThemeStyles","$","_c","t0","t1","t2","css","scope","fontCss","fonts","replaceAll","t3","t4","href","map","t5","usePortalContainer","PanneauIntlProvider","added","Object","keys","translated","length","t6","t7","PanneauRoot","className","givenNonce","props","pageNonce","intl","container","setContainer","themeStyles","root","t8","t9","t10","t11","t12","t13","Symbol","for","portal","t14","t15","t16","_c","_Fragment","styles"],"sources":["../../src/root/PanneauRoot.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, createContext, use, useState } from 'react';\nimport { I18nProvider } from 'react-aria-components';\nimport { IntlContext, IntlProvider, type IntlShape } from 'react-intl';\n\nimport { getPanneauMessages } from '@panneau/intl';\n\nimport { type NamedIconLoader, NamedIconLoaderContext } from '../icon/namedIcons';\nimport { getFontFaceCss, getFontStylesheets } from '../theme/fonts';\nimport {\n type ColorScheme,\n type Density,\n type Theme,\n getThemeCss,\n hashString,\n} from '../theme/theme';\nimport { ToastProvider } from '../toast/Toast';\nimport { cx } from '../utils/cx';\nimport styles from './PanneauRoot.module.css';\n\nexport interface PanneauRootProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Tokens, tones, variants and fonts that override the default theme: `bootstrapTheme`, or a\n * project's own (`defineTheme()`).\n */\n theme?: Theme | null;\n /** Defaults to `light`. `auto` follows the system setting. */\n colorScheme?: ColorScheme;\n /**\n * How much room controls and rows take: `compact`, `comfortable` or `touch`. Defaults to\n * `auto`: `touch` on touch screens, `comfortable` otherwise.\n */\n density?: Density;\n /**\n * Loads the icons that definitions name (`\"icon\": \"send\"`), for `getNamedIcon()`: pass\n * `lucideIconLoader` from `@panneau/ui/named-icons`, or a loader of only the icons the app\n * uses. Without it, named icons render an empty space.\n */\n iconLoader?: NamedIconLoader | null;\n /**\n * Locale of dates and numbers in React Aria components. Defaults to the react-intl locale, or\n * to the browser's without an `IntlProvider`.\n *\n * Without an `IntlProvider` above it, the root provides one, with the messages of every Panneau\n * package in this locale (English without a locale, or for a locale Panneau doesn't translate).\n * An app with its own `IntlProvider` adds them with `withPanneauMessages()` from\n * `@panneau/intl`.\n */\n locale?: string;\n /**\n * Messages added to Panneau's, by id, when the root provides the `IntlProvider`: those of\n * plugins (`loadMessages()` of `@panneau/core`). An app with its own `IntlProvider` adds them\n * to its own.\n */\n messages?: Readonly<Record<string, string>> | null;\n /**\n * The nonce of the page's Content Security Policy, set on the `<style>` and `<link>` elements of\n * themes and fonts, for a policy without `'unsafe-inline'` in `style-src`. Defaults to the\n * nonce React Aria reads too: that of `<meta property=\"csp-nonce\">`, or `__webpack_nonce__`.\n */\n nonce?: string;\n children?: ReactNode;\n}\n\n/** `undefined` outside of a root, `null` while the root's container isn't mounted yet. */\nconst PortalContext = createContext<Element | null | undefined>(undefined);\n\n/**\n * The color scheme and density in effect, which a `ThemeScope` inherits when it doesn't set them,\n * and the nonce of the styles of themes.\n */\nexport const ScopeContext = createContext<{\n colorScheme: ColorScheme;\n density: Density;\n nonce?: string | undefined;\n}>({\n colorScheme: 'light',\n density: 'auto',\n});\n\n/**\n * The nonce of the page's Content Security Policy, where React Aria reads it: the `nonce` (or\n * `content`) of `<meta property=\"csp-nonce\">` or `<meta name=\"csp-nonce\">`, or\n * `__webpack_nonce__`. `undefined` without one, and on the server.\n */\nexport function getPageNonce(): string | undefined {\n if (typeof document === 'undefined') {\n return undefined;\n }\n const meta = document.querySelector<HTMLMetaElement>(\n 'meta[property=\"csp-nonce\"], meta[name=\"csp-nonce\"]',\n );\n const nonce =\n meta?.nonce ||\n meta?.content ||\n (globalThis as { __webpack_nonce__?: string }).__webpack_nonce__;\n return nonce !== undefined && nonce !== '' ? nonce : undefined;\n}\n\n/** Gives overlays a container: that of a root, or of a scope. */\nexport const PortalProvider = PortalContext.Provider;\n\n/**\n * The `<style>` and `<link>` elements of a theme: its CSS, scoped to `data-panneau-theme`, and its\n * fonts. React hoists them to the head and adds each once, however many roots or scopes use it.\n * Returns the scope of the theme too, for `data-panneau-theme`.\n */\nexport function useThemeStyles(\n theme: Theme | null,\n nonce?: string,\n): { scope?: string; styles: ReactNode } {\n const css = theme !== null ? getThemeCss(theme, '§') : '';\n const scope = css !== '' ? hashString(css) : undefined;\n const fontCss = getFontFaceCss(theme?.fonts);\n return {\n scope,\n styles: (\n <>\n {scope !== undefined ? (\n <style href={`panneau-theme-${scope}`} precedence=\"panneau\" nonce={nonce}>\n {css.replaceAll('§', scope)}\n </style>\n ) : null}\n {fontCss !== '' ? (\n <style\n href={`panneau-fonts-${hashString(fontCss)}`}\n precedence=\"panneau\"\n nonce={nonce}\n >\n {fontCss}\n </style>\n ) : null}\n {getFontStylesheets(theme?.fonts).map((href) => (\n <link\n key={href}\n rel=\"stylesheet\"\n href={href}\n precedence=\"panneau\"\n nonce={nonce}\n />\n ))}\n </>\n ),\n };\n}\n\n/**\n * The element overlays render into: the closest `PanneauRoot`'s or `ThemeScope`'s, or `undefined` for the body\n * without a root. It is `null` during the first render of a root: overlays wait for it, since\n * React Aria hides everything outside of a modal from assistive technologies when it opens.\n */\nexport function usePortalContainer(): Element | null | undefined {\n return use(PortalContext);\n}\n\n/**\n * An `IntlProvider` with Panneau's messages in a locale, for a root without one above it. A locale\n * Panneau doesn't translate gets English, so that react-intl doesn't report every message as\n * missing.\n */\nfunction PanneauIntlProvider({\n locale = 'en',\n messages: added,\n children,\n}: {\n locale?: string;\n messages?: Readonly<Record<string, string>> | null;\n children: ReactNode;\n}) {\n const messages = getPanneauMessages(locale);\n const translated = Object.keys(messages).length > 0;\n return (\n <IntlProvider\n locale={translated ? locale : 'en'}\n defaultLocale=\"en\"\n messages={{ ...(translated ? messages : getPanneauMessages('en')), ...added }}\n >\n {children}\n </IntlProvider>\n );\n}\n\n/**\n * The root of every Panneau interface. It scopes the base stylesheet and the design tokens to its\n * element (no global CSS), applies a theme and a color scheme, and hosts overlays and toasts so\n * that they get the tokens too. Panneau components must render inside one. A project can override\n * any token with its own class on the root. Without an `IntlProvider` above it, it provides one\n * with Panneau's messages in its `locale`.\n */\nexport function PanneauRoot({\n theme = null,\n colorScheme = 'light',\n density = 'auto',\n iconLoader = null,\n locale,\n messages,\n nonce: givenNonce,\n className,\n children,\n ...props\n}: PanneauRootProps) {\n const [pageNonce] = useState(getPageNonce);\n const nonce = givenNonce ?? pageNonce;\n const intl = use(IntlContext) as IntlShape | null | undefined;\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const { scope, styles: themeStyles } = useThemeStyles(theme, nonce);\n const root = (\n <div\n {...props}\n className={cx('panneau-root', styles.root, styles.container, className)}\n data-color-scheme={colorScheme}\n data-density={density}\n data-panneau-theme={scope}\n >\n {themeStyles}\n <I18nProvider locale={locale ?? intl?.locale}>\n <NamedIconLoaderContext value={iconLoader}>\n <ScopeContext value={{ colorScheme, density, nonce }}>\n <PortalContext value={container}>\n <ToastProvider\n regionClassName={styles.root}\n regionProps={{\n 'data-color-scheme': colorScheme,\n 'data-density': density,\n 'data-panneau-theme': scope,\n }}\n >\n {children}\n </ToastProvider>\n </PortalContext>\n </ScopeContext>\n </NamedIconLoaderContext>\n <div ref={setContainer} className={styles.portal} />\n </I18nProvider>\n </div>\n );\n if (intl === null || intl === undefined) {\n return (\n <PanneauIntlProvider locale={locale} messages={messages}>\n {root}\n </PanneauIntlProvider>\n );\n }\n return root;\n}\n"],"mappings":";;;;;;;;;;;;;;AAgEA,IAAMkC,gBAAgBhC,cAA0CkC,KAAAA,CAAS;;;;;AAMzE,IAAaC,eAAenC,cAIzB;CACCuB,aAAa;CACbC,SAAS;AACb,CAAC;;;;;;AAOD,SAAgBY,eAAmC;CAC/C,IAAI,OAAOC,aAAa,aACpB;CAEJ,MAAMC,OAAOD,SAASE,cAClB,wDACJ;CACA,MAAMT,QACFQ,MAAMR,SACNQ,MAAMG,WACLC,WAA8CC;CACnD,OAAOb,UAAUI,KAAAA,KAAaJ,UAAU,KAAKA,QAAQI,KAAAA;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,MAAA,oBAAC,qBAAD;IAA6BlE;IAAkBC;IAC1CqD,UAAAA;GADe,CAAA;GAEEjC,EAAA,MAAArB;GAAAqB,EAAA,MAAApB;GAAAoB,EAAA,MAAAiC;GAAAjC,EAAA,MAAA6C;EAAA,OAAAA,MAAA7C,EAAA;EAAA,OAFtB6C;CAEsB;CAE7B,OACMZ;AAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeScope.d.ts","sourceRoot":"","sources":["../../src/root/ThemeScope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AAE3E,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAKlE,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,WAAW,CAAC;IAChE,4CAA4C;IAC5C,EAAE,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IACpF,2DAA2D;IAC3D,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,EACvB,EAAE,EAAE,OAAe,EACnB,KAAY,EACZ,WAAW,EACX,OAAO,EACP,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,eAAe,+
|
|
1
|
+
{"version":3,"file":"ThemeScope.d.ts","sourceRoot":"","sources":["../../src/root/ThemeScope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AAE3E,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAKlE,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,WAAW,CAAC;IAChE,4CAA4C;IAC5C,EAAE,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IACpF,2DAA2D;IAC3D,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,EACvB,EAAE,EAAE,OAAe,EACnB,KAAY,EACZ,WAAW,EACX,OAAO,EACP,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,eAAe,+BAgCjB"}
|
package/dist/root/ThemeScope.js
CHANGED
|
@@ -15,7 +15,7 @@ import { use, useState } from "react";
|
|
|
15
15
|
* theme around it.
|
|
16
16
|
*/
|
|
17
17
|
function ThemeScope(t0) {
|
|
18
|
-
const $ = c(
|
|
18
|
+
const $ = c(32);
|
|
19
19
|
let children;
|
|
20
20
|
let className;
|
|
21
21
|
let colorScheme;
|
|
@@ -46,60 +46,62 @@ function ThemeScope(t0) {
|
|
|
46
46
|
const theme = t2 === void 0 ? null : t2;
|
|
47
47
|
const parent = use(ScopeContext);
|
|
48
48
|
const [container, setContainer] = useState(null);
|
|
49
|
-
const { scope, styles: themeStyles } = useThemeStyles(theme);
|
|
49
|
+
const { scope, styles: themeStyles } = useThemeStyles(theme, parent.nonce);
|
|
50
50
|
const t3 = colorScheme ?? parent.colorScheme;
|
|
51
51
|
const t4 = density ?? parent.density;
|
|
52
52
|
let t5;
|
|
53
|
-
if ($[8] !==
|
|
53
|
+
if ($[8] !== parent.nonce || $[9] !== t3 || $[10] !== t4) {
|
|
54
54
|
t5 = {
|
|
55
55
|
colorScheme: t3,
|
|
56
|
-
density: t4
|
|
56
|
+
density: t4,
|
|
57
|
+
nonce: parent.nonce
|
|
57
58
|
};
|
|
58
|
-
$[8] =
|
|
59
|
-
$[9] =
|
|
60
|
-
$[10] =
|
|
61
|
-
|
|
59
|
+
$[8] = parent.nonce;
|
|
60
|
+
$[9] = t3;
|
|
61
|
+
$[10] = t4;
|
|
62
|
+
$[11] = t5;
|
|
63
|
+
} else t5 = $[11];
|
|
62
64
|
const effective = t5;
|
|
63
65
|
const t6 = colorScheme !== void 0 && PanneauRoot_module_default.scheme;
|
|
64
66
|
const t7 = density !== void 0 && PanneauRoot_module_default.density;
|
|
65
67
|
let t8;
|
|
66
|
-
if ($[
|
|
68
|
+
if ($[12] !== className || $[13] !== t6 || $[14] !== t7) {
|
|
67
69
|
t8 = cx("panneau-theme-scope", PanneauRoot_module_default.scope, t6, t7, className);
|
|
68
|
-
$[
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
} else t8 = $[
|
|
70
|
+
$[12] = className;
|
|
71
|
+
$[13] = t6;
|
|
72
|
+
$[14] = t7;
|
|
73
|
+
$[15] = t8;
|
|
74
|
+
} else t8 = $[15];
|
|
73
75
|
let t9;
|
|
74
|
-
if ($[
|
|
76
|
+
if ($[16] !== children || $[17] !== container) {
|
|
75
77
|
t9 = /* @__PURE__ */ jsx(PortalProvider, {
|
|
76
78
|
value: container,
|
|
77
79
|
children
|
|
78
80
|
});
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
} else t9 = $[
|
|
81
|
+
$[16] = children;
|
|
82
|
+
$[17] = container;
|
|
83
|
+
$[18] = t9;
|
|
84
|
+
} else t9 = $[18];
|
|
83
85
|
let t10;
|
|
84
|
-
if ($[
|
|
86
|
+
if ($[19] !== effective || $[20] !== t9) {
|
|
85
87
|
t10 = /* @__PURE__ */ jsx(ScopeContext, {
|
|
86
88
|
value: effective,
|
|
87
89
|
children: t9
|
|
88
90
|
});
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
-
$[
|
|
92
|
-
} else t10 = $[
|
|
91
|
+
$[19] = effective;
|
|
92
|
+
$[20] = t9;
|
|
93
|
+
$[21] = t10;
|
|
94
|
+
} else t10 = $[21];
|
|
93
95
|
let t11;
|
|
94
|
-
if ($[
|
|
96
|
+
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
95
97
|
t11 = /* @__PURE__ */ jsx("div", {
|
|
96
98
|
ref: setContainer,
|
|
97
99
|
className: PanneauRoot_module_default.portal
|
|
98
100
|
});
|
|
99
|
-
$[
|
|
100
|
-
} else t11 = $[
|
|
101
|
+
$[22] = t11;
|
|
102
|
+
} else t11 = $[22];
|
|
101
103
|
let t12;
|
|
102
|
-
if ($[
|
|
104
|
+
if ($[23] !== Element || $[24] !== effective.colorScheme || $[25] !== effective.density || $[26] !== props || $[27] !== scope || $[28] !== t10 || $[29] !== t8 || $[30] !== themeStyles) {
|
|
103
105
|
t12 = /* @__PURE__ */ jsxs(Element, {
|
|
104
106
|
...props,
|
|
105
107
|
className: t8,
|
|
@@ -112,16 +114,16 @@ function ThemeScope(t0) {
|
|
|
112
114
|
t11
|
|
113
115
|
]
|
|
114
116
|
});
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
$[
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
} else t12 = $[
|
|
117
|
+
$[23] = Element;
|
|
118
|
+
$[24] = effective.colorScheme;
|
|
119
|
+
$[25] = effective.density;
|
|
120
|
+
$[26] = props;
|
|
121
|
+
$[27] = scope;
|
|
122
|
+
$[28] = t10;
|
|
123
|
+
$[29] = t8;
|
|
124
|
+
$[30] = themeStyles;
|
|
125
|
+
$[31] = t12;
|
|
126
|
+
} else t12 = $[31];
|
|
125
127
|
return t12;
|
|
126
128
|
}
|
|
127
129
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeScope.js","names":["HTMLAttributes","ReactNode","use","useState","ColorScheme","Density","Theme","cx","PortalProvider","ScopeContext","useThemeStyles","styles","ThemeScopeProps","HTMLElement","as","theme","colorScheme","density","children","ThemeScope","t0","$","_c","className","props","t1","t2","Element","undefined","parent","container","setContainer","scope","themeStyles","t3","t4","t5","effective","t6","scheme","t7","t8","t9","t10","t11","Symbol","for","portal","t12","_c","styles"],"sources":["../../src/root/ThemeScope.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, use, useState } from 'react';\n\nimport type { ColorScheme, Density, Theme } from '../theme/theme';\nimport { cx } from '../utils/cx';\nimport { PortalProvider, ScopeContext, useThemeStyles } from './PanneauRoot';\nimport styles from './PanneauRoot.module.css';\n\nexport interface ThemeScopeProps extends HTMLAttributes<HTMLElement> {\n /** Element to render. Defaults to `div`. */\n as?: 'div' | 'section' | 'aside' | 'nav' | 'header' | 'footer' | 'main' | 'article';\n /** A theme for the subtree, over the theme of the root. */\n theme?: Theme | null;\n /** A color scheme for the subtree. Inherited by default. */\n colorScheme?: ColorScheme;\n /** A density for the subtree. Inherited by default. */\n density?: Density;\n children?: ReactNode;\n}\n\n/**\n * Applies a theme, a color scheme or a density to a subtree, like `data-bs-theme` on any element:\n * a dark sidebar in a light app, a compact table, a preview in another brand's colors. Overlays\n * opened inside it render in its own container, so that they keep its tokens. It must be inside a\n * `PanneauRoot`.\n *\n * What it doesn't set comes from its parent: a scope with only a density keeps the colors of the\n * theme around it.\n */\nexport function ThemeScope({\n as: Element = 'div',\n theme = null,\n colorScheme,\n density,\n className,\n children,\n ...props\n}: ThemeScopeProps) {\n const parent = use(ScopeContext);\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const { scope, styles: themeStyles } = useThemeStyles(theme);\n // The effective values are always written, so that the dark and density rules of a theme apply.\n // Only those set here take the default tokens back (`.scheme`, `.density`).\n const effective = {\n colorScheme: colorScheme ?? parent.colorScheme,\n density: density ?? parent.density,\n };\n return (\n <Element\n {...props}\n className={cx(\n 'panneau-theme-scope',\n styles.scope,\n colorScheme !== undefined && styles.scheme,\n density !== undefined && styles.density,\n className,\n )}\n data-color-scheme={effective.colorScheme}\n data-density={effective.density}\n data-panneau-theme={scope}\n >\n {themeStyles}\n <ScopeContext value={effective}>\n <PortalProvider value={container}>{children}</PortalProvider>\n </ScopeContext>\n <div ref={setContainer} className={styles.portal} />\n </Element>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,SAAOmB,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAJ;CAAA,IAAAK;CAAA,IAAAP;CAAA,IAAAC;CAAA,IAAAO;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAL,EAAA,OAAAD,IAAA;EAAoB,CAAA,CAAAN,IAAAW,IAAAV,OAAAW,IAAAV,aAAAC,SAAAM,WAAAL,UAAA,GAAAM,SAAAJ;EAQTC,EAAA,KAAAD;EAAAC,EAAA,KAAAH;EAAAG,EAAA,KAAAE;EAAAF,EAAA,KAAAL;EAAAK,EAAA,KAAAJ;EAAAI,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAA;EAAAR,WAAAG,EAAA;EAAAE,YAAAF,EAAA;EAAAL,cAAAK,EAAA;EAAAJ,UAAAI,EAAA;EAAAG,QAAAH,EAAA;EAAAI,KAAAJ,EAAA;EAAAK,KAAAL,EAAA;CAAA;CAPV,MAAAM,UAAAF,OAAAG,KAAAA,IAAA,QAAAH;CACJ,MAAAV,QAAAW,OAAAE,KAAAA,IAAA,OAAAF;CAOA,MAAAG,SAAe3B,IAAIO,YAAY;CAC/B,MAAA,CAAAqB,WAAAC,gBAAkC5B,SAAgC,IAAI;CACtE,MAAA,EAAA6B,OAAArB,QAAAsB,gBAAuCvB,eAAeK,
|
|
1
|
+
{"version":3,"file":"ThemeScope.js","names":["HTMLAttributes","ReactNode","use","useState","ColorScheme","Density","Theme","cx","PortalProvider","ScopeContext","useThemeStyles","styles","ThemeScopeProps","HTMLElement","as","theme","colorScheme","density","children","ThemeScope","t0","$","_c","className","props","t1","t2","Element","undefined","parent","container","setContainer","scope","themeStyles","nonce","t3","t4","t5","effective","t6","scheme","t7","t8","t9","t10","t11","Symbol","for","portal","t12","_c","styles"],"sources":["../../src/root/ThemeScope.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, use, useState } from 'react';\n\nimport type { ColorScheme, Density, Theme } from '../theme/theme';\nimport { cx } from '../utils/cx';\nimport { PortalProvider, ScopeContext, useThemeStyles } from './PanneauRoot';\nimport styles from './PanneauRoot.module.css';\n\nexport interface ThemeScopeProps extends HTMLAttributes<HTMLElement> {\n /** Element to render. Defaults to `div`. */\n as?: 'div' | 'section' | 'aside' | 'nav' | 'header' | 'footer' | 'main' | 'article';\n /** A theme for the subtree, over the theme of the root. */\n theme?: Theme | null;\n /** A color scheme for the subtree. Inherited by default. */\n colorScheme?: ColorScheme;\n /** A density for the subtree. Inherited by default. */\n density?: Density;\n children?: ReactNode;\n}\n\n/**\n * Applies a theme, a color scheme or a density to a subtree, like `data-bs-theme` on any element:\n * a dark sidebar in a light app, a compact table, a preview in another brand's colors. Overlays\n * opened inside it render in its own container, so that they keep its tokens. It must be inside a\n * `PanneauRoot`.\n *\n * What it doesn't set comes from its parent: a scope with only a density keeps the colors of the\n * theme around it.\n */\nexport function ThemeScope({\n as: Element = 'div',\n theme = null,\n colorScheme,\n density,\n className,\n children,\n ...props\n}: ThemeScopeProps) {\n const parent = use(ScopeContext);\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const { scope, styles: themeStyles } = useThemeStyles(theme, parent.nonce);\n // The effective values are always written, so that the dark and density rules of a theme apply.\n // Only those set here take the default tokens back (`.scheme`, `.density`).\n const effective = {\n colorScheme: colorScheme ?? parent.colorScheme,\n density: density ?? parent.density,\n nonce: parent.nonce,\n };\n return (\n <Element\n {...props}\n className={cx(\n 'panneau-theme-scope',\n styles.scope,\n colorScheme !== undefined && styles.scheme,\n density !== undefined && styles.density,\n className,\n )}\n data-color-scheme={effective.colorScheme}\n data-density={effective.density}\n data-panneau-theme={scope}\n >\n {themeStyles}\n <ScopeContext value={effective}>\n <PortalProvider value={container}>{children}</PortalProvider>\n </ScopeContext>\n <div ref={setContainer} className={styles.portal} />\n </Element>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,SAAOmB,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAJ;CAAA,IAAAK;CAAA,IAAAP;CAAA,IAAAC;CAAA,IAAAO;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAL,EAAA,OAAAD,IAAA;EAAoB,CAAA,CAAAN,IAAAW,IAAAV,OAAAW,IAAAV,aAAAC,SAAAM,WAAAL,UAAA,GAAAM,SAAAJ;EAQTC,EAAA,KAAAD;EAAAC,EAAA,KAAAH;EAAAG,EAAA,KAAAE;EAAAF,EAAA,KAAAL;EAAAK,EAAA,KAAAJ;EAAAI,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAA;EAAAR,WAAAG,EAAA;EAAAE,YAAAF,EAAA;EAAAL,cAAAK,EAAA;EAAAJ,UAAAI,EAAA;EAAAG,QAAAH,EAAA;EAAAI,KAAAJ,EAAA;EAAAK,KAAAL,EAAA;CAAA;CAPV,MAAAM,UAAAF,OAAAG,KAAAA,IAAA,QAAAH;CACJ,MAAAV,QAAAW,OAAAE,KAAAA,IAAA,OAAAF;CAOA,MAAAG,SAAe3B,IAAIO,YAAY;CAC/B,MAAA,CAAAqB,WAAAC,gBAAkC5B,SAAgC,IAAI;CACtE,MAAA,EAAA6B,OAAArB,QAAAsB,gBAAuCvB,eAAeK,OAAOc,OAAMK,KA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A,IAAAwB;CAAA,IAAAxB,EAAA,QAAAyB,OAAAC,IAAA,2BAAA,GAAA;EACfF,MAAA,oBAAA,OAAA;GAAUd,KAAAA;GAAyB,WAAApB,2BAAMqC;EAAO,CAAA;EAAI3B,EAAA,MAAAwB;CAAA,OAAAA,MAAAxB,EAAA;CAAA,IAAA4B;CAAA,IAAA5B,EAAA,QAAAM,WAAAN,EAAA,QAAAiB,UAAAtB,eAAAK,EAAA,QAAAiB,UAAArB,WAAAI,EAAA,QAAAG,SAAAH,EAAA,QAAAW,SAAAX,EAAA,QAAAuB,OAAAvB,EAAA,QAAAqB,MAAArB,EAAA,QAAAY,aAAA;EAjBxDgB,MAAA,qBAAC,SAAD;GAAQ,GACAzB;GACO,WAAAkB;GAOQ,qBAAAJ,UAAStB;GACd,gBAAAsB,UAASrB;GACHe,sBAAAA;GAXxB,UAAA;IAaKC;IACDW;IAGAC;GAjBI;;EAkBExB,EAAA,MAAAM;EAAAN,EAAA,MAAAiB,UAAAtB;EAAAK,EAAA,MAAAiB,UAAArB;EAAAI,EAAA,MAAAG;EAAAH,EAAA,MAAAW;EAAAX,EAAA,MAAAuB;EAAAvB,EAAA,MAAAqB;EAAArB,EAAA,MAAAY;EAAAZ,EAAA,MAAA4B;CAAA,OAAAA,MAAA5B,EAAA;CAAA,OAlBV4B;AAkBU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/utils/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAE3D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/events.ts
|
|
2
|
+
/** Stops an event from reaching the components around: for `onSubmit` of overlays. */
|
|
3
|
+
function stopPropagation(event) {
|
|
4
|
+
event.stopPropagation();
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { stopPropagation };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","names":["SyntheticEvent","stopPropagation","event"],"sources":["../../src/utils/events.ts"],"sourcesContent":["import type { SyntheticEvent } from 'react';\n\n/** Stops an event from reaching the components around: for `onSubmit` of overlays. */\nexport function stopPropagation(event: SyntheticEvent): void {\n event.stopPropagation();\n}\n"],"mappings":";;AAGA,SAAgBC,gBAAgBC,OAA6B;CACzDA,MAAMD,gBAAgB;AAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/ui",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.9",
|
|
4
4
|
"description": "Design tokens, themes and accessible primitives of Panneau, built on React Aria Components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"react-intl": "^12.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@panneau/intl": "5.0.0-alpha.
|
|
60
|
+
"@panneau/intl": "5.0.0-alpha.9",
|
|
61
61
|
"lucide-react": "^1.57.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@panneau/protocol": "5.0.0-alpha.
|
|
64
|
+
"@panneau/protocol": "5.0.0-alpha.9"
|
|
65
65
|
}
|
|
66
66
|
}
|