@derelicious/ds 0.0.0-stage → 0.2.0
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/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +147 -2
- package/dist/a2ui/Surface.css +140 -0
- package/dist/a2ui/Surface.css.d.ts +22 -0
- package/dist/a2ui/Surface.css.js +29 -0
- package/dist/a2ui/Surface.d.ts +56 -0
- package/dist/a2ui/Surface.js +1411 -0
- package/dist/a2ui/catalog.d.ts +93 -0
- package/dist/a2ui/catalog.js +1666 -0
- package/dist/a2ui/clientMessages.d.ts +36 -0
- package/dist/a2ui/clientMessages.js +65 -0
- package/dist/a2ui/examples.d.ts +8 -0
- package/dist/a2ui/examples.js +877 -0
- package/dist/a2ui/functions.d.ts +55 -0
- package/dist/a2ui/functions.js +341 -0
- package/dist/a2ui/ids.d.ts +5 -0
- package/dist/a2ui/ids.js +7 -0
- package/dist/a2ui/index.d.ts +16 -0
- package/dist/a2ui/index.js +12 -0
- package/dist/a2ui/jsonl.d.ts +41 -0
- package/dist/a2ui/jsonl.js +127 -0
- package/dist/a2ui/links.d.ts +17 -0
- package/dist/a2ui/links.js +29 -0
- package/dist/a2ui/pointer.d.ts +22 -0
- package/dist/a2ui/pointer.js +85 -0
- package/dist/a2ui/processor.d.ts +126 -0
- package/dist/a2ui/processor.js +497 -0
- package/dist/a2ui/react.d.ts +2 -0
- package/dist/a2ui/react.js +1 -0
- package/dist/a2ui/toTsx.d.ts +9 -0
- package/dist/a2ui/toTsx.js +1389 -0
- package/dist/a2ui/types.d.ts +96 -0
- package/dist/a2ui/validate.d.ts +90 -0
- package/dist/a2ui/validate.js +750 -0
- package/dist/a2ui-catalog.json +4369 -0
- package/dist/a2ui-conformance.json +71 -0
- package/dist/components/Accordion/Accordion.css +58 -0
- package/dist/components/Accordion/Accordion.css.d.ts +5 -0
- package/dist/components/Accordion/Accordion.css.js +10 -0
- package/dist/components/Accordion/Accordion.d.ts +23 -0
- package/dist/components/Accordion/Accordion.docs.d.ts +19 -0
- package/dist/components/Accordion/Accordion.docs.js +43 -0
- package/dist/components/Accordion/Accordion.js +55 -0
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/AiLabel/AiLabel.css +70 -0
- package/dist/components/AiLabel/AiLabel.css.d.ts +8 -0
- package/dist/components/AiLabel/AiLabel.css.js +11 -0
- package/dist/components/AiLabel/AiLabel.d.ts +29 -0
- package/dist/components/AiLabel/AiLabel.docs.d.ts +19 -0
- package/dist/components/AiLabel/AiLabel.docs.js +51 -0
- package/dist/components/AiLabel/AiLabel.js +41 -0
- package/dist/components/AiLabel/index.d.ts +1 -0
- package/dist/components/AiLabel/index.js +1 -0
- package/dist/components/Alert/Alert.css +76 -0
- package/dist/components/Alert/Alert.css.d.ts +9 -0
- package/dist/components/Alert/Alert.css.js +23 -0
- package/dist/components/Alert/Alert.d.ts +21 -0
- package/dist/components/Alert/Alert.docs.d.ts +19 -0
- package/dist/components/Alert/Alert.docs.js +57 -0
- package/dist/components/Alert/Alert.js +55 -0
- package/dist/components/Alert/index.d.ts +1 -0
- package/dist/components/Alert/index.js +1 -0
- package/dist/components/Avatar/Avatar.css +42 -0
- package/dist/components/Avatar/Avatar.css.d.ts +3 -0
- package/dist/components/Avatar/Avatar.css.js +12 -0
- package/dist/components/Avatar/Avatar.d.ts +13 -0
- package/dist/components/Avatar/Avatar.docs.d.ts +19 -0
- package/dist/components/Avatar/Avatar.docs.js +43 -0
- package/dist/components/Avatar/Avatar.js +31 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/Avatar/initials.d.ts +2 -0
- package/dist/components/Avatar/initials.js +8 -0
- package/dist/components/Badge/Badge.css +63 -0
- package/dist/components/Badge/Badge.css.d.ts +5 -0
- package/dist/components/Badge/Badge.css.js +16 -0
- package/dist/components/Badge/Badge.d.ts +15 -0
- package/dist/components/Badge/Badge.docs.d.ts +19 -0
- package/dist/components/Badge/Badge.docs.js +52 -0
- package/dist/components/Badge/Badge.js +24 -0
- package/dist/components/Badge/index.d.ts +1 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.css +40 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.css.d.ts +5 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.css.js +10 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +17 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.docs.d.ts +19 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.docs.js +38 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +48 -0
- package/dist/components/Breadcrumbs/index.d.ts +1 -0
- package/dist/components/Breadcrumbs/index.js +1 -0
- package/dist/components/Button/Button.css +101 -0
- package/dist/components/Button/Button.css.d.ts +72 -0
- package/dist/components/Button/Button.css.js +35 -0
- package/dist/components/Button/Button.d.ts +53 -0
- package/dist/components/Button/Button.docs.d.ts +19 -0
- package/dist/components/Button/Button.docs.js +71 -0
- package/dist/components/Button/Button.js +68 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/Card/Card.css +122 -0
- package/dist/components/Card/Card.css.d.ts +12 -0
- package/dist/components/Card/Card.css.js +25 -0
- package/dist/components/Card/Card.d.ts +306 -0
- package/dist/components/Card/Card.docs.d.ts +19 -0
- package/dist/components/Card/Card.docs.js +65 -0
- package/dist/components/Card/Card.js +53 -0
- package/dist/components/Card/index.d.ts +1 -0
- package/dist/components/Card/index.js +1 -0
- package/dist/components/ChatMessage/ChatMessage.css +56 -0
- package/dist/components/ChatMessage/ChatMessage.css.d.ts +7 -0
- package/dist/components/ChatMessage/ChatMessage.css.js +15 -0
- package/dist/components/ChatMessage/ChatMessage.d.ts +35 -0
- package/dist/components/ChatMessage/ChatMessage.docs.d.ts +19 -0
- package/dist/components/ChatMessage/ChatMessage.docs.js +45 -0
- package/dist/components/ChatMessage/ChatMessage.js +49 -0
- package/dist/components/ChatMessage/index.d.ts +1 -0
- package/dist/components/ChatMessage/index.js +1 -0
- package/dist/components/Checkbox/Checkbox.css +70 -0
- package/dist/components/Checkbox/Checkbox.css.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.css.js +6 -0
- package/dist/components/Checkbox/Checkbox.d.ts +28 -0
- package/dist/components/Checkbox/Checkbox.docs.d.ts +19 -0
- package/dist/components/Checkbox/Checkbox.docs.js +53 -0
- package/dist/components/Checkbox/Checkbox.js +63 -0
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/Checkbox/index.js +1 -0
- package/dist/components/Code/Code.css +12 -0
- package/dist/components/Code/Code.css.d.ts +1 -0
- package/dist/components/Code/Code.css.js +5 -0
- package/dist/components/Code/Code.d.ts +7 -0
- package/dist/components/Code/Code.docs.d.ts +19 -0
- package/dist/components/Code/Code.docs.js +26 -0
- package/dist/components/Code/Code.js +12 -0
- package/dist/components/Code/index.d.ts +1 -0
- package/dist/components/Code/index.js +1 -0
- package/dist/components/CodeBlock/CodeBlock.css +76 -0
- package/dist/components/CodeBlock/CodeBlock.css.d.ts +12 -0
- package/dist/components/CodeBlock/CodeBlock.css.js +21 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +19 -0
- package/dist/components/CodeBlock/CodeBlock.docs.d.ts +19 -0
- package/dist/components/CodeBlock/CodeBlock.docs.js +47 -0
- package/dist/components/CodeBlock/CodeBlock.js +82 -0
- package/dist/components/CodeBlock/highlight.d.ts +28 -0
- package/dist/components/CodeBlock/highlight.js +118 -0
- package/dist/components/CodeBlock/index.d.ts +1 -0
- package/dist/components/CodeBlock/index.js +1 -0
- package/dist/components/Container/Container.css +21 -0
- package/dist/components/Container/Container.css.d.ts +3 -0
- package/dist/components/Container/Container.css.js +12 -0
- package/dist/components/Container/Container.d.ts +295 -0
- package/dist/components/Container/Container.docs.d.ts +19 -0
- package/dist/components/Container/Container.docs.js +31 -0
- package/dist/components/Container/Container.js +12 -0
- package/dist/components/Container/index.d.ts +1 -0
- package/dist/components/Container/index.js +1 -0
- package/dist/components/Dialog/Dialog.css +94 -0
- package/dist/components/Dialog/Dialog.css.d.ts +9 -0
- package/dist/components/Dialog/Dialog.css.js +17 -0
- package/dist/components/Dialog/Dialog.d.ts +29 -0
- package/dist/components/Dialog/Dialog.docs.d.ts +19 -0
- package/dist/components/Dialog/Dialog.docs.js +50 -0
- package/dist/components/Dialog/Dialog.js +90 -0
- package/dist/components/Dialog/index.d.ts +1 -0
- package/dist/components/Dialog/index.js +1 -0
- package/dist/components/Divider/Divider.css +41 -0
- package/dist/components/Divider/Divider.css.d.ts +6 -0
- package/dist/components/Divider/Divider.css.js +16 -0
- package/dist/components/Divider/Divider.d.ts +11 -0
- package/dist/components/Divider/Divider.docs.d.ts +19 -0
- package/dist/components/Divider/Divider.docs.js +43 -0
- package/dist/components/Divider/Divider.js +30 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/Grid/Grid.css +11 -0
- package/dist/components/Grid/Grid.css.d.ts +8 -0
- package/dist/components/Grid/Grid.css.js +8 -0
- package/dist/components/Grid/Grid.d.ts +18 -0
- package/dist/components/Grid/Grid.docs.d.ts +19 -0
- package/dist/components/Grid/Grid.docs.js +41 -0
- package/dist/components/Grid/Grid.js +22 -0
- package/dist/components/Grid/index.d.ts +1 -0
- package/dist/components/Grid/index.js +1 -0
- package/dist/components/Heading/Heading.css +44 -0
- package/dist/components/Heading/Heading.css.d.ts +3 -0
- package/dist/components/Heading/Heading.css.js +17 -0
- package/dist/components/Heading/Heading.d.ts +298 -0
- package/dist/components/Heading/Heading.docs.d.ts +19 -0
- package/dist/components/Heading/Heading.docs.js +48 -0
- package/dist/components/Heading/Heading.js +20 -0
- package/dist/components/Heading/index.d.ts +1 -0
- package/dist/components/Heading/index.js +1 -0
- package/dist/components/Icon/Icon.css +25 -0
- package/dist/components/Icon/Icon.css.d.ts +4 -0
- package/dist/components/Icon/Icon.css.js +13 -0
- package/dist/components/Icon/Icon.d.ts +16 -0
- package/dist/components/Icon/Icon.docs.d.ts +19 -0
- package/dist/components/Icon/Icon.docs.js +56 -0
- package/dist/components/Icon/Icon.js +25 -0
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/components/Icon/index.js +1 -0
- package/dist/components/IconButton/IconButton.css +70 -0
- package/dist/components/IconButton/IconButton.css.d.ts +57 -0
- package/dist/components/IconButton/IconButton.css.js +27 -0
- package/dist/components/IconButton/IconButton.d.ts +46 -0
- package/dist/components/IconButton/IconButton.docs.d.ts +19 -0
- package/dist/components/IconButton/IconButton.docs.js +48 -0
- package/dist/components/IconButton/IconButton.js +44 -0
- package/dist/components/IconButton/index.d.ts +1 -0
- package/dist/components/IconButton/index.js +1 -0
- package/dist/components/Image/Image.css +53 -0
- package/dist/components/Image/Image.css.d.ts +7 -0
- package/dist/components/Image/Image.css.js +18 -0
- package/dist/components/Image/Image.d.ts +23 -0
- package/dist/components/Image/Image.docs.d.ts +19 -0
- package/dist/components/Image/Image.docs.js +48 -0
- package/dist/components/Image/Image.js +75 -0
- package/dist/components/Image/index.d.ts +1 -0
- package/dist/components/Image/index.js +1 -0
- package/dist/components/Inline/Inline.css +38 -0
- package/dist/components/Inline/Inline.css.d.ts +4 -0
- package/dist/components/Inline/Inline.css.js +18 -0
- package/dist/components/Inline/Inline.d.ts +300 -0
- package/dist/components/Inline/Inline.docs.d.ts +19 -0
- package/dist/components/Inline/Inline.docs.js +48 -0
- package/dist/components/Inline/Inline.js +13 -0
- package/dist/components/Inline/index.d.ts +1 -0
- package/dist/components/Inline/index.js +1 -0
- package/dist/components/Link/Link.css +57 -0
- package/dist/components/Link/Link.css.d.ts +5 -0
- package/dist/components/Link/Link.css.js +14 -0
- package/dist/components/Link/Link.d.ts +19 -0
- package/dist/components/Link/Link.docs.d.ts +19 -0
- package/dist/components/Link/Link.docs.js +51 -0
- package/dist/components/Link/Link.js +39 -0
- package/dist/components/Link/index.d.ts +1 -0
- package/dist/components/Link/index.js +1 -0
- package/dist/components/List/List.css +39 -0
- package/dist/components/List/List.css.d.ts +5 -0
- package/dist/components/List/List.css.js +14 -0
- package/dist/components/List/List.d.ts +294 -0
- package/dist/components/List/List.docs.d.ts +19 -0
- package/dist/components/List/List.docs.js +43 -0
- package/dist/components/List/List.js +25 -0
- package/dist/components/List/index.d.ts +1 -0
- package/dist/components/List/index.js +1 -0
- package/dist/components/Menu/Menu.css +65 -0
- package/dist/components/Menu/Menu.css.d.ts +5 -0
- package/dist/components/Menu/Menu.css.js +9 -0
- package/dist/components/Menu/Menu.d.ts +60 -0
- package/dist/components/Menu/Menu.docs.d.ts +19 -0
- package/dist/components/Menu/Menu.docs.js +53 -0
- package/dist/components/Menu/Menu.js +192 -0
- package/dist/components/Menu/index.d.ts +1 -0
- package/dist/components/Menu/index.js +1 -0
- package/dist/components/NavBar/NavBar.css +187 -0
- package/dist/components/NavBar/NavBar.css.d.ts +16 -0
- package/dist/components/NavBar/NavBar.css.js +19 -0
- package/dist/components/NavBar/NavBar.d.ts +31 -0
- package/dist/components/NavBar/NavBar.docs.d.ts +19 -0
- package/dist/components/NavBar/NavBar.docs.js +53 -0
- package/dist/components/NavBar/NavBar.js +110 -0
- package/dist/components/NavBar/index.d.ts +1 -0
- package/dist/components/NavBar/index.js +1 -0
- package/dist/components/Popover/Popover.css +28 -0
- package/dist/components/Popover/Popover.css.d.ts +3 -0
- package/dist/components/Popover/Popover.css.js +8 -0
- package/dist/components/Popover/Popover.d.ts +40 -0
- package/dist/components/Popover/Popover.docs.d.ts +19 -0
- package/dist/components/Popover/Popover.docs.js +50 -0
- package/dist/components/Popover/Popover.js +69 -0
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/Popover/index.js +1 -0
- package/dist/components/Progress/Progress.css +106 -0
- package/dist/components/Progress/Progress.css.d.ts +10 -0
- package/dist/components/Progress/Progress.css.js +24 -0
- package/dist/components/Progress/Progress.d.ts +23 -0
- package/dist/components/Progress/Progress.docs.d.ts +19 -0
- package/dist/components/Progress/Progress.docs.js +43 -0
- package/dist/components/Progress/Progress.js +54 -0
- package/dist/components/Progress/index.d.ts +1 -0
- package/dist/components/Progress/index.js +1 -0
- package/dist/components/PromptInput/PromptInput.css +25 -0
- package/dist/components/PromptInput/PromptInput.css.d.ts +5 -0
- package/dist/components/PromptInput/PromptInput.css.js +8 -0
- package/dist/components/PromptInput/PromptInput.d.ts +65 -0
- package/dist/components/PromptInput/PromptInput.docs.d.ts +19 -0
- package/dist/components/PromptInput/PromptInput.docs.js +45 -0
- package/dist/components/PromptInput/PromptInput.js +91 -0
- package/dist/components/PromptInput/index.d.ts +1 -0
- package/dist/components/PromptInput/index.js +1 -0
- package/dist/components/Quote/Quote.css +31 -0
- package/dist/components/Quote/Quote.css.d.ts +5 -0
- package/dist/components/Quote/Quote.css.js +9 -0
- package/dist/components/Quote/Quote.d.ts +13 -0
- package/dist/components/Quote/Quote.docs.d.ts +19 -0
- package/dist/components/Quote/Quote.docs.js +30 -0
- package/dist/components/Quote/Quote.js +26 -0
- package/dist/components/Quote/index.d.ts +1 -0
- package/dist/components/Quote/index.js +1 -0
- package/dist/components/RadioGroup/RadioGroup.css +70 -0
- package/dist/components/RadioGroup/RadioGroup.css.d.ts +4 -0
- package/dist/components/RadioGroup/RadioGroup.css.js +12 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +32 -0
- package/dist/components/RadioGroup/RadioGroup.docs.d.ts +19 -0
- package/dist/components/RadioGroup/RadioGroup.docs.js +47 -0
- package/dist/components/RadioGroup/RadioGroup.js +85 -0
- package/dist/components/RadioGroup/index.d.ts +1 -0
- package/dist/components/RadioGroup/index.js +1 -0
- package/dist/components/Select/Select.css +17 -0
- package/dist/components/Select/Select.css.d.ts +3 -0
- package/dist/components/Select/Select.css.js +7 -0
- package/dist/components/Select/Select.d.ts +26 -0
- package/dist/components/Select/Select.docs.d.ts +19 -0
- package/dist/components/Select/Select.docs.js +35 -0
- package/dist/components/Select/Select.js +57 -0
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/Select/index.js +1 -0
- package/dist/components/SideNav/SideNav.css +74 -0
- package/dist/components/SideNav/SideNav.css.d.ts +7 -0
- package/dist/components/SideNav/SideNav.css.js +12 -0
- package/dist/components/SideNav/SideNav.d.ts +23 -0
- package/dist/components/SideNav/SideNav.docs.d.ts +19 -0
- package/dist/components/SideNav/SideNav.docs.js +43 -0
- package/dist/components/SideNav/SideNav.js +55 -0
- package/dist/components/SideNav/index.d.ts +1 -0
- package/dist/components/SideNav/index.js +1 -0
- package/dist/components/Skeleton/Skeleton.css +45 -0
- package/dist/components/Skeleton/Skeleton.css.d.ts +3 -0
- package/dist/components/Skeleton/Skeleton.css.js +11 -0
- package/dist/components/Skeleton/Skeleton.d.ts +25 -0
- package/dist/components/Skeleton/Skeleton.docs.d.ts +19 -0
- package/dist/components/Skeleton/Skeleton.docs.js +43 -0
- package/dist/components/Skeleton/Skeleton.js +27 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/Skeleton/index.js +1 -0
- package/dist/components/Spinner/Spinner.css +46 -0
- package/dist/components/Spinner/Spinner.css.d.ts +5 -0
- package/dist/components/Spinner/Spinner.css.js +13 -0
- package/dist/components/Spinner/Spinner.d.ts +24 -0
- package/dist/components/Spinner/Spinner.docs.d.ts +19 -0
- package/dist/components/Spinner/Spinner.docs.js +44 -0
- package/dist/components/Spinner/Spinner.js +46 -0
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/Spinner/index.js +1 -0
- package/dist/components/Stack/Stack.css +21 -0
- package/dist/components/Stack/Stack.css.d.ts +2 -0
- package/dist/components/Stack/Stack.css.js +10 -0
- package/dist/components/Stack/Stack.d.ts +296 -0
- package/dist/components/Stack/Stack.docs.d.ts +19 -0
- package/dist/components/Stack/Stack.docs.js +48 -0
- package/dist/components/Stack/Stack.js +13 -0
- package/dist/components/Stack/index.d.ts +1 -0
- package/dist/components/Stack/index.js +1 -0
- package/dist/components/Stat/Stat.css +59 -0
- package/dist/components/Stat/Stat.css.d.ts +13 -0
- package/dist/components/Stat/Stat.css.js +18 -0
- package/dist/components/Stat/Stat.d.ts +20 -0
- package/dist/components/Stat/Stat.docs.d.ts +19 -0
- package/dist/components/Stat/Stat.docs.js +52 -0
- package/dist/components/Stat/Stat.js +49 -0
- package/dist/components/Stat/index.d.ts +1 -0
- package/dist/components/Stat/index.js +1 -0
- package/dist/components/StreamingIndicator/StreamingIndicator.css +46 -0
- package/dist/components/StreamingIndicator/StreamingIndicator.css.d.ts +5 -0
- package/dist/components/StreamingIndicator/StreamingIndicator.css.js +13 -0
- package/dist/components/StreamingIndicator/StreamingIndicator.d.ts +22 -0
- package/dist/components/StreamingIndicator/StreamingIndicator.docs.d.ts +19 -0
- package/dist/components/StreamingIndicator/StreamingIndicator.docs.js +43 -0
- package/dist/components/StreamingIndicator/StreamingIndicator.js +31 -0
- package/dist/components/StreamingIndicator/index.d.ts +1 -0
- package/dist/components/StreamingIndicator/index.js +1 -0
- package/dist/components/Switch/Switch.css +89 -0
- package/dist/components/Switch/Switch.css.d.ts +4 -0
- package/dist/components/Switch/Switch.css.js +9 -0
- package/dist/components/Switch/Switch.d.ts +21 -0
- package/dist/components/Switch/Switch.docs.d.ts +19 -0
- package/dist/components/Switch/Switch.docs.js +36 -0
- package/dist/components/Switch/Switch.js +51 -0
- package/dist/components/Switch/index.d.ts +1 -0
- package/dist/components/Switch/index.js +1 -0
- package/dist/components/TabBar/TabBar.css +94 -0
- package/dist/components/TabBar/TabBar.css.d.ts +7 -0
- package/dist/components/TabBar/TabBar.css.js +12 -0
- package/dist/components/TabBar/TabBar.d.ts +23 -0
- package/dist/components/TabBar/TabBar.docs.d.ts +19 -0
- package/dist/components/TabBar/TabBar.docs.js +43 -0
- package/dist/components/TabBar/TabBar.js +50 -0
- package/dist/components/TabBar/index.d.ts +1 -0
- package/dist/components/TabBar/index.js +1 -0
- package/dist/components/Table/Table.css +75 -0
- package/dist/components/Table/Table.css.d.ts +10 -0
- package/dist/components/Table/Table.css.js +22 -0
- package/dist/components/Table/Table.d.ts +32 -0
- package/dist/components/Table/Table.docs.d.ts +19 -0
- package/dist/components/Table/Table.docs.js +49 -0
- package/dist/components/Table/Table.js +69 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Table/index.js +1 -0
- package/dist/components/Tabs/Tabs.css +79 -0
- package/dist/components/Tabs/Tabs.css.d.ts +6 -0
- package/dist/components/Tabs/Tabs.css.js +14 -0
- package/dist/components/Tabs/Tabs.d.ts +33 -0
- package/dist/components/Tabs/Tabs.docs.d.ts +19 -0
- package/dist/components/Tabs/Tabs.docs.js +56 -0
- package/dist/components/Tabs/Tabs.js +90 -0
- package/dist/components/Tabs/index.d.ts +1 -0
- package/dist/components/Tabs/index.js +1 -0
- package/dist/components/Tag/Tag.css +63 -0
- package/dist/components/Tag/Tag.css.d.ts +5 -0
- package/dist/components/Tag/Tag.css.js +10 -0
- package/dist/components/Tag/Tag.d.ts +13 -0
- package/dist/components/Tag/Tag.docs.d.ts +19 -0
- package/dist/components/Tag/Tag.docs.js +39 -0
- package/dist/components/Tag/Tag.js +35 -0
- package/dist/components/Tag/index.d.ts +1 -0
- package/dist/components/Tag/index.js +1 -0
- package/dist/components/Text/Text.css +86 -0
- package/dist/components/Text/Text.css.d.ts +6 -0
- package/dist/components/Text/Text.css.js +39 -0
- package/dist/components/Text/Text.d.ts +310 -0
- package/dist/components/Text/Text.docs.d.ts +19 -0
- package/dist/components/Text/Text.docs.js +52 -0
- package/dist/components/Text/Text.js +12 -0
- package/dist/components/Text/index.d.ts +1 -0
- package/dist/components/Text/index.js +1 -0
- package/dist/components/TextArea/TextArea.css +8 -0
- package/dist/components/TextArea/TextArea.css.d.ts +1 -0
- package/dist/components/TextArea/TextArea.css.js +5 -0
- package/dist/components/TextArea/TextArea.d.ts +15 -0
- package/dist/components/TextArea/TextArea.docs.d.ts +19 -0
- package/dist/components/TextArea/TextArea.docs.js +31 -0
- package/dist/components/TextArea/TextArea.js +33 -0
- package/dist/components/TextArea/index.d.ts +1 -0
- package/dist/components/TextArea/index.js +1 -0
- package/dist/components/TextField/TextField.d.ts +14 -0
- package/dist/components/TextField/TextField.docs.d.ts +19 -0
- package/dist/components/TextField/TextField.docs.js +59 -0
- package/dist/components/TextField/TextField.js +32 -0
- package/dist/components/TextField/index.d.ts +1 -0
- package/dist/components/TextField/index.js +1 -0
- package/dist/components/Timeline/Timeline.css +100 -0
- package/dist/components/Timeline/Timeline.css.d.ts +10 -0
- package/dist/components/Timeline/Timeline.css.js +15 -0
- package/dist/components/Timeline/Timeline.d.ts +22 -0
- package/dist/components/Timeline/Timeline.docs.d.ts +19 -0
- package/dist/components/Timeline/Timeline.docs.js +39 -0
- package/dist/components/Timeline/Timeline.js +42 -0
- package/dist/components/Timeline/index.d.ts +1 -0
- package/dist/components/Timeline/index.js +1 -0
- package/dist/components/Toast/Toast.css +106 -0
- package/dist/components/Toast/Toast.css.d.ts +11 -0
- package/dist/components/Toast/Toast.css.js +25 -0
- package/dist/components/Toast/Toast.d.ts +30 -0
- package/dist/components/Toast/Toast.docs.d.ts +19 -0
- package/dist/components/Toast/Toast.docs.js +49 -0
- package/dist/components/Toast/Toast.js +68 -0
- package/dist/components/Toast/ToastProvider.d.ts +12 -0
- package/dist/components/Toast/ToastProvider.js +140 -0
- package/dist/components/Toast/index.d.ts +3 -0
- package/dist/components/Toast/index.js +4 -0
- package/dist/components/Toast/toast-context.d.ts +21 -0
- package/dist/components/Toast/toast-context.js +11 -0
- package/dist/components/Tooltip/Tooltip.css +18 -0
- package/dist/components/Tooltip/Tooltip.css.d.ts +1 -0
- package/dist/components/Tooltip/Tooltip.css.js +5 -0
- package/dist/components/Tooltip/Tooltip.d.ts +45 -0
- package/dist/components/Tooltip/Tooltip.docs.d.ts +19 -0
- package/dist/components/Tooltip/Tooltip.docs.js +47 -0
- package/dist/components/Tooltip/Tooltip.js +93 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/components/Tooltip/index.js +1 -0
- package/dist/icons/index.d.ts +293 -0
- package/dist/icons/index.js +395 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.js +59 -0
- package/dist/internal/Field.d.ts +31 -0
- package/dist/internal/Field.js +54 -0
- package/dist/internal/field-ids.d.ts +7 -0
- package/dist/internal/field-ids.js +18 -0
- package/dist/internal/field.css +131 -0
- package/dist/internal/field.css.d.ts +16 -0
- package/dist/internal/field.css.js +22 -0
- package/dist/internal/floating-geometry.d.ts +42 -0
- package/dist/internal/floating-geometry.js +55 -0
- package/dist/internal/floating.css +36 -0
- package/dist/internal/floating.css.d.ts +8 -0
- package/dist/internal/floating.css.js +6 -0
- package/dist/internal/floating.d.ts +27 -0
- package/dist/internal/floating.js +118 -0
- package/dist/internal/useControllableState.d.ts +16 -0
- package/dist/internal/useControllableState.js +28 -0
- package/dist/internal/useOverflow.d.ts +7 -0
- package/dist/internal/useOverflow.js +24 -0
- package/dist/internal/usePopover.d.ts +28 -0
- package/dist/internal/usePopover.js +91 -0
- package/dist/manifest.json +12308 -0
- package/dist/patterns/dashboard-overview.docs.d.ts +22 -0
- package/dist/patterns/dashboard-overview.docs.js +80 -0
- package/dist/patterns/empty-state.docs.d.ts +22 -0
- package/dist/patterns/empty-state.docs.js +60 -0
- package/dist/patterns/index.d.ts +6 -0
- package/dist/patterns/index.js +14 -0
- package/dist/patterns/profile-card.docs.d.ts +22 -0
- package/dist/patterns/profile-card.docs.js +72 -0
- package/dist/patterns/settings-page.docs.d.ts +22 -0
- package/dist/patterns/settings-page.docs.js +76 -0
- package/dist/patterns/sign-in-form.docs.d.ts +22 -0
- package/dist/patterns/sign-in-form.docs.js +84 -0
- package/dist/primitives/VisuallyHidden.d.ts +13 -0
- package/dist/primitives/VisuallyHidden.js +18 -0
- package/dist/providers/LinkProvider.d.ts +18 -0
- package/dist/providers/LinkProvider.js +23 -0
- package/dist/providers/StringsProvider.d.ts +14 -0
- package/dist/providers/StringsProvider.js +25 -0
- package/dist/providers/link-context.d.ts +12 -0
- package/dist/providers/link-context.js +15 -0
- package/dist/providers/strings.d.ts +64 -0
- package/dist/providers/strings.js +38 -0
- package/dist/registry/gaps.d.ts +30 -0
- package/dist/registry/gaps.js +208 -0
- package/dist/registry/generated.d.ts +5 -0
- package/dist/registry/generated.js +2821 -0
- package/dist/registry/index.d.ts +36 -0
- package/dist/registry/index.js +201 -0
- package/dist/registry/types.d.ts +84 -0
- package/dist/styles/base.css +9 -0
- package/dist/styles/base.css.d.ts +1 -0
- package/dist/styles/base.css.js +1 -0
- package/dist/styles/layout.css +33 -0
- package/dist/styles/layout.css.d.ts +1 -0
- package/dist/styles/layout.css.js +17 -0
- package/dist/styles/shared.css +16 -0
- package/dist/styles/shared.css.d.ts +35 -0
- package/dist/styles/shared.css.js +5 -0
- package/dist/styles.css +3406 -0
- package/dist/themes/blueprint.css +115 -0
- package/dist/themes/contrast.d.ts +26 -0
- package/dist/themes/contrast.js +114 -0
- package/dist/themes/define.d.ts +9 -0
- package/dist/themes/define.js +29 -0
- package/dist/themes/dtcg.d.ts +126 -0
- package/dist/themes/dtcg.js +268 -0
- package/dist/themes/index.d.ts +19 -0
- package/dist/themes/index.js +21 -0
- package/dist/themes/letterpress.css +115 -0
- package/dist/themes/letterpress.d.ts +7 -0
- package/dist/themes/letterpress.js +187 -0
- package/dist/themes/presets/blueprint.d.ts +6 -0
- package/dist/themes/presets/blueprint.js +183 -0
- package/dist/themes/runtime/browser.d.ts +47 -0
- package/dist/themes/runtime/browser.js +164 -0
- package/dist/themes/runtime/cache.d.ts +43 -0
- package/dist/themes/runtime/cache.js +87 -0
- package/dist/themes/runtime/css.d.ts +43 -0
- package/dist/themes/runtime/css.js +89 -0
- package/dist/themes/runtime/diff.d.ts +22 -0
- package/dist/themes/runtime/diff.js +43 -0
- package/dist/themes/types.d.ts +59 -0
- package/dist/themes/values.d.ts +12 -0
- package/dist/themes/values.js +40 -0
- package/dist/tokens/blueprint.dark.tokens.json +1361 -0
- package/dist/tokens/blueprint.light.tokens.json +1361 -0
- package/dist/tokens/contract.d.ts +252 -0
- package/dist/tokens/contract.js +249 -0
- package/dist/tokens/index.d.ts +6 -0
- package/dist/tokens/index.js +1 -0
- package/dist/tokens/letterpress.dark.tokens.json +1391 -0
- package/dist/tokens/letterpress.light.tokens.json +1391 -0
- package/dist/tokens/tokens.css +117 -0
- package/dist/tokens/tokens.css.d.ts +128 -0
- package/dist/tokens/tokens.css.js +121 -0
- package/dist/utils/cx.d.ts +7 -0
- package/dist/utils/cx.js +14 -0
- package/dist/utils/space.d.ts +5 -0
- package/dist/utils/space.js +7 -0
- package/package.json +104 -3
|
@@ -0,0 +1,1411 @@
|
|
|
1
|
+
import { Accordion } from "../components/Accordion/Accordion.js";
|
|
2
|
+
import { Alert } from "../components/Alert/Alert.js";
|
|
3
|
+
import { Avatar } from "../components/Avatar/Avatar.js";
|
|
4
|
+
import { Badge } from "../components/Badge/Badge.js";
|
|
5
|
+
import { Breadcrumbs } from "../components/Breadcrumbs/Breadcrumbs.js";
|
|
6
|
+
import { Button } from "../components/Button/Button.js";
|
|
7
|
+
import { Card } from "../components/Card/Card.js";
|
|
8
|
+
import { Checkbox } from "../components/Checkbox/Checkbox.js";
|
|
9
|
+
import { Code } from "../components/Code/Code.js";
|
|
10
|
+
import { CodeBlock } from "../components/CodeBlock/CodeBlock.js";
|
|
11
|
+
import { Dialog } from "../components/Dialog/Dialog.js";
|
|
12
|
+
import { Divider } from "../components/Divider/Divider.js";
|
|
13
|
+
import { Grid } from "../components/Grid/Grid.js";
|
|
14
|
+
import { Heading } from "../components/Heading/Heading.js";
|
|
15
|
+
import { Icon } from "../components/Icon/Icon.js";
|
|
16
|
+
import { IconButton } from "../components/IconButton/IconButton.js";
|
|
17
|
+
import { Image } from "../components/Image/Image.js";
|
|
18
|
+
import { Inline } from "../components/Inline/Inline.js";
|
|
19
|
+
import { Link } from "../components/Link/Link.js";
|
|
20
|
+
import { List } from "../components/List/List.js";
|
|
21
|
+
import { Menu } from "../components/Menu/Menu.js";
|
|
22
|
+
import { NavBar } from "../components/NavBar/NavBar.js";
|
|
23
|
+
import { Popover } from "../components/Popover/Popover.js";
|
|
24
|
+
import { Progress } from "../components/Progress/Progress.js";
|
|
25
|
+
import { Quote } from "../components/Quote/Quote.js";
|
|
26
|
+
import { RadioGroup } from "../components/RadioGroup/RadioGroup.js";
|
|
27
|
+
import { Select } from "../components/Select/Select.js";
|
|
28
|
+
import { SideNav } from "../components/SideNav/SideNav.js";
|
|
29
|
+
import { Skeleton } from "../components/Skeleton/Skeleton.js";
|
|
30
|
+
import { Spinner } from "../components/Spinner/Spinner.js";
|
|
31
|
+
import { Stack } from "../components/Stack/Stack.js";
|
|
32
|
+
import { Stat } from "../components/Stat/Stat.js";
|
|
33
|
+
import { Switch } from "../components/Switch/Switch.js";
|
|
34
|
+
import { TabBar } from "../components/TabBar/TabBar.js";
|
|
35
|
+
import { Table } from "../components/Table/Table.js";
|
|
36
|
+
import { Tabs } from "../components/Tabs/Tabs.js";
|
|
37
|
+
import { Tag } from "../components/Tag/Tag.js";
|
|
38
|
+
import { Text } from "../components/Text/Text.js";
|
|
39
|
+
import { TextArea } from "../components/TextArea/TextArea.js";
|
|
40
|
+
import { TextField } from "../components/TextField/TextField.js";
|
|
41
|
+
import { Timeline } from "../components/Timeline/Timeline.js";
|
|
42
|
+
import { Tooltip } from "../components/Tooltip/Tooltip.js";
|
|
43
|
+
import { isIconName } from "../icons/index.js";
|
|
44
|
+
import { basicIconMap } from "./catalog.js";
|
|
45
|
+
import { humanize, isBinding, testPattern, toText } from "./functions.js";
|
|
46
|
+
import { isInternalHref, safeHref, safeImage } from "./links.js";
|
|
47
|
+
import { errorText, fieldset, imageSize, inlineList, inspect, legend, notice, placeholder, prose, proseList, range, rangeValue, slider, sliderLabel, surface, svgIcon, weighted } from "./Surface.css.js";
|
|
48
|
+
import { safeRegExp } from "./validate.js";
|
|
49
|
+
import { Component, createContext, useContext, useId, useMemo, useState, useSyncExternalStore } from "react";
|
|
50
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
51
|
+
// src/a2ui/Surface.tsx
|
|
52
|
+
/**
|
|
53
|
+
* Renders one A2UI surface with Derelicious components. Every catalog type
|
|
54
|
+
* maps to a component from the system, so generated UI always looks like the
|
|
55
|
+
* rest of the site and follows the active preset and mode.
|
|
56
|
+
*
|
|
57
|
+
* The renderer never throws: unknown or invalid components, cycles, and
|
|
58
|
+
* render errors become a small inline notice, and components that have not
|
|
59
|
+
* streamed in yet show a placeholder.
|
|
60
|
+
*/
|
|
61
|
+
var SurfaceContext = createContext(null);
|
|
62
|
+
/** Set by Modal so its trigger button opens the dialog. */
|
|
63
|
+
var ModalTriggerContext = createContext(null);
|
|
64
|
+
function useSurface() {
|
|
65
|
+
const value = useContext(SurfaceContext);
|
|
66
|
+
if (!value) throw new Error("A2UI nodes must render inside A2uiSurface");
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
function defaultOpenUrl(url) {
|
|
70
|
+
const href = safeHref(url);
|
|
71
|
+
if (!href || typeof window === "undefined") return;
|
|
72
|
+
if (isInternalHref(href)) window.location.assign(href);
|
|
73
|
+
else window.open(href, "_blank", "noopener,noreferrer");
|
|
74
|
+
}
|
|
75
|
+
function A2uiSurface({ processor, surfaceId, onAction, onToast, onOpenUrl, handlesEvent, onRenderError, headingLevel = 2, streaming = false, debug = false, inspectable = false, allowRemoteImages = false, landmarkSuffix, className }) {
|
|
76
|
+
useSyncExternalStore(processor.subscribe, processor.getVersion, processor.getVersion);
|
|
77
|
+
const value = useMemo(() => ({
|
|
78
|
+
processor,
|
|
79
|
+
surfaceId,
|
|
80
|
+
headingLevel,
|
|
81
|
+
streaming,
|
|
82
|
+
debug,
|
|
83
|
+
inspectable,
|
|
84
|
+
allowRemoteImages,
|
|
85
|
+
landmarkSuffix,
|
|
86
|
+
handlesEvent,
|
|
87
|
+
onRenderError,
|
|
88
|
+
dispatch(component, action, scope) {
|
|
89
|
+
const resolved = processor.resolveAction(surfaceId, component.id, action, scope);
|
|
90
|
+
if (!resolved) return;
|
|
91
|
+
if (resolved.type === "event") onAction?.(resolved.event);
|
|
92
|
+
else if (resolved.type === "toast") onToast?.(resolved.toast);
|
|
93
|
+
else if (resolved.type === "openUrl") (onOpenUrl ?? defaultOpenUrl)(resolved.url);
|
|
94
|
+
}
|
|
95
|
+
}), [
|
|
96
|
+
processor,
|
|
97
|
+
surfaceId,
|
|
98
|
+
headingLevel,
|
|
99
|
+
streaming,
|
|
100
|
+
debug,
|
|
101
|
+
inspectable,
|
|
102
|
+
allowRemoteImages,
|
|
103
|
+
landmarkSuffix,
|
|
104
|
+
handlesEvent,
|
|
105
|
+
onRenderError,
|
|
106
|
+
onAction,
|
|
107
|
+
onToast,
|
|
108
|
+
onOpenUrl
|
|
109
|
+
]);
|
|
110
|
+
const surface$1 = processor.getSurface(surfaceId);
|
|
111
|
+
const classes = [surface, className].filter(Boolean).join(" ");
|
|
112
|
+
if (!surface$1) return streaming ? /* @__PURE__ */ jsx("div", {
|
|
113
|
+
className: classes,
|
|
114
|
+
"aria-busy": "true",
|
|
115
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
116
|
+
variant: "rect",
|
|
117
|
+
width: "100%",
|
|
118
|
+
height: "1.5rem",
|
|
119
|
+
className: placeholder
|
|
120
|
+
})
|
|
121
|
+
}) : null;
|
|
122
|
+
return /* @__PURE__ */ jsx(SurfaceContext.Provider, {
|
|
123
|
+
value,
|
|
124
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
125
|
+
className: classes,
|
|
126
|
+
"data-a2ui-surface": surfaceId,
|
|
127
|
+
"aria-busy": streaming || void 0,
|
|
128
|
+
children: /* @__PURE__ */ jsx(A2uiNode, {
|
|
129
|
+
childRef: {
|
|
130
|
+
id: "root",
|
|
131
|
+
scope: "",
|
|
132
|
+
key: "root@"
|
|
133
|
+
},
|
|
134
|
+
trail: []
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Problems show as notices only where someone can act on them: in debug
|
|
141
|
+
* mode and in inspectable tools like the prototyping canvas. Visitors see
|
|
142
|
+
* the rest of the answer without the broken part.
|
|
143
|
+
*/
|
|
144
|
+
function Notice({ title, detail }) {
|
|
145
|
+
const { debug, inspectable } = useSurface();
|
|
146
|
+
if (!debug && !inspectable) return null;
|
|
147
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
148
|
+
className: notice,
|
|
149
|
+
role: "note",
|
|
150
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
151
|
+
name: "warning",
|
|
152
|
+
size: "sm"
|
|
153
|
+
}), /* @__PURE__ */ jsx("span", { children: debug && detail ? `${title}: ${detail}` : title })]
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
var NodeBoundary = class extends Component {
|
|
157
|
+
state = { error: null };
|
|
158
|
+
static getDerivedStateFromError(error) {
|
|
159
|
+
return { error };
|
|
160
|
+
}
|
|
161
|
+
componentDidCatch(error, info) {
|
|
162
|
+
if (typeof console !== "undefined") console.warn(`A2UI: "${this.props.id}" failed to render`, error, info);
|
|
163
|
+
this.props.onError?.(this.props.id, error.message);
|
|
164
|
+
}
|
|
165
|
+
render() {
|
|
166
|
+
if (this.state.error) return /* @__PURE__ */ jsx(Notice, {
|
|
167
|
+
title: `Couldn’t show "${this.props.id}"`,
|
|
168
|
+
detail: this.state.error.message
|
|
169
|
+
});
|
|
170
|
+
return this.props.children;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
function A2uiNode({ childRef, trail }) {
|
|
174
|
+
const { processor, surfaceId, streaming, inspectable, onRenderError } = useSurface();
|
|
175
|
+
const surface = processor.getSurface(surfaceId);
|
|
176
|
+
const component = surface?.components.get(childRef.id);
|
|
177
|
+
const marker = `${childRef.id}@${childRef.scope}`;
|
|
178
|
+
if (!component) return streaming ? /* @__PURE__ */ jsx(Skeleton, {
|
|
179
|
+
variant: "rect",
|
|
180
|
+
width: "100%",
|
|
181
|
+
height: "1.5rem",
|
|
182
|
+
className: placeholder
|
|
183
|
+
}) : /* @__PURE__ */ jsx(Notice, { title: `Missing "${childRef.id}"` });
|
|
184
|
+
if (trail.includes(marker)) return /* @__PURE__ */ jsx(Notice, {
|
|
185
|
+
title: `"${childRef.id}" contains itself`,
|
|
186
|
+
detail: [...trail, marker].join(" → ")
|
|
187
|
+
});
|
|
188
|
+
if (trail.length >= 40) return /* @__PURE__ */ jsx(Notice, { title: "Nested too deeply" });
|
|
189
|
+
const issues = surface?.componentIssues.get(childRef.id);
|
|
190
|
+
if (issues && issues.length > 0) return /* @__PURE__ */ jsx(Notice, {
|
|
191
|
+
title: `Couldn’t show "${childRef.id}"`,
|
|
192
|
+
detail: issues.join(" ")
|
|
193
|
+
});
|
|
194
|
+
const node = /* @__PURE__ */ jsx(NodeBoundary, {
|
|
195
|
+
id: childRef.id,
|
|
196
|
+
onError: onRenderError ? (componentId, message) => onRenderError({
|
|
197
|
+
surfaceId,
|
|
198
|
+
componentId,
|
|
199
|
+
message: `"${componentId}" failed to render: ${message}`
|
|
200
|
+
}) : void 0,
|
|
201
|
+
children: /* @__PURE__ */ jsx(Render, {
|
|
202
|
+
component,
|
|
203
|
+
scope: childRef.scope,
|
|
204
|
+
trail: [...trail, marker]
|
|
205
|
+
})
|
|
206
|
+
});
|
|
207
|
+
return inspectable ? /* @__PURE__ */ jsx("div", {
|
|
208
|
+
className: inspect,
|
|
209
|
+
"data-a2ui-id": childRef.id,
|
|
210
|
+
"data-a2ui-component": component.component,
|
|
211
|
+
"data-a2ui-scope": childRef.scope,
|
|
212
|
+
children: node
|
|
213
|
+
}) : node;
|
|
214
|
+
}
|
|
215
|
+
/** Render a ChildList prop. Weighted children get a flex wrapper. */
|
|
216
|
+
function Children$1({ list, scope, trail, weighted: weighted$1 = false }) {
|
|
217
|
+
const { processor, surfaceId } = useSurface();
|
|
218
|
+
const refs = processor.childrenOf(surfaceId, list, scope);
|
|
219
|
+
return /* @__PURE__ */ jsx(Fragment, { children: refs.map((ref) => {
|
|
220
|
+
const node = /* @__PURE__ */ jsx(A2uiNode, {
|
|
221
|
+
childRef: ref,
|
|
222
|
+
trail
|
|
223
|
+
}, ref.key);
|
|
224
|
+
const weight = weighted$1 ? processor.getComponent(surfaceId, ref.id)?.weight : void 0;
|
|
225
|
+
return typeof weight === "number" && weight > 0 ? /* @__PURE__ */ jsx("div", {
|
|
226
|
+
className: weighted,
|
|
227
|
+
style: { flexGrow: weight },
|
|
228
|
+
children: node
|
|
229
|
+
}, ref.key) : node;
|
|
230
|
+
}) });
|
|
231
|
+
}
|
|
232
|
+
function One({ id, scope, trail }) {
|
|
233
|
+
if (typeof id !== "string") return null;
|
|
234
|
+
return /* @__PURE__ */ jsx(A2uiNode, {
|
|
235
|
+
childRef: {
|
|
236
|
+
id,
|
|
237
|
+
scope,
|
|
238
|
+
key: `${id}@${scope}`
|
|
239
|
+
},
|
|
240
|
+
trail
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function childArray(list, scope, trail, processor, surfaceId) {
|
|
244
|
+
return processor.childrenOf(surfaceId, list, scope).map((ref) => /* @__PURE__ */ jsx(A2uiNode, {
|
|
245
|
+
childRef: ref,
|
|
246
|
+
trail
|
|
247
|
+
}, ref.key));
|
|
248
|
+
}
|
|
249
|
+
function useResolve(scope) {
|
|
250
|
+
const { processor, surfaceId } = useSurface();
|
|
251
|
+
return {
|
|
252
|
+
value: (value) => processor.resolve(surfaceId, value, scope),
|
|
253
|
+
text: (value) => value === void 0 ? "" : processor.resolveText(surfaceId, value, scope),
|
|
254
|
+
optional: (value) => value === void 0 ? void 0 : processor.resolveText(surfaceId, value, scope) || void 0
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* A value an input reads and writes. Bound values write to the data model;
|
|
259
|
+
* literal values keep local state, starting from the literal.
|
|
260
|
+
*/
|
|
261
|
+
function useBound(binding, scope, fallback) {
|
|
262
|
+
const { processor, surfaceId } = useSurface();
|
|
263
|
+
const [local, setLocal] = useState(() => isBinding(binding) ? void 0 : processor.resolve(surfaceId, binding, scope));
|
|
264
|
+
if (isBinding(binding)) return [processor.getData(surfaceId, binding.path, scope) ?? fallback, (next) => processor.setData(surfaceId, binding.path, next, scope)];
|
|
265
|
+
return [local ?? fallback, (next) => setLocal(next)];
|
|
266
|
+
}
|
|
267
|
+
function iconName(value) {
|
|
268
|
+
if (typeof value !== "string") return null;
|
|
269
|
+
if (isIconName(value)) return value;
|
|
270
|
+
const mapped = Object.hasOwn(basicIconMap, value) ? basicIconMap[value] : void 0;
|
|
271
|
+
return mapped && isIconName(mapped) ? mapped : null;
|
|
272
|
+
}
|
|
273
|
+
function clampLevel(level) {
|
|
274
|
+
return Math.min(4, Math.max(1, Math.round(level)));
|
|
275
|
+
}
|
|
276
|
+
var gapStep = (value, fallback) => typeof value === "number" && [
|
|
277
|
+
0,
|
|
278
|
+
1,
|
|
279
|
+
2,
|
|
280
|
+
3,
|
|
281
|
+
4,
|
|
282
|
+
5,
|
|
283
|
+
6,
|
|
284
|
+
8
|
|
285
|
+
].includes(value) ? value : fallback;
|
|
286
|
+
function inline(text, keyPrefix) {
|
|
287
|
+
const out = [];
|
|
288
|
+
const pattern = /(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*\s][^*]*\*)|(_[^_\s][^_]*_)|(\[[^\]]+\]\([^)]+\))/g;
|
|
289
|
+
let last = 0;
|
|
290
|
+
let index = 0;
|
|
291
|
+
for (const match of text.matchAll(pattern)) {
|
|
292
|
+
const start = match.index ?? 0;
|
|
293
|
+
if (start > last) out.push(text.slice(last, start));
|
|
294
|
+
const token = match[0];
|
|
295
|
+
const key = `${keyPrefix}-${index}`;
|
|
296
|
+
index += 1;
|
|
297
|
+
if (match[1]) out.push(/* @__PURE__ */ jsx(Code, { children: token.slice(1, -1) }, key));
|
|
298
|
+
else if (match[2]) out.push(/* @__PURE__ */ jsx("strong", { children: token.slice(2, -2) }, key));
|
|
299
|
+
else if (match[3] || match[4]) out.push(/* @__PURE__ */ jsx("em", { children: token.slice(1, -1) }, key));
|
|
300
|
+
else out.push(token.slice(1, token.indexOf("]")));
|
|
301
|
+
last = start + token.length;
|
|
302
|
+
}
|
|
303
|
+
if (last < text.length) out.push(text.slice(last));
|
|
304
|
+
return out;
|
|
305
|
+
}
|
|
306
|
+
/** True when the text needs block Markdown: several paragraphs or a list. */
|
|
307
|
+
function isRich(text) {
|
|
308
|
+
return /\n\s*\n|^\s*[-*] |^#{1,6} /m.test(text);
|
|
309
|
+
}
|
|
310
|
+
function MarkdownText({ text, tone, size }) {
|
|
311
|
+
const blocks = text.trim().split(/\n\s*\n/);
|
|
312
|
+
return /* @__PURE__ */ jsx("div", {
|
|
313
|
+
className: prose,
|
|
314
|
+
children: blocks.map((block, blockIndex) => {
|
|
315
|
+
const lines = block.split("\n");
|
|
316
|
+
const key = `b${blockIndex}`;
|
|
317
|
+
if (lines.every((line) => /^\s*[-*] /.test(line))) return /* @__PURE__ */ jsx("ul", {
|
|
318
|
+
className: proseList,
|
|
319
|
+
children: lines.map((line, lineIndex) => /* @__PURE__ */ jsx(Text, {
|
|
320
|
+
as: "li",
|
|
321
|
+
tone,
|
|
322
|
+
size,
|
|
323
|
+
children: inline(line.replace(/^\s*[-*] /, ""), `${key}-${lineIndex}`)
|
|
324
|
+
}, `${key}-${lineIndex}`))
|
|
325
|
+
}, key);
|
|
326
|
+
const heading = /^#{1,6} (.*)$/.exec(block);
|
|
327
|
+
if (heading && lines.length === 1) return /* @__PURE__ */ jsx(Text, {
|
|
328
|
+
weight: "semibold",
|
|
329
|
+
tone,
|
|
330
|
+
size,
|
|
331
|
+
children: inline(heading[1], key)
|
|
332
|
+
}, key);
|
|
333
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
334
|
+
tone,
|
|
335
|
+
size,
|
|
336
|
+
children: inline(lines.join(" "), key)
|
|
337
|
+
}, key);
|
|
338
|
+
})
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
var headingSizes = {
|
|
342
|
+
1: "2xl",
|
|
343
|
+
2: "xl",
|
|
344
|
+
3: "lg",
|
|
345
|
+
4: "md"
|
|
346
|
+
};
|
|
347
|
+
/** Run both handlers, ours first. */
|
|
348
|
+
function chain(own, extra) {
|
|
349
|
+
if (typeof extra !== "function") return own;
|
|
350
|
+
if (!own) return extra;
|
|
351
|
+
return (...args) => {
|
|
352
|
+
own(...args);
|
|
353
|
+
extra(...args);
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function Render(props) {
|
|
357
|
+
const type = props.component.component;
|
|
358
|
+
const Renderer = Object.hasOwn(renderers, type) ? renderers[type] : void 0;
|
|
359
|
+
if (!Renderer) return /* @__PURE__ */ jsx(Notice, { title: `Unknown component "${props.component.component}"` });
|
|
360
|
+
return /* @__PURE__ */ jsx(Renderer, { ...props });
|
|
361
|
+
}
|
|
362
|
+
function TextNode({ component, scope }) {
|
|
363
|
+
const { headingLevel } = useSurface();
|
|
364
|
+
const text = useResolve(scope).text(component.text);
|
|
365
|
+
const variant = typeof component.variant === "string" ? component.variant : "body";
|
|
366
|
+
const tone = component.tone ?? void 0;
|
|
367
|
+
const heading = /^h([1-5])$/.exec(variant);
|
|
368
|
+
if (heading) {
|
|
369
|
+
const depth = Number(heading[1]);
|
|
370
|
+
const plain = text.replace(/^#{1,6}\s+/, "");
|
|
371
|
+
if (depth === 5) return /* @__PURE__ */ jsx(Text, {
|
|
372
|
+
weight: "semibold",
|
|
373
|
+
tone,
|
|
374
|
+
children: inline(plain, component.id)
|
|
375
|
+
});
|
|
376
|
+
return /* @__PURE__ */ jsx(Heading, {
|
|
377
|
+
level: clampLevel(headingLevel + depth - 1),
|
|
378
|
+
size: headingSizes[depth],
|
|
379
|
+
tone: tone === "accent" ? "accent" : "default",
|
|
380
|
+
children: inline(plain, component.id)
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
if (variant === "caption") return isRich(text) ? /* @__PURE__ */ jsx(MarkdownText, {
|
|
384
|
+
text,
|
|
385
|
+
tone: tone ?? "muted",
|
|
386
|
+
size: "sm"
|
|
387
|
+
}) : /* @__PURE__ */ jsx(Text, {
|
|
388
|
+
size: "sm",
|
|
389
|
+
tone: tone ?? "muted",
|
|
390
|
+
children: inline(text, component.id)
|
|
391
|
+
});
|
|
392
|
+
if (variant === "lede" || variant === "eyebrow") return /* @__PURE__ */ jsx(Text, {
|
|
393
|
+
variant,
|
|
394
|
+
tone,
|
|
395
|
+
children: inline(text, component.id)
|
|
396
|
+
});
|
|
397
|
+
return isRich(text) ? /* @__PURE__ */ jsx(MarkdownText, {
|
|
398
|
+
text,
|
|
399
|
+
tone
|
|
400
|
+
}) : /* @__PURE__ */ jsx(Text, {
|
|
401
|
+
tone,
|
|
402
|
+
children: inline(text, component.id)
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
var imageAspect = {
|
|
406
|
+
icon: "1/1",
|
|
407
|
+
avatar: "1/1",
|
|
408
|
+
smallFeature: "1/1",
|
|
409
|
+
mediumFeature: "4/3",
|
|
410
|
+
largeFeature: "16/9",
|
|
411
|
+
header: "21/9"
|
|
412
|
+
};
|
|
413
|
+
function ImageNode({ component, scope }) {
|
|
414
|
+
const { allowRemoteImages } = useSurface();
|
|
415
|
+
const resolve = useResolve(scope);
|
|
416
|
+
const variant = typeof component.variant === "string" && Object.hasOwn(imageAspect, component.variant) ? component.variant : "mediumFeature";
|
|
417
|
+
const fit = component.fit === "contain" || component.fit === "none" || component.fit === "scaleDown" ? "contain" : "cover";
|
|
418
|
+
return /* @__PURE__ */ jsx(Image, {
|
|
419
|
+
src: safeImage(resolve.value(component.url), { allowRemote: allowRemoteImages }),
|
|
420
|
+
alt: resolve.text(component.description),
|
|
421
|
+
aspect: imageAspect[variant],
|
|
422
|
+
fit,
|
|
423
|
+
radius: variant === "icon" ? "md" : "lg",
|
|
424
|
+
className: imageSize[variant]
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
function IconNode({ component, scope }) {
|
|
428
|
+
const resolve = useResolve(scope);
|
|
429
|
+
const label = resolve.optional(component.accessibility?.label);
|
|
430
|
+
const raw = isBinding(component.name) ? resolve.value(component.name) : component.name;
|
|
431
|
+
if (raw && typeof raw === "object" && typeof raw.svgPath === "string") return /* @__PURE__ */ jsx("svg", {
|
|
432
|
+
viewBox: "0 0 24 24",
|
|
433
|
+
className: svgIcon,
|
|
434
|
+
role: label ? "img" : void 0,
|
|
435
|
+
"aria-label": label,
|
|
436
|
+
"aria-hidden": label ? void 0 : true,
|
|
437
|
+
focusable: "false",
|
|
438
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
439
|
+
d: raw.svgPath,
|
|
440
|
+
fill: "currentColor"
|
|
441
|
+
})
|
|
442
|
+
});
|
|
443
|
+
return /* @__PURE__ */ jsx(Icon, {
|
|
444
|
+
name: iconName(raw) ?? "sparkle",
|
|
445
|
+
label
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function MediaFallback({ component, scope }) {
|
|
449
|
+
const resolve = useResolve(scope);
|
|
450
|
+
const href = safeHref(resolve.value(component.url));
|
|
451
|
+
const label = resolve.optional(component.description) ?? (component.component === "Video" ? "Open the video" : "Open the audio");
|
|
452
|
+
if (!href) return /* @__PURE__ */ jsx(Notice, { title: label });
|
|
453
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
454
|
+
href,
|
|
455
|
+
variant: "standalone",
|
|
456
|
+
external: href.startsWith("https:"),
|
|
457
|
+
children: label
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
var rowJustify = {
|
|
461
|
+
start: "start",
|
|
462
|
+
center: "center",
|
|
463
|
+
end: "end",
|
|
464
|
+
spaceBetween: "between",
|
|
465
|
+
spaceAround: "between",
|
|
466
|
+
spaceEvenly: "between",
|
|
467
|
+
stretch: "start"
|
|
468
|
+
};
|
|
469
|
+
function RowNode({ component, scope, trail }) {
|
|
470
|
+
const justify = rowJustify[component.justify] ?? "start";
|
|
471
|
+
const align = [
|
|
472
|
+
"start",
|
|
473
|
+
"center",
|
|
474
|
+
"end",
|
|
475
|
+
"stretch"
|
|
476
|
+
].includes(String(component.align)) ? component.align : "stretch";
|
|
477
|
+
return /* @__PURE__ */ jsx(Inline, {
|
|
478
|
+
gap: gapStep(component.gap, 3),
|
|
479
|
+
justify,
|
|
480
|
+
align,
|
|
481
|
+
wrap: component.wrap !== false,
|
|
482
|
+
children: /* @__PURE__ */ jsx(Children$1, {
|
|
483
|
+
list: component.children,
|
|
484
|
+
scope,
|
|
485
|
+
trail,
|
|
486
|
+
weighted: true
|
|
487
|
+
})
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
function ColumnNode({ component, scope, trail }) {
|
|
491
|
+
const align = [
|
|
492
|
+
"start",
|
|
493
|
+
"center",
|
|
494
|
+
"end",
|
|
495
|
+
"stretch"
|
|
496
|
+
].includes(String(component.align)) ? component.align : "stretch";
|
|
497
|
+
return /* @__PURE__ */ jsx(Stack, {
|
|
498
|
+
gap: gapStep(component.gap, 3),
|
|
499
|
+
align,
|
|
500
|
+
children: /* @__PURE__ */ jsx(Children$1, {
|
|
501
|
+
list: component.children,
|
|
502
|
+
scope,
|
|
503
|
+
trail,
|
|
504
|
+
weighted: true
|
|
505
|
+
})
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
function ListNode({ component, scope, trail }) {
|
|
509
|
+
const { processor, surfaceId } = useSurface();
|
|
510
|
+
const items = childArray(component.children, scope, trail, processor, surfaceId);
|
|
511
|
+
if (component.direction === "horizontal") return /* @__PURE__ */ jsx(Inline, {
|
|
512
|
+
as: "ul",
|
|
513
|
+
gap: gapStep(component.gap, 2),
|
|
514
|
+
className: inlineList,
|
|
515
|
+
children: items.map((item, index) => /* @__PURE__ */ jsx("li", { children: item }, index))
|
|
516
|
+
});
|
|
517
|
+
const marker = [
|
|
518
|
+
"none",
|
|
519
|
+
"bullet",
|
|
520
|
+
"number",
|
|
521
|
+
"check"
|
|
522
|
+
].includes(String(component.marker)) ? component.marker : "none";
|
|
523
|
+
return /* @__PURE__ */ jsx(List, {
|
|
524
|
+
items,
|
|
525
|
+
marker,
|
|
526
|
+
gap: gapStep(component.gap, 2)
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
function CardNode({ component, scope, trail }) {
|
|
530
|
+
const { headingLevel } = useSurface();
|
|
531
|
+
const resolve = useResolve(scope);
|
|
532
|
+
const title = resolve.optional(component.title);
|
|
533
|
+
const href = title ? safeHref(resolve.value(component.href)) : void 0;
|
|
534
|
+
const variant = [
|
|
535
|
+
"outlined",
|
|
536
|
+
"filled",
|
|
537
|
+
"elevated"
|
|
538
|
+
].includes(String(component.variant)) ? component.variant : "outlined";
|
|
539
|
+
return /* @__PURE__ */ jsx(Card, {
|
|
540
|
+
as: "div",
|
|
541
|
+
title,
|
|
542
|
+
titleLevel: Math.min(4, Math.max(2, headingLevel + 1)),
|
|
543
|
+
eyebrow: resolve.optional(component.eyebrow),
|
|
544
|
+
href,
|
|
545
|
+
variant,
|
|
546
|
+
children: /* @__PURE__ */ jsx(One, {
|
|
547
|
+
id: component.child,
|
|
548
|
+
scope,
|
|
549
|
+
trail
|
|
550
|
+
})
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
function TabsNode({ component, scope, trail }) {
|
|
554
|
+
const resolve = useResolve(scope);
|
|
555
|
+
const tabs = Array.isArray(component.tabs) ? component.tabs : [];
|
|
556
|
+
return /* @__PURE__ */ jsx(Tabs, {
|
|
557
|
+
label: typeof component.label === "string" && component.label || resolve.optional(component.accessibility?.label) || "Views",
|
|
558
|
+
tabs: tabs.map((tab, index) => ({
|
|
559
|
+
id: `${component.id}-${index}`,
|
|
560
|
+
label: resolve.text(tab?.title) || `Tab ${index + 1}`,
|
|
561
|
+
content: /* @__PURE__ */ jsx(One, {
|
|
562
|
+
id: tab?.child,
|
|
563
|
+
scope,
|
|
564
|
+
trail
|
|
565
|
+
})
|
|
566
|
+
}))
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
function ModalNode({ component, scope, trail }) {
|
|
570
|
+
const resolve = useResolve(scope);
|
|
571
|
+
const [open, setOpen] = useState(false);
|
|
572
|
+
const title = resolve.optional(component.title) ?? resolve.optional(component.accessibility?.label) ?? "Details";
|
|
573
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ModalTriggerContext.Provider, {
|
|
574
|
+
value: () => setOpen(true),
|
|
575
|
+
children: /* @__PURE__ */ jsx(One, {
|
|
576
|
+
id: component.trigger,
|
|
577
|
+
scope,
|
|
578
|
+
trail
|
|
579
|
+
})
|
|
580
|
+
}), /* @__PURE__ */ jsx(Dialog, {
|
|
581
|
+
open,
|
|
582
|
+
onClose: () => setOpen(false),
|
|
583
|
+
title,
|
|
584
|
+
children: open ? /* @__PURE__ */ jsx(One, {
|
|
585
|
+
id: component.content,
|
|
586
|
+
scope,
|
|
587
|
+
trail
|
|
588
|
+
}) : null
|
|
589
|
+
})] });
|
|
590
|
+
}
|
|
591
|
+
function DividerNode({ component }) {
|
|
592
|
+
return /* @__PURE__ */ jsx(Divider, {
|
|
593
|
+
orientation: component.axis === "vertical" ? "vertical" : "horizontal",
|
|
594
|
+
label: typeof component.label === "string" ? component.label : void 0
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
/** A button's label and icon, read from its child. */
|
|
598
|
+
function buttonContent(processor, surfaceId, childId, scope) {
|
|
599
|
+
const child = typeof childId === "string" ? processor.getComponent(surfaceId, childId) : void 0;
|
|
600
|
+
if (!child) return {
|
|
601
|
+
label: "",
|
|
602
|
+
icon: null
|
|
603
|
+
};
|
|
604
|
+
if (child.component === "Icon") {
|
|
605
|
+
const raw = isBinding(child.name) ? processor.resolve(surfaceId, child.name, scope) : child.name;
|
|
606
|
+
return {
|
|
607
|
+
label: resolveLabel(processor, surfaceId, child, scope),
|
|
608
|
+
icon: iconName(raw),
|
|
609
|
+
...typeof raw === "string" ? { iconSource: raw } : {}
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
if (child.component === "Row" || child.component === "Column") {
|
|
613
|
+
let label = "";
|
|
614
|
+
let icon = null;
|
|
615
|
+
let iconSource;
|
|
616
|
+
for (const ref of processor.childrenOf(surfaceId, child.children, scope)) {
|
|
617
|
+
const part = buttonContent(processor, surfaceId, ref.id, ref.scope);
|
|
618
|
+
icon ??= part.icon;
|
|
619
|
+
iconSource ??= part.iconSource;
|
|
620
|
+
if (part.label) label = label ? `${label} ${part.label}` : part.label;
|
|
621
|
+
}
|
|
622
|
+
return {
|
|
623
|
+
label,
|
|
624
|
+
icon,
|
|
625
|
+
...iconSource ? { iconSource } : {}
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
for (const key of [
|
|
629
|
+
"text",
|
|
630
|
+
"title",
|
|
631
|
+
"label"
|
|
632
|
+
]) if (child[key] !== void 0) return {
|
|
633
|
+
label: processor.resolveText(surfaceId, child[key], scope),
|
|
634
|
+
icon: null
|
|
635
|
+
};
|
|
636
|
+
return {
|
|
637
|
+
label: "",
|
|
638
|
+
icon: null
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
/** An Icon's own accessibility label, used as its button's name. */
|
|
642
|
+
function resolveLabel(processor, surfaceId, component, scope) {
|
|
643
|
+
const label = component.accessibility?.label;
|
|
644
|
+
return label === void 0 ? "" : processor.resolveText(surfaceId, label, scope);
|
|
645
|
+
}
|
|
646
|
+
/** The event name of a component's action, or "". */
|
|
647
|
+
function actionName(component) {
|
|
648
|
+
const action = component.action;
|
|
649
|
+
return typeof action?.event?.name === "string" ? action.event.name : "";
|
|
650
|
+
}
|
|
651
|
+
var buttonTone = {
|
|
652
|
+
default: "secondary",
|
|
653
|
+
primary: "primary",
|
|
654
|
+
borderless: "ghost"
|
|
655
|
+
};
|
|
656
|
+
/** False when the host said it doesn't handle this component's event. */
|
|
657
|
+
function isHandled(component, handlesEvent) {
|
|
658
|
+
const name = actionName(component);
|
|
659
|
+
return !name || !handlesEvent || handlesEvent(name);
|
|
660
|
+
}
|
|
661
|
+
function ButtonNode({ component, scope, forwarded = {}, asTrigger = false, inTooltip = false }) {
|
|
662
|
+
const { processor, surfaceId, dispatch, handlesEvent } = useSurface();
|
|
663
|
+
const modalTrigger = useContext(ModalTriggerContext);
|
|
664
|
+
const openModal = asTrigger ? null : modalTrigger;
|
|
665
|
+
const resolve = useResolve(scope);
|
|
666
|
+
const content = buttonContent(processor, surfaceId, component.child, scope);
|
|
667
|
+
const ariaLabel = resolve.optional(component.accessibility?.label);
|
|
668
|
+
const href = asTrigger ? void 0 : safeHref(resolve.value(component.href));
|
|
669
|
+
const loading = !href && resolve.value(component.loading) === true;
|
|
670
|
+
const disabled = processor.failingChecks(surfaceId, component.checks, scope).length > 0 || !asTrigger && !openModal && !href && !isHandled(component, handlesEvent);
|
|
671
|
+
const onClick = chain(asTrigger ? void 0 : openModal ? openModal : component.action ? () => dispatch(component, component.action, scope) : void 0, forwarded.onClick);
|
|
672
|
+
const extraIcon = typeof component.icon === "string" && isIconName(component.icon) ? component.icon : null;
|
|
673
|
+
const named = ariaLabel ?? (humanize(actionName(component)) || humanize(content.iconSource ?? ""));
|
|
674
|
+
if (!content.label && content.icon) return /* @__PURE__ */ jsx(IconButton, {
|
|
675
|
+
...forwarded,
|
|
676
|
+
tooltip: !inTooltip,
|
|
677
|
+
icon: content.icon,
|
|
678
|
+
label: named || "Button",
|
|
679
|
+
href: openModal ? void 0 : href,
|
|
680
|
+
onClick,
|
|
681
|
+
disabled: disabled && !href,
|
|
682
|
+
tone: component.variant === "primary" ? "primary" : "neutral"
|
|
683
|
+
});
|
|
684
|
+
const tone = buttonTone[component.variant] ?? "secondary";
|
|
685
|
+
const label = content.label || named || "Button";
|
|
686
|
+
if (href && !openModal) return /* @__PURE__ */ jsx(Button, {
|
|
687
|
+
href,
|
|
688
|
+
tone,
|
|
689
|
+
leadingIcon: content.icon ?? extraIcon ?? void 0,
|
|
690
|
+
children: label
|
|
691
|
+
});
|
|
692
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
693
|
+
...forwarded,
|
|
694
|
+
type: "button",
|
|
695
|
+
tone,
|
|
696
|
+
onClick,
|
|
697
|
+
disabled,
|
|
698
|
+
loading,
|
|
699
|
+
leadingIcon: content.icon ?? extraIcon ?? void 0,
|
|
700
|
+
children: label
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
/** Error text for an input: failing checks once touched, then the regexp. */
|
|
704
|
+
function useFieldError(component, scope, value) {
|
|
705
|
+
const { processor, surfaceId } = useSurface();
|
|
706
|
+
const [touched, setTouched] = useState(false);
|
|
707
|
+
let error;
|
|
708
|
+
if (touched) {
|
|
709
|
+
error = processor.failingChecks(surfaceId, component.checks, scope)[0];
|
|
710
|
+
if (!error && typeof component.validationRegexp === "string" && toText(value) !== "") {
|
|
711
|
+
if (safeRegExp(component.validationRegexp) && !testPattern(component.validationRegexp, toText(value))) error = "This doesn’t match the expected format.";
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
return {
|
|
715
|
+
error,
|
|
716
|
+
touch: () => setTouched(true)
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
function TextFieldNode({ component, scope }) {
|
|
720
|
+
const resolve = useResolve(scope);
|
|
721
|
+
const [value, setValue] = useBound(component.value, scope, "");
|
|
722
|
+
const { error, touch } = useFieldError(component, scope, value);
|
|
723
|
+
const label = resolve.text(component.label) || "Text";
|
|
724
|
+
const hint = resolve.optional(component.hint);
|
|
725
|
+
if (component.variant === "longText") return /* @__PURE__ */ jsx(TextArea, {
|
|
726
|
+
label,
|
|
727
|
+
hint,
|
|
728
|
+
error,
|
|
729
|
+
value: toText(value),
|
|
730
|
+
onChange: (event) => setValue(event.currentTarget.value),
|
|
731
|
+
onBlur: touch
|
|
732
|
+
});
|
|
733
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
734
|
+
label,
|
|
735
|
+
hint,
|
|
736
|
+
error,
|
|
737
|
+
type: component.variant === "obscured" ? "password" : component.variant === "number" ? "number" : "text",
|
|
738
|
+
value: toText(value),
|
|
739
|
+
onChange: (event) => setValue(component.variant === "number" && event.currentTarget.value !== "" ? Number(event.currentTarget.value) : event.currentTarget.value),
|
|
740
|
+
onBlur: touch
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
function CheckBoxNode({ component, scope }) {
|
|
744
|
+
const resolve = useResolve(scope);
|
|
745
|
+
const [value, setValue] = useBound(component.value, scope, false);
|
|
746
|
+
const { error, touch } = useFieldError(component, scope, value);
|
|
747
|
+
return /* @__PURE__ */ jsx(Checkbox, {
|
|
748
|
+
label: resolve.text(component.label),
|
|
749
|
+
checked: Boolean(value),
|
|
750
|
+
error,
|
|
751
|
+
onChange: (event) => {
|
|
752
|
+
setValue(event.currentTarget.checked);
|
|
753
|
+
touch();
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
function ChoicePickerNode({ component, scope }) {
|
|
758
|
+
const resolve = useResolve(scope);
|
|
759
|
+
const [value, setValue] = useBound(component.value, scope, []);
|
|
760
|
+
const [filter, setFilter] = useState("");
|
|
761
|
+
const { error, touch } = useFieldError(component, scope, value);
|
|
762
|
+
const selected = Array.isArray(value) ? value.map(String) : value === void 0 || value === null || value === "" ? [] : [String(value)];
|
|
763
|
+
const options = (Array.isArray(component.options) ? component.options : []).map((item) => ({
|
|
764
|
+
value: String(item?.value ?? ""),
|
|
765
|
+
label: resolve.text(item?.label)
|
|
766
|
+
})).filter((item) => item.value !== "");
|
|
767
|
+
const visible = component.filterable && filter ? options.filter((item) => item.label.toLowerCase().includes(filter.toLowerCase())) : options;
|
|
768
|
+
const label = resolve.text(component.label) || "Choose";
|
|
769
|
+
const filterField = component.filterable ? /* @__PURE__ */ jsx(TextField, {
|
|
770
|
+
label: `Filter ${label.toLowerCase()}`,
|
|
771
|
+
type: "search",
|
|
772
|
+
size: "sm",
|
|
773
|
+
value: filter,
|
|
774
|
+
onChange: (event) => setFilter(event.currentTarget.value)
|
|
775
|
+
}) : null;
|
|
776
|
+
if (component.variant === "multipleSelection") return /* @__PURE__ */ jsxs("fieldset", {
|
|
777
|
+
className: fieldset,
|
|
778
|
+
children: [
|
|
779
|
+
/* @__PURE__ */ jsx("legend", {
|
|
780
|
+
className: legend,
|
|
781
|
+
children: label
|
|
782
|
+
}),
|
|
783
|
+
filterField,
|
|
784
|
+
visible.map((item) => /* @__PURE__ */ jsx(Checkbox, {
|
|
785
|
+
label: item.label,
|
|
786
|
+
checked: selected.includes(item.value),
|
|
787
|
+
onChange: (event) => {
|
|
788
|
+
const next = event.currentTarget.checked ? [...selected, item.value] : selected.filter((entry) => entry !== item.value);
|
|
789
|
+
setValue(next);
|
|
790
|
+
touch();
|
|
791
|
+
}
|
|
792
|
+
}, item.value)),
|
|
793
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
794
|
+
className: errorText,
|
|
795
|
+
children: error
|
|
796
|
+
}) : null
|
|
797
|
+
]
|
|
798
|
+
});
|
|
799
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
800
|
+
gap: 2,
|
|
801
|
+
children: [filterField, /* @__PURE__ */ jsx(RadioGroup, {
|
|
802
|
+
label,
|
|
803
|
+
error,
|
|
804
|
+
orientation: component.displayStyle === "chips" ? "horizontal" : "vertical",
|
|
805
|
+
options: visible,
|
|
806
|
+
value: selected[0] ?? "",
|
|
807
|
+
onValueChange: (next) => {
|
|
808
|
+
setValue([next]);
|
|
809
|
+
touch();
|
|
810
|
+
}
|
|
811
|
+
})]
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
function SliderNode({ component, scope }) {
|
|
815
|
+
const resolve = useResolve(scope);
|
|
816
|
+
const id = useId();
|
|
817
|
+
const errorId = useId();
|
|
818
|
+
const [value, setValue] = useBound(component.value, scope, 0);
|
|
819
|
+
const { error, touch } = useFieldError(component, scope, value);
|
|
820
|
+
const min = typeof component.min === "number" ? component.min : 0;
|
|
821
|
+
const max = typeof component.max === "number" ? component.max : 100;
|
|
822
|
+
const step = typeof component.step === "number" ? component.step : "any";
|
|
823
|
+
const label = resolve.text(component.label) || resolve.optional(component.accessibility?.label) || humanize(component.id);
|
|
824
|
+
const numeric = Number(value);
|
|
825
|
+
const shown = Number.isFinite(numeric) ? numeric : min;
|
|
826
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
827
|
+
className: slider,
|
|
828
|
+
children: [
|
|
829
|
+
/* @__PURE__ */ jsx("label", {
|
|
830
|
+
htmlFor: id,
|
|
831
|
+
className: sliderLabel,
|
|
832
|
+
children: label
|
|
833
|
+
}),
|
|
834
|
+
/* @__PURE__ */ jsx("input", {
|
|
835
|
+
id,
|
|
836
|
+
type: "range",
|
|
837
|
+
className: range,
|
|
838
|
+
min,
|
|
839
|
+
max,
|
|
840
|
+
step,
|
|
841
|
+
value: shown,
|
|
842
|
+
"aria-invalid": error ? true : void 0,
|
|
843
|
+
"aria-describedby": error ? errorId : void 0,
|
|
844
|
+
onChange: (event) => setValue(Number(event.currentTarget.value)),
|
|
845
|
+
onBlur: touch
|
|
846
|
+
}),
|
|
847
|
+
/* @__PURE__ */ jsx("output", {
|
|
848
|
+
htmlFor: id,
|
|
849
|
+
className: rangeValue,
|
|
850
|
+
children: shown
|
|
851
|
+
}),
|
|
852
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
853
|
+
id: errorId,
|
|
854
|
+
className: errorText,
|
|
855
|
+
children: error
|
|
856
|
+
}) : null
|
|
857
|
+
]
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
/** An ISO value in the shape a native date or time input expects. */
|
|
861
|
+
function toInputValue(value, kind) {
|
|
862
|
+
if (!value) return "";
|
|
863
|
+
if (kind === "time") {
|
|
864
|
+
const match = /(\d{2}:\d{2})/.exec(value);
|
|
865
|
+
return match ? match[1] : "";
|
|
866
|
+
}
|
|
867
|
+
const date = new Date(value);
|
|
868
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
869
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) return kind === "date" ? value : `${value}T00:00`;
|
|
870
|
+
const local = (/* @__PURE__ */ new Date(date.getTime() - date.getTimezoneOffset() * 6e4)).toISOString().slice(0, 16);
|
|
871
|
+
return kind === "date" ? local.slice(0, 10) : local;
|
|
872
|
+
}
|
|
873
|
+
function DateTimeNode({ component, scope }) {
|
|
874
|
+
const resolve = useResolve(scope);
|
|
875
|
+
const [value, setValue] = useBound(component.value, scope, "");
|
|
876
|
+
const { error, touch } = useFieldError(component, scope, value);
|
|
877
|
+
const kind = component.enableDate === true && component.enableTime !== true ? "date" : component.enableTime === true && component.enableDate !== true ? "time" : "datetime-local";
|
|
878
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
879
|
+
label: resolve.text(component.label) || (kind === "time" ? "Time" : "Date"),
|
|
880
|
+
type: kind,
|
|
881
|
+
value: toInputValue(toText(value), kind),
|
|
882
|
+
min: resolve.optional(component.min),
|
|
883
|
+
max: resolve.optional(component.max),
|
|
884
|
+
error,
|
|
885
|
+
onChange: (event) => setValue(event.currentTarget.value),
|
|
886
|
+
onBlur: touch
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
function HeadingNode({ component, scope }) {
|
|
890
|
+
const { headingLevel } = useSurface();
|
|
891
|
+
const resolve = useResolve(scope);
|
|
892
|
+
const relative = typeof component.level === "number" ? Math.max(1, component.level) : 1;
|
|
893
|
+
const size = typeof component.size === "string" ? component.size : {
|
|
894
|
+
1: "xl",
|
|
895
|
+
2: "lg",
|
|
896
|
+
3: "md",
|
|
897
|
+
4: "md"
|
|
898
|
+
}[clampLevel(relative)] ?? "md";
|
|
899
|
+
return /* @__PURE__ */ jsx(Heading, {
|
|
900
|
+
level: clampLevel(headingLevel + relative - 1),
|
|
901
|
+
size,
|
|
902
|
+
tone: component.tone === "accent" ? "accent" : "default",
|
|
903
|
+
children: resolve.text(component.text)
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
function StatNode({ component, scope }) {
|
|
907
|
+
const resolve = useResolve(scope);
|
|
908
|
+
const trend = [
|
|
909
|
+
"up",
|
|
910
|
+
"down",
|
|
911
|
+
"flat"
|
|
912
|
+
].includes(String(component.trend)) ? component.trend : void 0;
|
|
913
|
+
const tone = [
|
|
914
|
+
"positive",
|
|
915
|
+
"danger",
|
|
916
|
+
"neutral"
|
|
917
|
+
].includes(String(component.tone)) ? component.tone : void 0;
|
|
918
|
+
return /* @__PURE__ */ jsx(Stat, {
|
|
919
|
+
label: resolve.text(component.label),
|
|
920
|
+
value: resolve.text(component.value),
|
|
921
|
+
delta: resolve.optional(component.delta),
|
|
922
|
+
trend,
|
|
923
|
+
tone,
|
|
924
|
+
description: resolve.optional(component.description),
|
|
925
|
+
variant: component.variant === "plain" ? "plain" : "card"
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
var statusTones = [
|
|
929
|
+
"neutral",
|
|
930
|
+
"accent",
|
|
931
|
+
"positive",
|
|
932
|
+
"warning",
|
|
933
|
+
"danger",
|
|
934
|
+
"info"
|
|
935
|
+
];
|
|
936
|
+
function BadgeNode({ component, scope }) {
|
|
937
|
+
const resolve = useResolve(scope);
|
|
938
|
+
const tone = statusTones.includes(String(component.tone)) ? component.tone : "neutral";
|
|
939
|
+
return /* @__PURE__ */ jsx(Badge, {
|
|
940
|
+
tone,
|
|
941
|
+
variant: component.variant === "outline" ? "outline" : "soft",
|
|
942
|
+
dot: component.dot === true,
|
|
943
|
+
icon: iconName(component.icon) ?? void 0,
|
|
944
|
+
children: resolve.text(component.text)
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
function TagNode({ component, scope }) {
|
|
948
|
+
const resolve = useResolve(scope);
|
|
949
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
950
|
+
href: safeHref(resolve.value(component.href)),
|
|
951
|
+
children: resolve.text(component.text)
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
function AvatarNode({ component, scope }) {
|
|
955
|
+
const { allowRemoteImages } = useSurface();
|
|
956
|
+
const resolve = useResolve(scope);
|
|
957
|
+
const size = [
|
|
958
|
+
"sm",
|
|
959
|
+
"md",
|
|
960
|
+
"lg",
|
|
961
|
+
"xl"
|
|
962
|
+
].includes(String(component.size)) ? component.size : "md";
|
|
963
|
+
return /* @__PURE__ */ jsx(Avatar, {
|
|
964
|
+
name: resolve.text(component.name) || "Person",
|
|
965
|
+
src: safeImage(resolve.value(component.src), { allowRemote: allowRemoteImages }) || void 0,
|
|
966
|
+
size
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
function QuoteNode({ component, scope }) {
|
|
970
|
+
const resolve = useResolve(scope);
|
|
971
|
+
return /* @__PURE__ */ jsx(Quote, {
|
|
972
|
+
attribution: resolve.optional(component.attribution),
|
|
973
|
+
source: resolve.optional(component.source),
|
|
974
|
+
children: resolve.text(component.text)
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
/** A list from a literal array or a binding to one. */
|
|
978
|
+
function useList(value, scope) {
|
|
979
|
+
const { processor, surfaceId } = useSurface();
|
|
980
|
+
if (isBinding(value)) {
|
|
981
|
+
const items = processor.getData(surfaceId, value.path, scope);
|
|
982
|
+
if (!Array.isArray(items)) return [];
|
|
983
|
+
const base = value.path.startsWith("/") ? value.path : `${scope}/${value.path}`.replace(/^\/?/, "/");
|
|
984
|
+
return items.map((item, index) => ({
|
|
985
|
+
item,
|
|
986
|
+
scope: `${base}/${index}`
|
|
987
|
+
}));
|
|
988
|
+
}
|
|
989
|
+
return Array.isArray(value) ? value.map((item) => ({
|
|
990
|
+
item,
|
|
991
|
+
scope
|
|
992
|
+
})) : [];
|
|
993
|
+
}
|
|
994
|
+
function TimelineNode({ component, scope }) {
|
|
995
|
+
const { processor, surfaceId } = useSurface();
|
|
996
|
+
const items = useList(component.items, scope).map(({ item, scope: itemScope }, index) => {
|
|
997
|
+
const record = item ?? {};
|
|
998
|
+
const read = (key) => record[key] === void 0 ? void 0 : processor.resolveText(surfaceId, record[key], itemScope) || void 0;
|
|
999
|
+
return {
|
|
1000
|
+
id: `${component.id}-${index}`,
|
|
1001
|
+
title: read("title") ?? "",
|
|
1002
|
+
meta: read("meta"),
|
|
1003
|
+
description: read("description"),
|
|
1004
|
+
current: processor.resolve(surfaceId, record.current, itemScope) === true
|
|
1005
|
+
};
|
|
1006
|
+
});
|
|
1007
|
+
return /* @__PURE__ */ jsx(Timeline, { items });
|
|
1008
|
+
}
|
|
1009
|
+
function TableNode({ component, scope }) {
|
|
1010
|
+
const { processor, surfaceId } = useSurface();
|
|
1011
|
+
const resolve = useResolve(scope);
|
|
1012
|
+
const columns = (Array.isArray(component.columns) ? component.columns : []).filter((column) => typeof column?.key === "string").map((column) => ({
|
|
1013
|
+
key: column.key,
|
|
1014
|
+
header: resolve.text(column.header) || column.key,
|
|
1015
|
+
align: [
|
|
1016
|
+
"start",
|
|
1017
|
+
"center",
|
|
1018
|
+
"end"
|
|
1019
|
+
].includes(String(column.align)) ? column.align : void 0
|
|
1020
|
+
}));
|
|
1021
|
+
const rows = useList(component.rows, scope).map(({ item, scope: rowScope }) => {
|
|
1022
|
+
const record = item ?? {};
|
|
1023
|
+
const row = {};
|
|
1024
|
+
for (const column of columns) row[column.key] = processor.resolveText(surfaceId, record[column.key], rowScope);
|
|
1025
|
+
return row;
|
|
1026
|
+
});
|
|
1027
|
+
return /* @__PURE__ */ jsx(Table, {
|
|
1028
|
+
caption: resolve.text(component.caption) || "Table",
|
|
1029
|
+
columns,
|
|
1030
|
+
rows,
|
|
1031
|
+
rowHeader: typeof component.rowHeader === "string" ? component.rowHeader : void 0,
|
|
1032
|
+
density: component.density === "compact" ? "compact" : "comfortable",
|
|
1033
|
+
striped: component.striped === true,
|
|
1034
|
+
hideCaption: component.hideCaption === true
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
function AlertNode({ component, scope }) {
|
|
1038
|
+
const resolve = useResolve(scope);
|
|
1039
|
+
const tone = [
|
|
1040
|
+
"info",
|
|
1041
|
+
"positive",
|
|
1042
|
+
"warning",
|
|
1043
|
+
"danger"
|
|
1044
|
+
].includes(String(component.tone)) ? component.tone : "info";
|
|
1045
|
+
return /* @__PURE__ */ jsx(Alert, {
|
|
1046
|
+
tone,
|
|
1047
|
+
title: resolve.optional(component.title),
|
|
1048
|
+
children: resolve.optional(component.text)
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
function ProgressNode({ component, scope }) {
|
|
1052
|
+
const resolve = useResolve(scope);
|
|
1053
|
+
const value = Number(resolve.value(component.value));
|
|
1054
|
+
const tone = [
|
|
1055
|
+
"accent",
|
|
1056
|
+
"positive",
|
|
1057
|
+
"warning",
|
|
1058
|
+
"danger"
|
|
1059
|
+
].includes(String(component.tone)) ? component.tone : "accent";
|
|
1060
|
+
return /* @__PURE__ */ jsx(Progress, {
|
|
1061
|
+
label: resolve.text(component.label) || "Progress",
|
|
1062
|
+
value: component.value === void 0 || !Number.isFinite(value) ? void 0 : value,
|
|
1063
|
+
max: typeof component.max === "number" && component.max > 0 ? component.max : 100,
|
|
1064
|
+
tone,
|
|
1065
|
+
valueText: resolve.optional(component.valueText),
|
|
1066
|
+
description: resolve.optional(component.description),
|
|
1067
|
+
showValue: component.showValue !== false
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
function LinkNode({ component, scope }) {
|
|
1071
|
+
const resolve = useResolve(scope);
|
|
1072
|
+
const href = safeHref(resolve.value(component.href));
|
|
1073
|
+
const text = resolve.text(component.text);
|
|
1074
|
+
if (!href) return /* @__PURE__ */ jsx(Text, { children: text });
|
|
1075
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
1076
|
+
href,
|
|
1077
|
+
variant: component.variant === "inline" ? "inline" : "standalone",
|
|
1078
|
+
icon: iconName(component.icon) ?? (component.variant === "inline" ? void 0 : "arrow-right"),
|
|
1079
|
+
external: href.startsWith("https:"),
|
|
1080
|
+
children: text
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
function GridNode({ component, scope, trail }) {
|
|
1084
|
+
return /* @__PURE__ */ jsx(Grid, {
|
|
1085
|
+
min: typeof component.min === "string" ? component.min : "16rem",
|
|
1086
|
+
maxColumns: typeof component.maxColumns === "number" ? component.maxColumns : void 0,
|
|
1087
|
+
gap: gapStep(component.gap, 4),
|
|
1088
|
+
children: /* @__PURE__ */ jsx(Children$1, {
|
|
1089
|
+
list: component.children,
|
|
1090
|
+
scope,
|
|
1091
|
+
trail
|
|
1092
|
+
})
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
function AccordionNode({ component, scope, trail }) {
|
|
1096
|
+
const resolve = useResolve(scope);
|
|
1097
|
+
const items = Array.isArray(component.items) ? component.items : [];
|
|
1098
|
+
return /* @__PURE__ */ jsx(Accordion, {
|
|
1099
|
+
exclusive: component.exclusive === true,
|
|
1100
|
+
items: items.map((item, index) => ({
|
|
1101
|
+
id: `${component.id}-${index}`,
|
|
1102
|
+
title: resolve.text(item?.title),
|
|
1103
|
+
content: /* @__PURE__ */ jsx(One, {
|
|
1104
|
+
id: item?.child,
|
|
1105
|
+
scope,
|
|
1106
|
+
trail
|
|
1107
|
+
}),
|
|
1108
|
+
defaultOpen: item?.open === true
|
|
1109
|
+
}))
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
function CodeBlockNode({ component, scope }) {
|
|
1113
|
+
const resolve = useResolve(scope);
|
|
1114
|
+
return /* @__PURE__ */ jsx(CodeBlock, {
|
|
1115
|
+
code: resolve.text(component.code),
|
|
1116
|
+
language: typeof component.language === "string" ? component.language : void 0,
|
|
1117
|
+
title: typeof component.title === "string" ? component.title : void 0
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
function SwitchNode({ component, scope }) {
|
|
1121
|
+
const resolve = useResolve(scope);
|
|
1122
|
+
const [value, setValue] = useBound(component.value, scope, false);
|
|
1123
|
+
return /* @__PURE__ */ jsx(Switch, {
|
|
1124
|
+
label: resolve.text(component.label),
|
|
1125
|
+
hint: resolve.optional(component.hint),
|
|
1126
|
+
checked: Boolean(value),
|
|
1127
|
+
onChange: (event) => setValue(event.currentTarget.checked)
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
function SelectNode({ component, scope }) {
|
|
1131
|
+
const resolve = useResolve(scope);
|
|
1132
|
+
const [value, setValue] = useBound(component.value, scope, "");
|
|
1133
|
+
const options = (Array.isArray(component.options) ? component.options : []).map((item) => ({
|
|
1134
|
+
value: String(item?.value ?? ""),
|
|
1135
|
+
label: resolve.text(item?.label)
|
|
1136
|
+
}));
|
|
1137
|
+
return /* @__PURE__ */ jsx(Select, {
|
|
1138
|
+
label: resolve.text(component.label) || "Choose",
|
|
1139
|
+
hint: resolve.optional(component.hint),
|
|
1140
|
+
options,
|
|
1141
|
+
placeholder: typeof component.placeholder === "string" ? component.placeholder : void 0,
|
|
1142
|
+
value: toText(value),
|
|
1143
|
+
onChange: (event) => setValue(event.currentTarget.value)
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
function IconButtonNode({ component, scope, forwarded = {}, asTrigger = false, inTooltip = false }) {
|
|
1147
|
+
const { dispatch, handlesEvent } = useSurface();
|
|
1148
|
+
const modalTrigger = useContext(ModalTriggerContext);
|
|
1149
|
+
const openModal = asTrigger ? null : modalTrigger;
|
|
1150
|
+
const resolve = useResolve(scope);
|
|
1151
|
+
const tone = [
|
|
1152
|
+
"neutral",
|
|
1153
|
+
"ghost",
|
|
1154
|
+
"primary",
|
|
1155
|
+
"danger"
|
|
1156
|
+
].includes(String(component.tone)) ? component.tone : "neutral";
|
|
1157
|
+
const href = openModal || asTrigger ? void 0 : safeHref(resolve.value(component.href));
|
|
1158
|
+
const own = asTrigger ? void 0 : openModal ?? (component.action ? () => dispatch(component, component.action, scope) : void 0);
|
|
1159
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
1160
|
+
...forwarded,
|
|
1161
|
+
tooltip: !inTooltip,
|
|
1162
|
+
icon: iconName(component.icon) ?? "sparkle",
|
|
1163
|
+
label: typeof component.label === "string" && component.label ? component.label : humanize(actionName(component)) || humanize(String(component.icon ?? "")) || "Button",
|
|
1164
|
+
tone,
|
|
1165
|
+
href,
|
|
1166
|
+
disabled: !asTrigger && !openModal && !href && !isHandled(component, handlesEvent),
|
|
1167
|
+
onClick: chain(own, forwarded.onClick)
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
function navLinks(value) {
|
|
1171
|
+
return (Array.isArray(value) ? value : []).map((item) => ({
|
|
1172
|
+
label: typeof item?.label === "string" ? item.label : "",
|
|
1173
|
+
href: safeHref(item?.href) ?? "#",
|
|
1174
|
+
current: item?.current === true
|
|
1175
|
+
})).filter((item) => item.label);
|
|
1176
|
+
}
|
|
1177
|
+
/** A landmark name with the surface's suffix, like "Pulse (Web)". */
|
|
1178
|
+
function landmark(name, suffix) {
|
|
1179
|
+
return suffix ? `${name} (${suffix})` : name;
|
|
1180
|
+
}
|
|
1181
|
+
function NavBarNode({ component, scope, trail }) {
|
|
1182
|
+
const { processor, surfaceId, landmarkSuffix } = useSurface();
|
|
1183
|
+
const resolve = useResolve(scope);
|
|
1184
|
+
const brand = typeof component.brand === "string" ? component.brand : "";
|
|
1185
|
+
const actions = childArray(component.actions, scope, trail, processor, surfaceId);
|
|
1186
|
+
return /* @__PURE__ */ jsx(NavBar, {
|
|
1187
|
+
brand,
|
|
1188
|
+
label: landmark(resolve.optional(component.accessibility?.label) ?? (brand || "Primary"), landmarkSuffix),
|
|
1189
|
+
mark: typeof component.mark === "string" ? component.mark : void 0,
|
|
1190
|
+
links: navLinks(component.links),
|
|
1191
|
+
actions: actions.length > 0 ? actions : void 0
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
function TabBarNode({ component, scope }) {
|
|
1195
|
+
const { landmarkSuffix } = useSurface();
|
|
1196
|
+
const resolve = useResolve(scope);
|
|
1197
|
+
const items = (Array.isArray(component.items) ? component.items : []).map((item) => ({
|
|
1198
|
+
label: typeof item?.label === "string" ? item.label : "",
|
|
1199
|
+
href: safeHref(item?.href) ?? "#",
|
|
1200
|
+
icon: iconName(item?.icon) ?? "sparkle",
|
|
1201
|
+
current: item?.current === true
|
|
1202
|
+
})).filter((item) => item.label);
|
|
1203
|
+
return /* @__PURE__ */ jsx(TabBar, {
|
|
1204
|
+
items,
|
|
1205
|
+
position: "static",
|
|
1206
|
+
label: landmark(resolve.optional(component.accessibility?.label) ?? "Tabs", landmarkSuffix)
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
function SideNavNode({ component }) {
|
|
1210
|
+
const { landmarkSuffix } = useSurface();
|
|
1211
|
+
const sections = (Array.isArray(component.sections) ? component.sections : []).map((section) => ({
|
|
1212
|
+
title: typeof section?.title === "string" ? section.title : void 0,
|
|
1213
|
+
items: navLinks(section?.items)
|
|
1214
|
+
}));
|
|
1215
|
+
return /* @__PURE__ */ jsx(SideNav, {
|
|
1216
|
+
label: landmark(typeof component.label === "string" ? component.label : "Navigation", landmarkSuffix),
|
|
1217
|
+
sections
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* The Button or IconButton a Menu, Popover, or Tooltip attaches to. They
|
|
1222
|
+
* clone this element with a ref, ARIA, and handlers, and it hands those to
|
|
1223
|
+
* the real button. Anything else becomes a plain button named for its id.
|
|
1224
|
+
*/
|
|
1225
|
+
function AttachedControl({ componentId, scope, trail, asTrigger = true, inTooltip = false, ...forwarded }) {
|
|
1226
|
+
const { processor, surfaceId } = useSurface();
|
|
1227
|
+
const component = typeof componentId === "string" ? processor.getComponent(surfaceId, componentId) : void 0;
|
|
1228
|
+
const props = {
|
|
1229
|
+
scope,
|
|
1230
|
+
trail,
|
|
1231
|
+
forwarded,
|
|
1232
|
+
asTrigger,
|
|
1233
|
+
inTooltip
|
|
1234
|
+
};
|
|
1235
|
+
if (component?.component === "Button") return /* @__PURE__ */ jsx(ButtonNode, {
|
|
1236
|
+
component,
|
|
1237
|
+
...props
|
|
1238
|
+
});
|
|
1239
|
+
if (component?.component === "IconButton") return /* @__PURE__ */ jsx(IconButtonNode, {
|
|
1240
|
+
component,
|
|
1241
|
+
...props
|
|
1242
|
+
});
|
|
1243
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
1244
|
+
...forwarded,
|
|
1245
|
+
type: "button",
|
|
1246
|
+
tone: "secondary",
|
|
1247
|
+
children: humanize(String(componentId ?? "")) || "Open"
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
var isControl = (component) => component?.component === "Button" || component?.component === "IconButton";
|
|
1251
|
+
var placements = [
|
|
1252
|
+
"bottom",
|
|
1253
|
+
"top",
|
|
1254
|
+
"start",
|
|
1255
|
+
"end"
|
|
1256
|
+
];
|
|
1257
|
+
var aligns = [
|
|
1258
|
+
"start",
|
|
1259
|
+
"center",
|
|
1260
|
+
"end"
|
|
1261
|
+
];
|
|
1262
|
+
var pick = (value, allowed) => allowed.find((item) => item === value);
|
|
1263
|
+
function MenuNode({ component, scope, trail }) {
|
|
1264
|
+
const { dispatch, handlesEvent } = useSurface();
|
|
1265
|
+
const items = (Array.isArray(component.items) ? component.items : []).filter((item) => item && typeof item.label === "string" && item.label).map((item, index) => {
|
|
1266
|
+
const href = safeHref(item.href);
|
|
1267
|
+
const action = item.action;
|
|
1268
|
+
const name = action && typeof action === "object" && "event" in action ? String(action.event?.name ?? "") : "";
|
|
1269
|
+
const handled = !name || !handlesEvent || handlesEvent(name);
|
|
1270
|
+
return {
|
|
1271
|
+
id: `${component.id}-${index}`,
|
|
1272
|
+
label: item.label,
|
|
1273
|
+
icon: iconName(item.icon) ?? void 0,
|
|
1274
|
+
tone: item.tone === "danger" ? "danger" : "default",
|
|
1275
|
+
disabled: item.disabled === true || !href && (!action || !handled),
|
|
1276
|
+
...href ? { href } : {},
|
|
1277
|
+
...action && !href ? { onSelect: () => dispatch(component, action, scope) } : {}
|
|
1278
|
+
};
|
|
1279
|
+
});
|
|
1280
|
+
return /* @__PURE__ */ jsx(Menu, {
|
|
1281
|
+
trigger: /* @__PURE__ */ jsx(AttachedControl, {
|
|
1282
|
+
componentId: component.trigger,
|
|
1283
|
+
scope,
|
|
1284
|
+
trail
|
|
1285
|
+
}),
|
|
1286
|
+
items,
|
|
1287
|
+
label: typeof component.label === "string" ? component.label : void 0,
|
|
1288
|
+
placement: pick(component.placement, placements),
|
|
1289
|
+
align: pick(component.align, aligns)
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
function PopoverNode({ component, scope, trail }) {
|
|
1293
|
+
const resolve = useResolve(scope);
|
|
1294
|
+
return /* @__PURE__ */ jsx(Popover, {
|
|
1295
|
+
trigger: /* @__PURE__ */ jsx(AttachedControl, {
|
|
1296
|
+
componentId: component.trigger,
|
|
1297
|
+
scope,
|
|
1298
|
+
trail
|
|
1299
|
+
}),
|
|
1300
|
+
title: resolve.optional(component.title),
|
|
1301
|
+
label: typeof component.label === "string" ? component.label : void 0,
|
|
1302
|
+
placement: pick(component.placement, placements),
|
|
1303
|
+
align: pick(component.align, aligns),
|
|
1304
|
+
children: /* @__PURE__ */ jsx(One, {
|
|
1305
|
+
id: component.child,
|
|
1306
|
+
scope,
|
|
1307
|
+
trail
|
|
1308
|
+
})
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
function TooltipNode({ component, scope, trail }) {
|
|
1312
|
+
const { processor, surfaceId } = useSurface();
|
|
1313
|
+
const child = typeof component.child === "string" ? processor.getComponent(surfaceId, component.child) : void 0;
|
|
1314
|
+
const content = typeof component.content === "string" ? component.content : "";
|
|
1315
|
+
if (!isControl(child) || !content) return /* @__PURE__ */ jsx(One, {
|
|
1316
|
+
id: component.child,
|
|
1317
|
+
scope,
|
|
1318
|
+
trail
|
|
1319
|
+
});
|
|
1320
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
1321
|
+
content,
|
|
1322
|
+
type: "description",
|
|
1323
|
+
placement: pick(component.placement, placements),
|
|
1324
|
+
children: /* @__PURE__ */ jsx(AttachedControl, {
|
|
1325
|
+
componentId: component.child,
|
|
1326
|
+
scope,
|
|
1327
|
+
trail,
|
|
1328
|
+
asTrigger: false,
|
|
1329
|
+
inTooltip: true
|
|
1330
|
+
})
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
function SpinnerNode({ component, scope }) {
|
|
1334
|
+
const resolve = useResolve(scope);
|
|
1335
|
+
return /* @__PURE__ */ jsx(Spinner, {
|
|
1336
|
+
label: resolve.optional(component.label),
|
|
1337
|
+
size: pick(component.size, [
|
|
1338
|
+
"sm",
|
|
1339
|
+
"md",
|
|
1340
|
+
"lg"
|
|
1341
|
+
])
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
var cssLengthPattern = /^\d+(\.\d+)?(rem|em|ch|px|%)$/;
|
|
1345
|
+
function SkeletonNode({ component }) {
|
|
1346
|
+
const length = (value) => typeof value === "string" && cssLengthPattern.test(value) ? value : void 0;
|
|
1347
|
+
return /* @__PURE__ */ jsx(Skeleton, {
|
|
1348
|
+
variant: pick(component.variant, [
|
|
1349
|
+
"text",
|
|
1350
|
+
"rect",
|
|
1351
|
+
"circle"
|
|
1352
|
+
]),
|
|
1353
|
+
lines: typeof component.lines === "number" ? Math.min(12, Math.max(1, Math.round(component.lines))) : void 0,
|
|
1354
|
+
width: length(component.width),
|
|
1355
|
+
height: length(component.height)
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
function BreadcrumbsNode({ component }) {
|
|
1359
|
+
const items = (Array.isArray(component.items) ? component.items : []).map((item) => ({
|
|
1360
|
+
label: typeof item?.label === "string" ? item.label : "",
|
|
1361
|
+
href: safeHref(item?.href)
|
|
1362
|
+
})).filter((item) => item.label);
|
|
1363
|
+
return /* @__PURE__ */ jsx(Breadcrumbs, { items });
|
|
1364
|
+
}
|
|
1365
|
+
var renderers = {
|
|
1366
|
+
Text: TextNode,
|
|
1367
|
+
Image: ImageNode,
|
|
1368
|
+
Icon: IconNode,
|
|
1369
|
+
Video: MediaFallback,
|
|
1370
|
+
AudioPlayer: MediaFallback,
|
|
1371
|
+
Row: RowNode,
|
|
1372
|
+
Column: ColumnNode,
|
|
1373
|
+
List: ListNode,
|
|
1374
|
+
Card: CardNode,
|
|
1375
|
+
Tabs: TabsNode,
|
|
1376
|
+
Modal: ModalNode,
|
|
1377
|
+
Divider: DividerNode,
|
|
1378
|
+
Button: ButtonNode,
|
|
1379
|
+
TextField: TextFieldNode,
|
|
1380
|
+
CheckBox: CheckBoxNode,
|
|
1381
|
+
ChoicePicker: ChoicePickerNode,
|
|
1382
|
+
Slider: SliderNode,
|
|
1383
|
+
DateTimeInput: DateTimeNode,
|
|
1384
|
+
Heading: HeadingNode,
|
|
1385
|
+
Stat: StatNode,
|
|
1386
|
+
Badge: BadgeNode,
|
|
1387
|
+
Tag: TagNode,
|
|
1388
|
+
Avatar: AvatarNode,
|
|
1389
|
+
Quote: QuoteNode,
|
|
1390
|
+
Timeline: TimelineNode,
|
|
1391
|
+
Table: TableNode,
|
|
1392
|
+
Alert: AlertNode,
|
|
1393
|
+
Progress: ProgressNode,
|
|
1394
|
+
Link: LinkNode,
|
|
1395
|
+
Grid: GridNode,
|
|
1396
|
+
Accordion: AccordionNode,
|
|
1397
|
+
CodeBlock: CodeBlockNode,
|
|
1398
|
+
Switch: SwitchNode,
|
|
1399
|
+
Select: SelectNode,
|
|
1400
|
+
IconButton: IconButtonNode,
|
|
1401
|
+
NavBar: NavBarNode,
|
|
1402
|
+
TabBar: TabBarNode,
|
|
1403
|
+
SideNav: SideNavNode,
|
|
1404
|
+
Breadcrumbs: BreadcrumbsNode,
|
|
1405
|
+
Menu: MenuNode,
|
|
1406
|
+
Popover: PopoverNode,
|
|
1407
|
+
Tooltip: TooltipNode,
|
|
1408
|
+
Spinner: SpinnerNode,
|
|
1409
|
+
Skeleton: SkeletonNode
|
|
1410
|
+
};
|
|
1411
|
+
export { A2uiSurface };
|