@monimesl/dot-renderer-react 0.1.0-alpha.3 → 0.1.0-alpha.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -1
- package/dist/LICENSE-PHOSPHOR +21 -0
- package/dist/_virtual/_rolldown/runtime.js +14 -0
- package/dist/_virtual/builtin_esm-external-require-react.js +9 -0
- package/dist/color.js +94 -0
- package/dist/components/amount-input.d.ts +6 -0
- package/dist/components/amount-input.js +111 -0
- package/dist/components/avatar.d.ts +6 -0
- package/dist/components/avatar.js +68 -0
- package/dist/components/box.js +56 -0
- package/dist/components/button.d.ts +6 -0
- package/dist/components/button.js +42 -0
- package/dist/components/carousel.d.ts +6 -0
- package/dist/components/carousel.js +258 -0
- package/dist/components/chip.d.ts +6 -0
- package/dist/components/chip.js +41 -0
- package/dist/components/code-input.d.ts +6 -0
- package/dist/components/code-input.js +96 -0
- package/dist/components/detail-row.d.ts +6 -0
- package/dist/components/detail-row.js +40 -0
- package/dist/components/disclosure.d.ts +6 -0
- package/dist/components/disclosure.js +76 -0
- package/dist/components/divider.d.ts +6 -0
- package/dist/components/divider.js +18 -0
- package/dist/components/empty-state.d.ts +6 -0
- package/dist/components/empty-state.js +64 -0
- package/dist/components/feedback.d.ts +8 -0
- package/dist/components/feedback.js +101 -0
- package/dist/components/field-box.js +44 -0
- package/dist/components/field.js +43 -0
- package/dist/components/footer.d.ts +6 -0
- package/dist/components/footer.js +25 -0
- package/dist/components/grid.d.ts +7 -0
- package/dist/components/grid.js +97 -0
- package/dist/components/https.js +11 -0
- package/dist/components/icon-artwork.js +143 -0
- package/dist/components/icon-button.js +28 -0
- package/dist/components/icon-svg.js +27 -0
- package/dist/components/icon.d.ts +6 -0
- package/dist/components/icon.js +25 -0
- package/dist/components/image.d.ts +6 -0
- package/dist/components/image.js +40 -0
- package/dist/components/index.d.ts +38 -0
- package/dist/components/index.js +92 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.js +108 -0
- package/dist/components/link.d.ts +6 -0
- package/dist/components/link.js +32 -0
- package/dist/components/list.d.ts +7 -0
- package/dist/components/list.js +143 -0
- package/dist/components/numbers.js +9 -0
- package/dist/components/option-place.js +9 -0
- package/dist/components/option.d.ts +6 -0
- package/dist/components/option.js +44 -0
- package/dist/components/padding.d.ts +2 -0
- package/dist/components/padding.js +38 -0
- package/dist/components/pressable.js +17 -0
- package/dist/components/prose-context.js +5 -0
- package/dist/components/prose.d.ts +9 -0
- package/dist/components/prose.js +67 -0
- package/dist/components/qr-code.d.ts +6 -0
- package/dist/components/qr-code.js +58 -0
- package/dist/components/rich-text.d.ts +6 -0
- package/dist/components/rich-text.js +73 -0
- package/dist/components/scroll.d.ts +6 -0
- package/dist/components/scroll.js +57 -0
- package/dist/components/select.d.ts +6 -0
- package/dist/components/select.js +93 -0
- package/dist/components/sheet.d.ts +8 -0
- package/dist/components/sheet.js +106 -0
- package/dist/components/skeleton.d.ts +6 -0
- package/dist/components/skeleton.js +55 -0
- package/dist/components/slider.d.ts +6 -0
- package/dist/components/slider.js +57 -0
- package/dist/components/spinner.d.ts +6 -0
- package/dist/components/spinner.js +48 -0
- package/dist/components/stack.d.ts +6 -0
- package/dist/components/stack.js +25 -0
- package/dist/components/stepper.d.ts +6 -0
- package/dist/components/stepper.js +92 -0
- package/dist/components/steps.d.ts +7 -0
- package/dist/components/steps.js +110 -0
- package/dist/components/tabs.d.ts +7 -0
- package/dist/components/tabs.js +95 -0
- package/dist/components/text-area.d.ts +6 -0
- package/dist/components/text-area.js +42 -0
- package/dist/components/text.d.ts +6 -0
- package/dist/components/text.js +107 -0
- package/dist/components/toast.d.ts +6 -0
- package/dist/components/toast.js +56 -0
- package/dist/components/toggles.d.ts +9 -0
- package/dist/components/toggles.js +148 -0
- package/dist/components/tokens.js +49 -0
- package/dist/components/tones.js +30 -0
- package/dist/components/typed-text.js +28 -0
- package/dist/components/view.d.ts +6 -0
- package/dist/components/view.js +61 -0
- package/dist/index.d.ts +43 -48
- package/dist/index.js +40 -1335
- package/dist/markdown.js +230 -0
- package/dist/page-root.d.ts +2 -0
- package/dist/page-root.js +20 -0
- package/dist/portal.js +8 -0
- package/dist/pull-to-refresh.js +120 -0
- package/dist/react-host/19.3.0/react-dom.js +3 -0
- package/dist/react-host/19.3.0/react-host.js +6 -6
- package/dist/renderer.d.ts +17 -0
- package/dist/renderer.js +33 -0
- package/dist/root.d.ts +10 -0
- package/dist/root.js +71 -0
- package/dist/styles.css +1 -0
- package/dist/theme.d.ts +26 -0
- package/dist/theme.js +129 -0
- package/dist/types.d.ts +7 -0
- package/dist/vendor/@base-ui/react/checkbox/indicator/CheckboxIndicator.js +51 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRoot.js +265 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/checkbox/utils/getCheckboxStateAttributesMapping.js +15 -0
- package/dist/vendor/@base-ui/react/checkbox-group/CheckboxGroupContext.js +10 -0
- package/dist/vendor/@base-ui/react/dialog/backdrop/DialogBackdrop.js +40 -0
- package/dist/vendor/@base-ui/react/dialog/close/DialogClose.js +39 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopup.js +92 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupCssVars.js +8 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupDataAttributes.js +7 -0
- package/dist/vendor/@base-ui/react/dialog/portal/DialogPortal.js +38 -0
- package/dist/vendor/@base-ui/react/dialog/portal/DialogPortalContext.js +13 -0
- package/dist/vendor/@base-ui/react/dialog/root/DialogRoot.js +16 -0
- package/dist/vendor/@base-ui/react/dialog/root/DialogRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/dialog/root/useDialogRoot.js +77 -0
- package/dist/vendor/@base-ui/react/dialog/root/useRenderDialogRoot.js +65 -0
- package/dist/vendor/@base-ui/react/dialog/store/DialogStore.js +70 -0
- package/dist/vendor/@base-ui/react/dialog/title/DialogTitle.js +25 -0
- package/dist/vendor/@base-ui/react/dialog/utils/stateAttributesMapping.js +17 -0
- package/dist/vendor/@base-ui/react/field/control/FieldControlDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/field/item/FieldItemContext.js +10 -0
- package/dist/vendor/@base-ui/react/field/root/useFieldValidation.js +18 -0
- package/dist/vendor/@base-ui/react/fieldset/root/FieldsetRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingFocusManager.js +477 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingPortal.js +165 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingRootStore.js +65 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingTree.js +22 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useDismiss.js +373 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.js +58 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/composite.js +40 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/constants.js +5 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/createAttribute.js +6 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/createEventEmitter.js +18 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/element.js +26 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/enqueueFocus.js +25 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/event.js +25 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/markOthers.js +116 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/nodes.js +16 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/tabbable.js +135 -0
- package/dist/vendor/@base-ui/react/internals/TransitionStatusDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/internals/composite/composite.js +89 -0
- package/dist/vendor/@base-ui/react/internals/composite/constants.js +4 -0
- package/dist/vendor/@base-ui/react/internals/composite/item/CompositeItem.js +21 -0
- package/dist/vendor/@base-ui/react/internals/composite/item/useCompositeItem.js +31 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/CompositeList.js +180 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/CompositeListContext.js +15 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/useCompositeListItem.js +54 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRoot.js +62 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/useCompositeRoot.js +170 -0
- package/dist/vendor/@base-ui/react/internals/constants.js +18 -0
- package/dist/vendor/@base-ui/react/internals/createBaseUIEventDetails.js +40 -0
- package/dist/vendor/@base-ui/react/internals/direction-context/DirectionContext.js +10 -0
- package/dist/vendor/@base-ui/react/internals/field-constants/constants.js +33 -0
- package/dist/vendor/@base-ui/react/internals/field-register-control/useRegisterFieldControl.js +40 -0
- package/dist/vendor/@base-ui/react/internals/field-root-context/FieldRootContext.js +45 -0
- package/dist/vendor/@base-ui/react/internals/form-context/FormContext.js +18 -0
- package/dist/vendor/@base-ui/react/internals/getStateAttributesProps.js +17 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/LabelableContext.js +24 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/useAriaLabelledBy.js +35 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/useLabelableId.js +57 -0
- package/dist/vendor/@base-ui/react/internals/reason-parts.js +14 -0
- package/dist/vendor/@base-ui/react/internals/serializeValue.js +12 -0
- package/dist/vendor/@base-ui/react/internals/stateAttributesMapping.js +11 -0
- package/dist/vendor/@base-ui/react/internals/use-button/useButton.js +137 -0
- package/dist/vendor/@base-ui/react/internals/useAnimationsFinished.js +94 -0
- package/dist/vendor/@base-ui/react/internals/useBaseUiId.js +13 -0
- package/dist/vendor/@base-ui/react/internals/useOpenChangeComplete.js +28 -0
- package/dist/vendor/@base-ui/react/internals/useRenderElement.js +109 -0
- package/dist/vendor/@base-ui/react/internals/useTransitionStatus.js +70 -0
- package/dist/vendor/@base-ui/react/internals/useValueChanged.js +15 -0
- package/dist/vendor/@base-ui/react/merge-props/mergeProps.js +153 -0
- package/dist/vendor/@base-ui/react/radio/indicator/RadioIndicator.js +46 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRoot.js +179 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/radio/utils/stateAttributesMapping.js +14 -0
- package/dist/vendor/@base-ui/react/radio-group/RadioGroup.js +170 -0
- package/dist/vendor/@base-ui/react/radio-group/RadioGroupContext.js +10 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRoot.js +170 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/switch/stateAttributesMapping.js +12 -0
- package/dist/vendor/@base-ui/react/switch/thumb/SwitchThumb.js +25 -0
- package/dist/vendor/@base-ui/react/tabs/list/TabsList.js +98 -0
- package/dist/vendor/@base-ui/react/tabs/list/TabsListContext.js +13 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRoot.js +213 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRootContext.js +16 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRootDataAttributes.js +8 -0
- package/dist/vendor/@base-ui/react/tabs/root/stateAttributesMapping.js +5 -0
- package/dist/vendor/@base-ui/react/tabs/tab/TabsTab.js +137 -0
- package/dist/vendor/@base-ui/react/utils/CommonPopupDataAttributes.js +24 -0
- package/dist/vendor/@base-ui/react/utils/CommonTriggerDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/utils/FocusGuard.js +32 -0
- package/dist/vendor/@base-ui/react/utils/InternalBackdrop.js +30 -0
- package/dist/vendor/@base-ui/react/utils/dispatchClickWithModifiers.js +25 -0
- package/dist/vendor/@base-ui/react/utils/popupStateMapping.js +22 -0
- package/dist/vendor/@base-ui/react/utils/popups/popupStoreUtils.js +247 -0
- package/dist/vendor/@base-ui/react/utils/popups/popupTriggerMap.js +96 -0
- package/dist/vendor/@base-ui/react/utils/popups/store.js +94 -0
- package/dist/vendor/@base-ui/react/utils/resolveClassName.js +13 -0
- package/dist/vendor/@base-ui/react/utils/resolveRef.js +11 -0
- package/dist/vendor/@base-ui/react/utils/resolveStyle.js +13 -0
- package/dist/vendor/@base-ui/react/utils/useFocusableWhenDisabled.js +30 -0
- package/dist/vendor/@base-ui/utils/addEventListener.js +12 -0
- package/dist/vendor/@base-ui/utils/createLogOnce.js +20 -0
- package/dist/vendor/@base-ui/utils/empty.js +6 -0
- package/dist/vendor/@base-ui/utils/error.js +5 -0
- package/dist/vendor/@base-ui/utils/fastHooks.js +68 -0
- package/dist/vendor/@base-ui/utils/formatErrorMessage.js +27 -0
- package/dist/vendor/@base-ui/utils/getDefaultFormSubmitter.js +25 -0
- package/dist/vendor/@base-ui/utils/getReactElementRef.js +14 -0
- package/dist/vendor/@base-ui/utils/inertValue.js +8 -0
- package/dist/vendor/@base-ui/utils/isElementDisabled.js +6 -0
- package/dist/vendor/@base-ui/utils/mergeCleanups.js +14 -0
- package/dist/vendor/@base-ui/utils/mergeObjects.js +11 -0
- package/dist/vendor/@base-ui/utils/owner.js +7 -0
- package/dist/vendor/@base-ui/utils/platform/engine.js +8 -0
- package/dist/vendor/@base-ui/utils/platform/env.js +6 -0
- package/dist/vendor/@base-ui/utils/platform/os.js +15 -0
- package/dist/vendor/@base-ui/utils/platform/screen-reader.js +9 -0
- package/dist/vendor/@base-ui/utils/platform/shared.js +36 -0
- package/dist/vendor/@base-ui/utils/reactVersion.js +8 -0
- package/dist/vendor/@base-ui/utils/safeReact.js +13 -0
- package/dist/vendor/@base-ui/utils/shadowDom.js +26 -0
- package/dist/vendor/@base-ui/utils/store/ReactStore.js +181 -0
- package/dist/vendor/@base-ui/utils/store/Store.js +102 -0
- package/dist/vendor/@base-ui/utils/store/useStore.js +97 -0
- package/dist/vendor/@base-ui/utils/useAnimationFrame.js +87 -0
- package/dist/vendor/@base-ui/utils/useControlled.js +52 -0
- package/dist/vendor/@base-ui/utils/useId.js +32 -0
- package/dist/vendor/@base-ui/utils/useIsoLayoutEffect.js +7 -0
- package/dist/vendor/@base-ui/utils/useMergedRefs.js +87 -0
- package/dist/vendor/@base-ui/utils/useOnMount.js +12 -0
- package/dist/vendor/@base-ui/utils/useRefWithInit.js +18 -0
- package/dist/vendor/@base-ui/utils/useScrollLock.js +206 -0
- package/dist/vendor/@base-ui/utils/useStableCallback.js +38 -0
- package/dist/vendor/@base-ui/utils/useTimeout.js +43 -0
- package/dist/vendor/@base-ui/utils/useValueAsRef.js +27 -0
- package/dist/vendor/@base-ui/utils/visuallyHidden.js +23 -0
- package/dist/vendor/@base-ui/utils/warn.js +5 -0
- package/dist/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js +49 -0
- package/dist/vendor/uqr/dist/index.js +858 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +74 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +77 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +69 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +64 -0
- package/dist/vendor/use-sync-external-store/shim/index.js +11 -0
- package/dist/vendor/use-sync-external-store/shim/with-selector.js +11 -0
- package/package.json +15 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
1
|
# @monimesl/dot-renderer-react
|
|
2
2
|
|
|
3
|
-
Renders Dot pages with React.
|
|
3
|
+
Renders Dot pages with React. Every dot runs with this renderer. Dots get it through
|
|
4
|
+
`@monimesl/dot-runtime` and never import it themselves.
|
|
5
|
+
|
|
6
|
+
## How it draws
|
|
7
|
+
|
|
8
|
+
Each built-in component is a React component that draws plain elements with inline styles, in
|
|
9
|
+
the colors and shape of the dot's theme. A small stylesheet, `dist/styles.css`, covers what inline
|
|
10
|
+
styles can't do, such as keyframes and scroll bars. The compiler copies it into each dot as
|
|
11
|
+
`dot.css`.
|
|
12
|
+
|
|
13
|
+
Five components use [Base UI](https://base-ui.com)'s headless parts for the focus, keyboard and
|
|
14
|
+
screen-reader behaviour that is hard to get right: `Sheet` (and the sheet a `Select` opens), `Tabs`,
|
|
15
|
+
`Switch`, `Checkbox` and `RadioGroup`. A sheet keeps focus inside it, closes on Escape and stops the
|
|
16
|
+
page behind from scrolling. Fields link their hint or error to the control they describe.
|
|
17
|
+
|
|
18
|
+
Icons are [Phosphor](https://phosphoricons.com)'s bold artwork. A script generates them into the
|
|
19
|
+
source at build time, from `@phosphor-icons/core`.
|
|
20
|
+
|
|
21
|
+
## The theme
|
|
22
|
+
|
|
23
|
+
A dot sets `scheme`, `colors` and `shape` in `defineDot`. The colors are `primary`, `background`,
|
|
24
|
+
`surface`, `text`, `muted`, `border` and `subtle`, each for light and dark, and `custom` for the
|
|
25
|
+
dot's own named colors. A page can set its own colors over the theme's, with `configs.colors` or
|
|
26
|
+
`setColors`. The renderer fills in the rest of the palette from Dash's own look. On a background
|
|
27
|
+
that isn't Dash's, it works out surfaces and quieter text that sit well on it. `useTheme()` gives a
|
|
28
|
+
component the resolved theme.
|
|
29
|
+
|
|
30
|
+
## Only the components a dot uses
|
|
31
|
+
|
|
32
|
+
A dot's production build carries only the components its pages use. The compiler lists them from
|
|
33
|
+
the pages, imports each one by name and makes the webview with
|
|
34
|
+
`createReactRenderer({ components })`. The renderer is built as one file per module, with the
|
|
35
|
+
libraries it bundles under `dist/vendor/`. So a dot's bundle can leave out a component, and
|
|
36
|
+
anything only that component imports. A development build has every component, because a hot reload
|
|
37
|
+
keeps the renderer the page already runs with.
|
|
38
|
+
|
|
39
|
+
`reactRenderer()`, the default export, makes a renderer with every built-in component. Pass
|
|
40
|
+
`components` to add or replace some, and `wrapper` to wrap each page.
|
|
41
|
+
|
|
42
|
+
## React
|
|
43
|
+
|
|
44
|
+
Hosts serve React, so dots don't bundle it. This package's build makes the React that hosts ship,
|
|
45
|
+
in `dist/react-host/<version>/`. A dot's page imports it through an import map.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Phosphor Icons
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
4
|
+
var __exportAll = (all, no_symbols) => {
|
|
5
|
+
let target = {};
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { __commonJSMin, __exportAll };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __commonJSMin } from "./_rolldown/runtime.js";
|
|
2
|
+
import * as m from "react";
|
|
3
|
+
//#region builtin:esm-external-require-react
|
|
4
|
+
var require_builtin_esm_external_require_react = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
|
+
module.exports = { ...m };
|
|
6
|
+
}));
|
|
7
|
+
//#endregion
|
|
8
|
+
export default require_builtin_esm_external_require_react();
|
|
9
|
+
export { require_builtin_esm_external_require_react };
|
package/dist/color.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//#region src/color.ts
|
|
2
|
+
function mix(from, to, amount) {
|
|
3
|
+
const end = channels(to);
|
|
4
|
+
return toHex(channels(from).map((start, index) => start + (end[index] - start) * amount));
|
|
5
|
+
}
|
|
6
|
+
function darken(color, points) {
|
|
7
|
+
const [hue, saturation, lightness] = toHsl(channels(color));
|
|
8
|
+
return toHex(fromHsl(hue, saturation, Math.max(0, lightness - points / 100)));
|
|
9
|
+
}
|
|
10
|
+
function channels(color) {
|
|
11
|
+
let hex = color.slice(1);
|
|
12
|
+
if (hex.length === 3 || hex.length === 4) hex = [...hex].map((digit) => digit + digit).join("");
|
|
13
|
+
const [red, green, blue] = [
|
|
14
|
+
0,
|
|
15
|
+
2,
|
|
16
|
+
4
|
|
17
|
+
].map((offset) => parseInt(hex.slice(offset, offset + 2), 16));
|
|
18
|
+
return [
|
|
19
|
+
red,
|
|
20
|
+
green,
|
|
21
|
+
blue
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
function toHex(rgb) {
|
|
25
|
+
return `#${rgb.map((channel) => Math.round(channel).toString(16).padStart(2, "0")).join("")}`;
|
|
26
|
+
}
|
|
27
|
+
function toHsl([red, green, blue]) {
|
|
28
|
+
const redShare = red / 255;
|
|
29
|
+
const greenShare = green / 255;
|
|
30
|
+
const blueShare = blue / 255;
|
|
31
|
+
const max = Math.max(redShare, greenShare, blueShare);
|
|
32
|
+
const min = Math.min(redShare, greenShare, blueShare);
|
|
33
|
+
const lightness = (max + min) / 2;
|
|
34
|
+
const chroma = max - min;
|
|
35
|
+
if (chroma === 0) return [
|
|
36
|
+
0,
|
|
37
|
+
0,
|
|
38
|
+
lightness
|
|
39
|
+
];
|
|
40
|
+
const saturation = chroma / (1 - Math.abs(2 * lightness - 1));
|
|
41
|
+
let hue;
|
|
42
|
+
if (max === redShare) hue = (greenShare - blueShare) / chroma % 6;
|
|
43
|
+
else if (max === greenShare) hue = (blueShare - redShare) / chroma + 2;
|
|
44
|
+
else hue = (redShare - greenShare) / chroma + 4;
|
|
45
|
+
return [
|
|
46
|
+
(hue * 60 + 360) % 360,
|
|
47
|
+
saturation,
|
|
48
|
+
lightness
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
function fromHsl(hue, saturation, lightness) {
|
|
52
|
+
const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
53
|
+
const middle = chroma * (1 - Math.abs(hue / 60 % 2 - 1));
|
|
54
|
+
const [red, green, blue] = [
|
|
55
|
+
[
|
|
56
|
+
chroma,
|
|
57
|
+
middle,
|
|
58
|
+
0
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
middle,
|
|
62
|
+
chroma,
|
|
63
|
+
0
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
0,
|
|
67
|
+
chroma,
|
|
68
|
+
middle
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
0,
|
|
72
|
+
middle,
|
|
73
|
+
chroma
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
middle,
|
|
77
|
+
0,
|
|
78
|
+
chroma
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
chroma,
|
|
82
|
+
0,
|
|
83
|
+
middle
|
|
84
|
+
]
|
|
85
|
+
][Math.floor(hue / 60) % 6];
|
|
86
|
+
const lift = lightness - chroma / 2;
|
|
87
|
+
return [
|
|
88
|
+
(red + lift) * 255,
|
|
89
|
+
(green + lift) * 255,
|
|
90
|
+
(blue + lift) * 255
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { darken, mix };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useTheme } from "../theme.js";
|
|
2
|
+
import { SPACE, WEIGHTS } from "./tokens.js";
|
|
3
|
+
import { Field } from "./field.js";
|
|
4
|
+
import { BARE_INPUT_STYLE, useFieldBox, useFieldNote } from "./field-box.js";
|
|
5
|
+
import { useTypedText } from "./typed-text.js";
|
|
6
|
+
import { createEvent } from "@monimesl/dot-core";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/amount-input.tsx
|
|
9
|
+
const AMOUNT_FONT_SIZE = 28;
|
|
10
|
+
const DEFAULT_CURRENCY = "SLE";
|
|
11
|
+
const AmountInput$1 = ({ value, currency = DEFAULT_CURRENCY, minorUnits, unit = "minor", label, placeholder, hint, error, disabled, onChange }) => {
|
|
12
|
+
const { colors } = useTheme();
|
|
13
|
+
const decimalPlaces = minorUnits === void 0 ? currencyMinorUnits(currency) : Math.max(0, Math.round(minorUnits));
|
|
14
|
+
const scale = unit === "major" ? 10 ** decimalPlaces : 1;
|
|
15
|
+
const formatAmount = (minor) => formatMinorUnits(minor, decimalPlaces);
|
|
16
|
+
const [text, typeText, reshowText] = useTypedText(amountText(value, scale), onChange !== void 0, (sent) => sent === "" ? "" : formatAmount(Number(sent)));
|
|
17
|
+
const box = useFieldBox(error, disabled);
|
|
18
|
+
const { noteId, controlAttributes } = useFieldNote(hint, error);
|
|
19
|
+
return /* @__PURE__ */ jsx(Field, {
|
|
20
|
+
label,
|
|
21
|
+
hint,
|
|
22
|
+
error,
|
|
23
|
+
noteId,
|
|
24
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
25
|
+
className: "dot-amount-input",
|
|
26
|
+
style: {
|
|
27
|
+
...box.style,
|
|
28
|
+
display: "flex",
|
|
29
|
+
alignItems: "baseline",
|
|
30
|
+
gap: SPACE.medium,
|
|
31
|
+
padding: "10px 14px"
|
|
32
|
+
},
|
|
33
|
+
children: [currency ? /* @__PURE__ */ jsx("span", {
|
|
34
|
+
style: {
|
|
35
|
+
color: colors.subtle,
|
|
36
|
+
fontSize: 20,
|
|
37
|
+
fontWeight: WEIGHTS.medium
|
|
38
|
+
},
|
|
39
|
+
children: currency
|
|
40
|
+
}) : null, /* @__PURE__ */ jsx("input", {
|
|
41
|
+
value: text,
|
|
42
|
+
placeholder: placeholder ?? formatAmount(0),
|
|
43
|
+
inputMode: decimalPlaces > 0 ? "decimal" : "numeric",
|
|
44
|
+
disabled,
|
|
45
|
+
...controlAttributes,
|
|
46
|
+
onFocus: box.onFocus,
|
|
47
|
+
onBlur: () => {
|
|
48
|
+
box.onBlur();
|
|
49
|
+
const amount = toMinorUnits(text, decimalPlaces);
|
|
50
|
+
if (amount !== null) reshowText(formatAmount(amount));
|
|
51
|
+
},
|
|
52
|
+
onChange: (event) => {
|
|
53
|
+
const typed = cleanAmount(event.currentTarget.value, decimalPlaces);
|
|
54
|
+
const amount = toMinorUnits(typed, decimalPlaces);
|
|
55
|
+
typeText(typed, amount === null ? "" : String(amount));
|
|
56
|
+
onChange?.(createEvent("change", { value: amount === null ? null : amount / scale }));
|
|
57
|
+
},
|
|
58
|
+
style: {
|
|
59
|
+
...BARE_INPUT_STYLE,
|
|
60
|
+
padding: 0,
|
|
61
|
+
fontSize: AMOUNT_FONT_SIZE,
|
|
62
|
+
fontWeight: WEIGHTS.bold
|
|
63
|
+
}
|
|
64
|
+
})]
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
function currencyMinorUnits(currency) {
|
|
69
|
+
try {
|
|
70
|
+
return new Intl.NumberFormat("en", {
|
|
71
|
+
style: "currency",
|
|
72
|
+
currency
|
|
73
|
+
}).resolvedOptions().maximumFractionDigits ?? 2;
|
|
74
|
+
} catch {
|
|
75
|
+
return 2;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function amountText(value, scale) {
|
|
79
|
+
if (value === void 0) return;
|
|
80
|
+
return Number.isFinite(value) ? String(Math.round(value * scale)) : "";
|
|
81
|
+
}
|
|
82
|
+
function cleanAmount(typed, decimalPlaces) {
|
|
83
|
+
const [whole = "", ...fractions] = typed.replace(/[^\d.]/g, "").split(".");
|
|
84
|
+
let wholeDigits = whole.replace(/^0+/, "");
|
|
85
|
+
if (wholeDigits === "" && whole !== "") wholeDigits = "0";
|
|
86
|
+
if (decimalPlaces === 0 || fractions.length === 0) return groupThousands(wholeDigits);
|
|
87
|
+
if (wholeDigits === "") wholeDigits = "0";
|
|
88
|
+
const fraction = fractions.join("").slice(0, decimalPlaces);
|
|
89
|
+
return `${groupThousands(wholeDigits)}.${fraction}`;
|
|
90
|
+
}
|
|
91
|
+
function toMinorUnits(text, decimalPlaces) {
|
|
92
|
+
const plain = text.replaceAll(",", "");
|
|
93
|
+
if (plain === "") return null;
|
|
94
|
+
const [whole = "", fraction = ""] = plain.split(".");
|
|
95
|
+
const fractionDigits = fraction.padEnd(decimalPlaces, "0").slice(0, decimalPlaces);
|
|
96
|
+
return Number(`${whole}${fractionDigits}`);
|
|
97
|
+
}
|
|
98
|
+
function formatMinorUnits(minorUnits, decimalPlaces) {
|
|
99
|
+
const digits = String(Math.abs(minorUnits)).padStart(decimalPlaces + 1, "0");
|
|
100
|
+
const wholeEnd = digits.length - decimalPlaces;
|
|
101
|
+
const grouped = groupThousands(digits.slice(0, wholeEnd));
|
|
102
|
+
if (decimalPlaces === 0) return grouped;
|
|
103
|
+
return `${grouped}.${digits.slice(wholeEnd)}`;
|
|
104
|
+
}
|
|
105
|
+
function groupThousands(digits) {
|
|
106
|
+
const groups = [];
|
|
107
|
+
for (let end = digits.length; end > 0; end -= 3) groups.unshift(digits.slice(Math.max(0, end - 3), end));
|
|
108
|
+
return groups.join(",");
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { AmountInput$1 as AmountInput };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useTheme } from "../theme.js";
|
|
2
|
+
import { WEIGHTS } from "./tokens.js";
|
|
3
|
+
import { USER_ARTWORK } from "./icon-artwork.js";
|
|
4
|
+
import { IconSvg } from "./icon-svg.js";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/avatar.tsx
|
|
8
|
+
const AVATAR_SIZE = {
|
|
9
|
+
small: 32,
|
|
10
|
+
medium: 40,
|
|
11
|
+
large: 56
|
|
12
|
+
};
|
|
13
|
+
function initials(name) {
|
|
14
|
+
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
15
|
+
if (words.length === 0) return "";
|
|
16
|
+
const firstInitial = initialOf(words[0]);
|
|
17
|
+
if (words.length === 1) return firstInitial;
|
|
18
|
+
return firstInitial + initialOf(words[words.length - 1]);
|
|
19
|
+
}
|
|
20
|
+
function initialOf(word) {
|
|
21
|
+
return word.charAt(0).toUpperCase();
|
|
22
|
+
}
|
|
23
|
+
const Avatar = ({ name = "", image, size = "medium" }) => {
|
|
24
|
+
const { colors } = useTheme();
|
|
25
|
+
const [failedImage, setFailedImage] = useState();
|
|
26
|
+
const pixels = AVATAR_SIZE[size];
|
|
27
|
+
const letters = initials(name);
|
|
28
|
+
let content;
|
|
29
|
+
if (image && failedImage !== image) content = /* @__PURE__ */ jsx("img", {
|
|
30
|
+
src: image,
|
|
31
|
+
alt: "",
|
|
32
|
+
onError: () => setFailedImage(image),
|
|
33
|
+
style: {
|
|
34
|
+
width: "100%",
|
|
35
|
+
height: "100%",
|
|
36
|
+
objectFit: "cover"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
else if (letters) content = letters;
|
|
40
|
+
else content = /* @__PURE__ */ jsx(IconSvg, {
|
|
41
|
+
artwork: USER_ARTWORK,
|
|
42
|
+
size: Math.round(pixels * .55),
|
|
43
|
+
color: "currentColor"
|
|
44
|
+
});
|
|
45
|
+
return /* @__PURE__ */ jsx("span", {
|
|
46
|
+
className: "dot-avatar",
|
|
47
|
+
role: "img",
|
|
48
|
+
"aria-label": name || void 0,
|
|
49
|
+
style: {
|
|
50
|
+
display: "inline-flex",
|
|
51
|
+
flexShrink: 0,
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
justifyContent: "center",
|
|
54
|
+
width: pixels,
|
|
55
|
+
height: pixels,
|
|
56
|
+
borderRadius: "50%",
|
|
57
|
+
overflow: "hidden",
|
|
58
|
+
background: colors.muted,
|
|
59
|
+
color: colors.subtle,
|
|
60
|
+
fontSize: Math.round(pixels * .4),
|
|
61
|
+
fontWeight: WEIGHTS.bold,
|
|
62
|
+
lineHeight: 1
|
|
63
|
+
},
|
|
64
|
+
children: content
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { Avatar };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { CARD_RADIUS_SCALE } from "./tokens.js";
|
|
2
|
+
import { isTone, toneBackground } from "./tones.js";
|
|
3
|
+
import { BACKGROUNDS } from "@monimesl/dot-core";
|
|
4
|
+
//#region src/components/box.ts
|
|
5
|
+
const RADIUS_SCALE = {
|
|
6
|
+
none: 0,
|
|
7
|
+
small: .5,
|
|
8
|
+
medium: 1,
|
|
9
|
+
large: CARD_RADIUS_SCALE
|
|
10
|
+
};
|
|
11
|
+
const FULL_RADIUS = 9999;
|
|
12
|
+
const BACKGROUND_WORDS = new Set(BACKGROUNDS.words);
|
|
13
|
+
function boxStyle(props, theme, look = {}) {
|
|
14
|
+
const background = props.background ?? look.background;
|
|
15
|
+
const border = props.border ?? look.border;
|
|
16
|
+
const radius = props.radius ?? look.radius;
|
|
17
|
+
const style = {};
|
|
18
|
+
if (background !== void 0) style.background = backgroundColor(background, theme);
|
|
19
|
+
if (border === "none") style.border = "none";
|
|
20
|
+
else if (border !== void 0) style.border = `1px solid ${border === "strong" ? theme.colors.subtle : theme.colors.border}`;
|
|
21
|
+
if (radius !== void 0) {
|
|
22
|
+
style.borderRadius = radius === "full" ? FULL_RADIUS : theme.radius * RADIUS_SCALE[radius];
|
|
23
|
+
style.overflow = "hidden";
|
|
24
|
+
}
|
|
25
|
+
if (props.width !== void 0) {
|
|
26
|
+
style.width = cssLength(props.width);
|
|
27
|
+
style.flexShrink = 0;
|
|
28
|
+
}
|
|
29
|
+
if (props.aspect !== void 0) style.aspectRatio = props.aspect.replace(":", " / ");
|
|
30
|
+
else if (props.height !== void 0) {
|
|
31
|
+
style.height = cssLength(props.height);
|
|
32
|
+
style.flexShrink = 0;
|
|
33
|
+
}
|
|
34
|
+
if (props.minHeight !== void 0) style.minHeight = props.minHeight;
|
|
35
|
+
if (props.maxWidth !== void 0) style.maxWidth = props.maxWidth;
|
|
36
|
+
return style;
|
|
37
|
+
}
|
|
38
|
+
function backgroundColor(background, theme) {
|
|
39
|
+
if (isTone(background)) return toneBackground(theme.colors, background);
|
|
40
|
+
if (BACKGROUND_WORDS.has(background)) return theme.colors[background];
|
|
41
|
+
return customColor(background, theme);
|
|
42
|
+
}
|
|
43
|
+
const unknownColors = /* @__PURE__ */ new Set();
|
|
44
|
+
function customColor(name, theme) {
|
|
45
|
+
const color = theme.customColors[name];
|
|
46
|
+
if (color === void 0 && !unknownColors.has(name)) {
|
|
47
|
+
unknownColors.add(name);
|
|
48
|
+
console.warn(`The theme has no colour named "${name}". Add it to colors.custom in dot.ts.`);
|
|
49
|
+
}
|
|
50
|
+
return color;
|
|
51
|
+
}
|
|
52
|
+
function cssLength(value) {
|
|
53
|
+
return value === "fill" ? "100%" : value;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { boxStyle, customColor };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useTheme } from "../theme.js";
|
|
2
|
+
import { DISABLED_OPACITY, FONT_SIZE, ICON_SIZE, SPACE, WEIGHTS } from "./tokens.js";
|
|
3
|
+
import { LoadingIcon } from "./spinner.js";
|
|
4
|
+
import { createEvent } from "@monimesl/dot-core";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/button.tsx
|
|
7
|
+
const Button$1 = ({ variant = "primary", disabled, loading, onClick, children }) => {
|
|
8
|
+
const { colors, radius } = useTheme();
|
|
9
|
+
const filled = variant === "primary" && !disabled;
|
|
10
|
+
let color = colors.text;
|
|
11
|
+
if (filled) color = colors.onPrimary;
|
|
12
|
+
else if (disabled) color = colors.subtle;
|
|
13
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
14
|
+
type: "button",
|
|
15
|
+
className: "dot-button",
|
|
16
|
+
"data-variant": variant,
|
|
17
|
+
disabled: Boolean(disabled),
|
|
18
|
+
"aria-busy": loading || void 0,
|
|
19
|
+
"aria-disabled": loading || void 0,
|
|
20
|
+
onClick: onClick && !loading ? () => onClick(createEvent("click")) : void 0,
|
|
21
|
+
style: {
|
|
22
|
+
display: "inline-flex",
|
|
23
|
+
alignItems: "center",
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
gap: SPACE.medium,
|
|
26
|
+
minHeight: 48,
|
|
27
|
+
padding: "12px 20px",
|
|
28
|
+
border: "none",
|
|
29
|
+
borderRadius: radius,
|
|
30
|
+
background: filled ? colors.primary : colors.muted,
|
|
31
|
+
color,
|
|
32
|
+
fontSize: FONT_SIZE.body,
|
|
33
|
+
fontWeight: WEIGHTS.bold,
|
|
34
|
+
lineHeight: "normal",
|
|
35
|
+
opacity: disabled ? DISABLED_OPACITY : 1,
|
|
36
|
+
cursor: disabled || loading ? "default" : "pointer"
|
|
37
|
+
},
|
|
38
|
+
children: [loading ? /* @__PURE__ */ jsx(LoadingIcon, { size: ICON_SIZE.small }) : null, children]
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Button$1 as Button };
|