@monimesl/dot-renderer-react 0.1.0-alpha.7 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -1
- package/dist/LICENSE-PHOSPHOR +21 -21
- package/dist/_virtual/_rolldown/runtime.js +14 -0
- package/dist/_virtual/builtin_esm-external-require-react.js +9 -0
- package/dist/color.js +105 -0
- package/dist/components/amount-input.d.ts +6 -0
- package/dist/components/amount-input.js +106 -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 +254 -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 +97 -0
- package/dist/components/detail-row.d.ts +6 -0
- package/dist/components/detail-row.js +40 -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 +66 -0
- package/dist/components/feedback.d.ts +8 -0
- package/dist/components/feedback.js +85 -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 +24 -0
- package/dist/components/grid.d.ts +7 -0
- package/dist/components/grid.js +98 -0
- package/dist/components/icon-artwork.js +74 -0
- package/dist/components/icon.d.ts +6 -0
- package/dist/components/icon.js +40 -0
- package/dist/components/image.d.ts +6 -0
- package/dist/components/image.js +40 -0
- package/dist/components/index.d.ts +30 -0
- package/dist/components/index.js +72 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.js +86 -0
- package/dist/components/link.d.ts +6 -0
- package/dist/components/link.js +39 -0
- package/dist/components/list.d.ts +7 -0
- package/dist/components/list.js +143 -0
- package/dist/components/option-place.js +9 -0
- package/dist/components/option.d.ts +6 -0
- package/dist/components/option.js +43 -0
- package/dist/components/padding.d.ts +2 -0
- package/dist/components/padding.js +27 -0
- package/dist/components/pressable.js +17 -0
- package/dist/components/qr-code.d.ts +6 -0
- package/dist/components/qr-code.js +58 -0
- package/dist/components/scroll.d.ts +6 -0
- package/dist/components/scroll.js +55 -0
- package/dist/components/select.d.ts +6 -0
- package/dist/components/select.js +92 -0
- package/dist/components/sheet.d.ts +8 -0
- package/dist/components/sheet.js +105 -0
- package/dist/components/skeleton.d.ts +6 -0
- package/dist/components/skeleton.js +55 -0
- package/dist/components/spinner.d.ts +6 -0
- package/dist/components/spinner.js +48 -0
- package/dist/components/tabs.d.ts +7 -0
- package/dist/components/tabs.js +91 -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 +46 -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 +149 -0
- package/dist/components/tokens.js +37 -0
- package/dist/components/tones.js +24 -0
- package/dist/components/typed-text.js +28 -0
- package/dist/components/view.d.ts +6 -0
- package/dist/components/view.js +51 -0
- package/dist/index.d.ts +35 -64
- package/dist/index.js +32 -22636
- package/dist/page-root.d.ts +2 -0
- package/dist/page-root.js +20 -0
- package/dist/portal.js +8 -0
- package/dist/renderer.d.ts +17 -0
- package/dist/renderer.js +33 -0
- package/dist/root.d.ts +10 -0
- package/dist/root.js +51 -0
- package/dist/styles.css +95 -1
- package/dist/theme.d.ts +25 -0
- package/dist/theme.js +84 -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 +8 -14
- package/dist/garra-versions.json +0 -7
package/README.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
1
|
# @monimesl/dot-renderer-react
|
|
2
2
|
|
|
3
|
-
Renders Dot pages with React. It is the
|
|
3
|
+
Renders Dot pages with React. It is the renderer every dot runs with: dots depend on
|
|
4
|
+
`@monimesl/dot-runtime`, which brings it in, 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 Dot's own inline
|
|
9
|
+
styles, in the colors and shape of the dot's theme. A small stylesheet, `dist/styles.css`, holds
|
|
10
|
+
what inline styles can't say, such as keyframes and scroll bars; the compiler copies it into each
|
|
11
|
+
dot as `dot.css`.
|
|
12
|
+
|
|
13
|
+
[Base UI](https://base-ui.com)'s headless parts give five components 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, generated into the source at build
|
|
19
|
+
time from `@phosphor-icons/core`.
|
|
20
|
+
|
|
21
|
+
## The theme
|
|
22
|
+
|
|
23
|
+
A dot sets `scheme`, its `colors` (`primary`, `background`, `surface` and `text`, each for light
|
|
24
|
+
and dark) and `shape` in `defineDot`. The renderer fills in the rest of its palette, the neutrals
|
|
25
|
+
and the status colors, from Dash's own look. `useTheme()` gives a component the resolved theme.
|
|
26
|
+
|
|
27
|
+
## Only the components a dot uses
|
|
28
|
+
|
|
29
|
+
A dot's production build carries only the components its pages use. The compiler lists them from
|
|
30
|
+
the pages and makes the webview with `createReactRenderer({ components })`, importing each one by
|
|
31
|
+
name. The renderer is built as a file per module, with the libraries it bundles under
|
|
32
|
+
`dist/vendor/`, so a dot's bundle leaves out a component, and what only it imports, entirely. A
|
|
33
|
+
development build has every component, since a hot reload keeps the renderer a page runs with.
|
|
34
|
+
|
|
35
|
+
`reactRenderer()`, the default export, makes a renderer with every built-in component, and takes
|
|
36
|
+
`components` to add or replace some, and a `wrapper` around each page.
|
|
37
|
+
|
|
38
|
+
## React
|
|
39
|
+
|
|
40
|
+
Hosts serve React, so dots don't bundle it. The build makes the React that hosts ship, in
|
|
41
|
+
`dist/react-host/<version>/`, and a dot's page imports it through an import map.
|
package/dist/LICENSE-PHOSPHOR
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c)
|
|
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.
|
|
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,105 @@
|
|
|
1
|
+
//#region src/color.ts
|
|
2
|
+
const READABLE_CONTRAST = 4.5;
|
|
3
|
+
function contrast(first, second) {
|
|
4
|
+
const [lighter, darker] = [luminance(first), luminance(second)].sort((a, b) => b - a);
|
|
5
|
+
return (lighter + .05) / (darker + .05);
|
|
6
|
+
}
|
|
7
|
+
function darken(color, points) {
|
|
8
|
+
const [hue, saturation, lightness] = toHsl(channels(color));
|
|
9
|
+
return toHex(fromHsl(hue, saturation, Math.max(0, lightness - points / 100)));
|
|
10
|
+
}
|
|
11
|
+
function luminance(color) {
|
|
12
|
+
const [red, green, blue] = channels(color).map((channel) => {
|
|
13
|
+
const share = channel / 255;
|
|
14
|
+
return share <= .03928 ? share / 12.92 : ((share + .055) / 1.055) ** 2.4;
|
|
15
|
+
});
|
|
16
|
+
return .2126 * red + .7152 * green + .0722 * blue;
|
|
17
|
+
}
|
|
18
|
+
function channels(color) {
|
|
19
|
+
let hex = color.slice(1);
|
|
20
|
+
if (hex.length === 3 || hex.length === 4) hex = [...hex].map((digit) => digit + digit).join("");
|
|
21
|
+
const [red, green, blue] = [
|
|
22
|
+
0,
|
|
23
|
+
2,
|
|
24
|
+
4
|
|
25
|
+
].map((start) => parseInt(hex.slice(start, start + 2), 16));
|
|
26
|
+
return [
|
|
27
|
+
red,
|
|
28
|
+
green,
|
|
29
|
+
blue
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
function toHex(rgb) {
|
|
33
|
+
return `#${rgb.map((channel) => Math.round(channel).toString(16).padStart(2, "0")).join("")}`;
|
|
34
|
+
}
|
|
35
|
+
function toHsl([red, green, blue]) {
|
|
36
|
+
const [r, g, b] = [
|
|
37
|
+
red / 255,
|
|
38
|
+
green / 255,
|
|
39
|
+
blue / 255
|
|
40
|
+
];
|
|
41
|
+
const max = Math.max(r, g, b);
|
|
42
|
+
const min = Math.min(r, g, b);
|
|
43
|
+
const lightness = (max + min) / 2;
|
|
44
|
+
const chroma = max - min;
|
|
45
|
+
if (chroma === 0) return [
|
|
46
|
+
0,
|
|
47
|
+
0,
|
|
48
|
+
lightness
|
|
49
|
+
];
|
|
50
|
+
const saturation = chroma / (1 - Math.abs(2 * lightness - 1));
|
|
51
|
+
let hue;
|
|
52
|
+
if (max === r) hue = (g - b) / chroma % 6;
|
|
53
|
+
else if (max === g) hue = (b - r) / chroma + 2;
|
|
54
|
+
else hue = (r - g) / chroma + 4;
|
|
55
|
+
return [
|
|
56
|
+
(hue * 60 + 360) % 360,
|
|
57
|
+
saturation,
|
|
58
|
+
lightness
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
function fromHsl(hue, saturation, lightness) {
|
|
62
|
+
const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
63
|
+
const second = chroma * (1 - Math.abs(hue / 60 % 2 - 1));
|
|
64
|
+
const sector = Math.floor(hue / 60) % 6;
|
|
65
|
+
const [r, g, b] = [
|
|
66
|
+
[
|
|
67
|
+
chroma,
|
|
68
|
+
second,
|
|
69
|
+
0
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
second,
|
|
73
|
+
chroma,
|
|
74
|
+
0
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
0,
|
|
78
|
+
chroma,
|
|
79
|
+
second
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
0,
|
|
83
|
+
second,
|
|
84
|
+
chroma
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
second,
|
|
88
|
+
0,
|
|
89
|
+
chroma
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
chroma,
|
|
93
|
+
0,
|
|
94
|
+
second
|
|
95
|
+
]
|
|
96
|
+
][sector];
|
|
97
|
+
const lift = lightness - chroma / 2;
|
|
98
|
+
return [
|
|
99
|
+
(r + lift) * 255,
|
|
100
|
+
(g + lift) * 255,
|
|
101
|
+
(b + lift) * 255
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { READABLE_CONTRAST, contrast, darken };
|
|
@@ -0,0 +1,106 @@
|
|
|
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 places = minorUnits === void 0 ? currencyMinorUnits(currency) : Math.max(0, Math.round(minorUnits));
|
|
14
|
+
const scale = unit === "major" ? 10 ** places : 1;
|
|
15
|
+
const show = (minor) => formatMinorUnits(minor, places);
|
|
16
|
+
const [text, typeText, reshowText] = useTypedText(amountText(value, scale), onChange !== void 0, (sent) => sent === "" ? "" : show(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 ?? show(0),
|
|
43
|
+
inputMode: places > 0 ? "decimal" : "numeric",
|
|
44
|
+
disabled,
|
|
45
|
+
...controlAttributes,
|
|
46
|
+
onFocus: box.onFocus,
|
|
47
|
+
onBlur: () => {
|
|
48
|
+
box.onBlur();
|
|
49
|
+
const amount = toMinorUnits(text, places);
|
|
50
|
+
if (amount !== null) reshowText(show(amount));
|
|
51
|
+
},
|
|
52
|
+
onChange: (event) => {
|
|
53
|
+
const typed = cleanAmount(event.currentTarget.value, places);
|
|
54
|
+
const amount = toMinorUnits(typed, places);
|
|
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, places) {
|
|
83
|
+
const [whole = "", ...fractions] = typed.replace(/[^\d.]/g, "").split(".");
|
|
84
|
+
const digits = whole.replace(/^0+/, "") || whole.slice(0, 1);
|
|
85
|
+
if (places === 0 || fractions.length === 0) return groupThousands(digits);
|
|
86
|
+
const fraction = fractions.join("").slice(0, places);
|
|
87
|
+
return `${groupThousands(digits) || "0"}.${fraction}`;
|
|
88
|
+
}
|
|
89
|
+
function toMinorUnits(text, places) {
|
|
90
|
+
const plain = text.replaceAll(",", "");
|
|
91
|
+
if (plain === "") return null;
|
|
92
|
+
const [whole = "", fraction = ""] = plain.split(".");
|
|
93
|
+
return Number(`${whole}${fraction.padEnd(places, "0").slice(0, places)}`);
|
|
94
|
+
}
|
|
95
|
+
function formatMinorUnits(minorUnits, places) {
|
|
96
|
+
const digits = String(Math.abs(minorUnits)).padStart(places + 1, "0");
|
|
97
|
+
const grouped = groupThousands(digits.slice(0, digits.length - places));
|
|
98
|
+
return places === 0 ? grouped : `${grouped}.${digits.slice(digits.length - places)}`;
|
|
99
|
+
}
|
|
100
|
+
function groupThousands(digits) {
|
|
101
|
+
const groups = [];
|
|
102
|
+
for (let end = digits.length; end > 0; end -= 3) groups.unshift(digits.slice(Math.max(0, end - 3), end));
|
|
103
|
+
return groups.join(",");
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { AmountInput$1 as AmountInput };
|
|
@@ -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 };
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { useTheme } from "../theme.js";
|
|
2
|
+
import { SPACE } from "./tokens.js";
|
|
3
|
+
import { paddingStyle } from "./padding.js";
|
|
4
|
+
import { createEvent } from "@monimesl/dot-core";
|
|
5
|
+
import { Children, Fragment, isValidElement, useEffect, useEffectEvent, useRef, useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/carousel.tsx
|
|
8
|
+
const SLIDE_DURATION = 350;
|
|
9
|
+
const SLIDE_EASING = "cubic-bezier(0.22, 0.61, 0.36, 1)";
|
|
10
|
+
const SWIPE_DISTANCE = .2;
|
|
11
|
+
const SWIPE_SPEED = .4;
|
|
12
|
+
const EDGE_RESISTANCE = .3;
|
|
13
|
+
const TAP_SLOP = 6;
|
|
14
|
+
const Carousel$1 = ({ autoplay = false, interval = 4e3, loop = false, indicator = "dots", gap = "none", effect = "slide", index, onChange, children, ...padding }) => {
|
|
15
|
+
const { colors } = useTheme();
|
|
16
|
+
const slides = slidesOf(children);
|
|
17
|
+
const count = slides.length;
|
|
18
|
+
const looping = loop && count > 1;
|
|
19
|
+
const first = looping ? 1 : 0;
|
|
20
|
+
const last = looping ? count + 1 : count - 1;
|
|
21
|
+
const [position, setPosition] = useState(() => first + slideIndex(index ?? 0, count));
|
|
22
|
+
const [animated, setAnimated] = useState(true);
|
|
23
|
+
const [drag, setDrag] = useState(0);
|
|
24
|
+
const [dragging, setDragging] = useState(false);
|
|
25
|
+
const [width, setWidth] = useState(0);
|
|
26
|
+
const [previousIndex, setPreviousIndex] = useState(index);
|
|
27
|
+
const viewport = useRef(null);
|
|
28
|
+
const gesture = useRef(null);
|
|
29
|
+
const swiped = useRef(false);
|
|
30
|
+
if (index !== previousIndex) {
|
|
31
|
+
setPreviousIndex(index);
|
|
32
|
+
if (index !== void 0) {
|
|
33
|
+
setAnimated(true);
|
|
34
|
+
setPosition(first + slideIndex(index, count));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const shown = clamp(position, 0, last);
|
|
38
|
+
const current = count === 0 ? 0 : wrap(shown - first, count);
|
|
39
|
+
const moveTo = (target) => {
|
|
40
|
+
const next = clamp(target, 0, last);
|
|
41
|
+
setAnimated(true);
|
|
42
|
+
setPosition(next);
|
|
43
|
+
const nextIndex = wrap(next - first, count);
|
|
44
|
+
if (nextIndex !== current) onChange?.(createEvent("change", { index: nextIndex }));
|
|
45
|
+
};
|
|
46
|
+
const step = (direction) => {
|
|
47
|
+
const beyondEnd = current + direction < 0 || current + direction >= count;
|
|
48
|
+
moveTo(!looping && beyondEnd ? shown : shown + direction);
|
|
49
|
+
};
|
|
50
|
+
const advance = useEffectEvent(() => {
|
|
51
|
+
if (!looping && current === count - 1) moveTo(first);
|
|
52
|
+
else moveTo(shown + 1);
|
|
53
|
+
});
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!autoplay || count < 2 || dragging) return;
|
|
56
|
+
const timer = setTimeout(advance, interval);
|
|
57
|
+
return () => clearTimeout(timer);
|
|
58
|
+
}, [
|
|
59
|
+
autoplay,
|
|
60
|
+
count,
|
|
61
|
+
dragging,
|
|
62
|
+
interval,
|
|
63
|
+
current
|
|
64
|
+
]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!looping || position !== 0 && position !== count + 1) return;
|
|
67
|
+
const timer = setTimeout(() => {
|
|
68
|
+
setAnimated(false);
|
|
69
|
+
setPosition(position === 0 ? count : 1);
|
|
70
|
+
}, SLIDE_DURATION);
|
|
71
|
+
return () => clearTimeout(timer);
|
|
72
|
+
}, [
|
|
73
|
+
looping,
|
|
74
|
+
position,
|
|
75
|
+
count
|
|
76
|
+
]);
|
|
77
|
+
const gestureOf = (event) => {
|
|
78
|
+
const touch = gesture.current;
|
|
79
|
+
return touch?.pointerId === event.pointerId ? touch : null;
|
|
80
|
+
};
|
|
81
|
+
const endGesture = () => {
|
|
82
|
+
gesture.current = null;
|
|
83
|
+
setDragging(false);
|
|
84
|
+
setDrag(0);
|
|
85
|
+
setAnimated(true);
|
|
86
|
+
};
|
|
87
|
+
const onPointerDown = (event) => {
|
|
88
|
+
if (count < 2 || !event.isPrimary) return;
|
|
89
|
+
gesture.current = {
|
|
90
|
+
pointerId: event.pointerId,
|
|
91
|
+
startX: event.clientX,
|
|
92
|
+
startY: event.clientY,
|
|
93
|
+
startTime: event.timeStamp,
|
|
94
|
+
swiping: false
|
|
95
|
+
};
|
|
96
|
+
swiped.current = false;
|
|
97
|
+
setDragging(true);
|
|
98
|
+
setWidth(viewport.current?.clientWidth ?? 0);
|
|
99
|
+
};
|
|
100
|
+
const onPointerMove = (event) => {
|
|
101
|
+
const touch = gestureOf(event);
|
|
102
|
+
if (!touch) return;
|
|
103
|
+
const dx = event.clientX - touch.startX;
|
|
104
|
+
const dy = event.clientY - touch.startY;
|
|
105
|
+
if (!touch.swiping) {
|
|
106
|
+
if (Math.abs(dx) < TAP_SLOP && Math.abs(dy) < TAP_SLOP) return;
|
|
107
|
+
if (Math.abs(dy) > Math.abs(dx)) {
|
|
108
|
+
endGesture();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
touch.swiping = true;
|
|
112
|
+
swiped.current = true;
|
|
113
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
114
|
+
setAnimated(false);
|
|
115
|
+
}
|
|
116
|
+
const pastEnd = !looping && (current === 0 && dx > 0 || current === count - 1 && dx < 0);
|
|
117
|
+
setDrag(pastEnd ? dx * EDGE_RESISTANCE : dx);
|
|
118
|
+
};
|
|
119
|
+
const onPointerUp = (event) => {
|
|
120
|
+
const touch = gestureOf(event);
|
|
121
|
+
if (!touch) return;
|
|
122
|
+
endGesture();
|
|
123
|
+
if (!touch.swiping) return;
|
|
124
|
+
const dx = event.clientX - touch.startX;
|
|
125
|
+
const speed = Math.abs(dx) / Math.max(1, event.timeStamp - touch.startTime);
|
|
126
|
+
if (Math.abs(dx) > width * SWIPE_DISTANCE || speed > SWIPE_SPEED) step(dx < 0 ? 1 : -1);
|
|
127
|
+
else moveTo(shown);
|
|
128
|
+
};
|
|
129
|
+
const gapWidth = SPACE[gap];
|
|
130
|
+
const transition = animated ? `transform ${SLIDE_DURATION}ms ${SLIDE_EASING}` : "none";
|
|
131
|
+
const swipedSlides = width > 0 ? drag / (width + gapWidth) : 0;
|
|
132
|
+
const track = looping ? [
|
|
133
|
+
{
|
|
134
|
+
...slides[count - 1],
|
|
135
|
+
key: "copy-of-last"
|
|
136
|
+
},
|
|
137
|
+
...slides,
|
|
138
|
+
{
|
|
139
|
+
...slides[0],
|
|
140
|
+
key: "copy-of-first"
|
|
141
|
+
}
|
|
142
|
+
] : slides;
|
|
143
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
144
|
+
className: "dot-carousel",
|
|
145
|
+
role: "region",
|
|
146
|
+
"aria-roledescription": "carousel",
|
|
147
|
+
style: {
|
|
148
|
+
display: "flex",
|
|
149
|
+
flexDirection: "column",
|
|
150
|
+
gap: SPACE.medium,
|
|
151
|
+
minWidth: 0,
|
|
152
|
+
...paddingStyle(padding)
|
|
153
|
+
},
|
|
154
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
155
|
+
ref: viewport,
|
|
156
|
+
onPointerDown,
|
|
157
|
+
onPointerMove,
|
|
158
|
+
onPointerUp,
|
|
159
|
+
onPointerCancel: endGesture,
|
|
160
|
+
onDragStart: (event) => event.preventDefault(),
|
|
161
|
+
onClickCapture: (event) => {
|
|
162
|
+
if (swiped.current) {
|
|
163
|
+
swiped.current = false;
|
|
164
|
+
event.stopPropagation();
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
style: {
|
|
168
|
+
overflow: "hidden",
|
|
169
|
+
touchAction: "pan-y",
|
|
170
|
+
userSelect: dragging ? "none" : void 0
|
|
171
|
+
},
|
|
172
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
173
|
+
style: {
|
|
174
|
+
display: "flex",
|
|
175
|
+
gap: gapWidth,
|
|
176
|
+
transform: `translateX(calc(${-shown} * (100% + ${gapWidth}px) + ${drag}px))`,
|
|
177
|
+
transition
|
|
178
|
+
},
|
|
179
|
+
children: track.map((slide, trackPosition) => {
|
|
180
|
+
const visible = trackPosition === shown;
|
|
181
|
+
const distance = Math.abs(trackPosition - shown + swipedSlides);
|
|
182
|
+
const scale = 1 - Math.min(distance, 1) * .15000000000000002;
|
|
183
|
+
return /* @__PURE__ */ jsx("div", {
|
|
184
|
+
role: "group",
|
|
185
|
+
"aria-roledescription": "slide",
|
|
186
|
+
"aria-label": `${wrap(trackPosition - first, count) + 1} of ${count}`,
|
|
187
|
+
"aria-hidden": !visible,
|
|
188
|
+
inert: !visible,
|
|
189
|
+
style: {
|
|
190
|
+
display: "grid",
|
|
191
|
+
flex: "0 0 100%",
|
|
192
|
+
minWidth: 0,
|
|
193
|
+
transform: effect === "scale" ? `scale(${scale})` : void 0,
|
|
194
|
+
transition: effect === "scale" ? transition : void 0
|
|
195
|
+
},
|
|
196
|
+
children: slide.node
|
|
197
|
+
}, slide.key);
|
|
198
|
+
})
|
|
199
|
+
})
|
|
200
|
+
}), indicator === "dots" && count > 1 ? /* @__PURE__ */ jsx("div", {
|
|
201
|
+
style: {
|
|
202
|
+
display: "flex",
|
|
203
|
+
justifyContent: "center"
|
|
204
|
+
},
|
|
205
|
+
children: slides.map((slide, slideIndex) => {
|
|
206
|
+
const active = slideIndex === current;
|
|
207
|
+
return /* @__PURE__ */ jsx("button", {
|
|
208
|
+
type: "button",
|
|
209
|
+
"aria-label": `Slide ${slideIndex + 1} of ${count}`,
|
|
210
|
+
"aria-current": active,
|
|
211
|
+
onClick: () => moveTo(first + slideIndex),
|
|
212
|
+
style: {
|
|
213
|
+
padding: "6px 3px",
|
|
214
|
+
border: "none",
|
|
215
|
+
background: "none",
|
|
216
|
+
cursor: "pointer"
|
|
217
|
+
},
|
|
218
|
+
children: /* @__PURE__ */ jsx("span", { style: {
|
|
219
|
+
display: "block",
|
|
220
|
+
width: active ? 18 : 6,
|
|
221
|
+
height: 6,
|
|
222
|
+
borderRadius: 3,
|
|
223
|
+
background: active ? colors.primary : colors.subtle,
|
|
224
|
+
transition: "width 0.3s, background 0.3s"
|
|
225
|
+
} })
|
|
226
|
+
}, slide.key);
|
|
227
|
+
})
|
|
228
|
+
}) : null]
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
function slidesOf(children, keyPrefix = "") {
|
|
232
|
+
const slides = [];
|
|
233
|
+
for (const child of Children.toArray(children)) {
|
|
234
|
+
if (!isValidElement(child)) continue;
|
|
235
|
+
const key = `${keyPrefix}${String(child.key)}`;
|
|
236
|
+
if (child.type === Fragment) slides.push(...slidesOf(child.props.children, `${key}/`));
|
|
237
|
+
else slides.push({
|
|
238
|
+
key,
|
|
239
|
+
node: child
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return slides;
|
|
243
|
+
}
|
|
244
|
+
function clamp(value, min, max) {
|
|
245
|
+
return Math.max(min, Math.min(value, max));
|
|
246
|
+
}
|
|
247
|
+
function slideIndex(index, count) {
|
|
248
|
+
return clamp(Math.round(index), 0, count - 1);
|
|
249
|
+
}
|
|
250
|
+
function wrap(value, count) {
|
|
251
|
+
return (value % count + count) % count;
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
export { Carousel$1 as Carousel };
|