@monimesl/dot-renderer-react 0.1.0-alpha.2 → 0.1.0-alpha.23
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 +24 -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 +30 -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 +54 -0
- package/dist/index.d.ts +43 -44
- package/dist/index.js +40 -318
- 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 +68 -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 +13 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,321 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
subtle: defaults.subtle,
|
|
41
|
-
muted: defaults.muted,
|
|
42
|
-
border: defaults.border
|
|
43
|
-
},
|
|
44
|
-
radius: theme.radius ?? DEFAULT_RADIUS
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
const ThemeContext = createContext(resolveTheme({}, "light"));
|
|
48
|
-
function useTheme() {
|
|
49
|
-
return useContext(ThemeContext);
|
|
50
|
-
}
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/components/tokens.ts
|
|
53
|
-
const GAP = {
|
|
54
|
-
none: 0,
|
|
55
|
-
small: 4,
|
|
56
|
-
medium: 8,
|
|
57
|
-
large: 16
|
|
58
|
-
};
|
|
59
|
-
const FONT_SIZE = {
|
|
60
|
-
caption: 13,
|
|
61
|
-
body: 15,
|
|
62
|
-
title: 20
|
|
63
|
-
};
|
|
64
|
-
const CARD_RADIUS_SCALE = 1.5;
|
|
65
|
-
const DISABLED_OPACITY = .6;
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/components/button.tsx
|
|
68
|
-
const Button = ({ variant = "primary", disabled, onClick, children }) => {
|
|
69
|
-
const { colors, radius } = useTheme();
|
|
70
|
-
const filled = variant === "primary" && !disabled;
|
|
71
|
-
let color = colors.text;
|
|
72
|
-
if (filled) color = colors.surface;
|
|
73
|
-
else if (disabled) color = colors.subtle;
|
|
74
|
-
return /* @__PURE__ */ jsx("button", {
|
|
75
|
-
type: "button",
|
|
76
|
-
className: "dot-button",
|
|
77
|
-
"data-variant": variant,
|
|
78
|
-
disabled,
|
|
79
|
-
onClick: onClick ? () => onClick(createEvent("click")) : void 0,
|
|
80
|
-
style: {
|
|
81
|
-
padding: "10px 16px",
|
|
82
|
-
border: "none",
|
|
83
|
-
borderRadius: radius,
|
|
84
|
-
background: filled ? colors.primary : colors.muted,
|
|
85
|
-
color,
|
|
86
|
-
font: "inherit",
|
|
87
|
-
fontSize: FONT_SIZE.body,
|
|
88
|
-
fontWeight: 600,
|
|
89
|
-
opacity: disabled ? DISABLED_OPACITY : 1,
|
|
90
|
-
cursor: disabled ? "default" : "pointer"
|
|
91
|
-
},
|
|
92
|
-
children
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/components/image.tsx
|
|
97
|
-
const Image = ({ src, alt, width, height, onLoad, onError }) => {
|
|
98
|
-
const { radius } = useTheme();
|
|
99
|
-
return /* @__PURE__ */ jsx("img", {
|
|
100
|
-
className: "dot-image",
|
|
101
|
-
src,
|
|
102
|
-
alt: alt ?? "",
|
|
103
|
-
width,
|
|
104
|
-
height,
|
|
105
|
-
style: { borderRadius: radius },
|
|
106
|
-
onLoad: onLoad ? (event) => {
|
|
107
|
-
const { naturalWidth, naturalHeight } = event.currentTarget;
|
|
108
|
-
onLoad(createEvent("load", {
|
|
109
|
-
width: naturalWidth,
|
|
110
|
-
height: naturalHeight
|
|
111
|
-
}));
|
|
112
|
-
} : void 0,
|
|
113
|
-
onError: onError ? () => onError(createEvent("error", { message: `Failed to load ${src}` })) : void 0
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/components/input.tsx
|
|
118
|
-
const HTML_TYPES = {
|
|
119
|
-
text: {
|
|
120
|
-
type: "text",
|
|
121
|
-
inputMode: "text"
|
|
122
|
-
},
|
|
123
|
-
number: {
|
|
124
|
-
type: "text",
|
|
125
|
-
inputMode: "decimal"
|
|
126
|
-
},
|
|
127
|
-
email: {
|
|
128
|
-
type: "email",
|
|
129
|
-
inputMode: "email"
|
|
130
|
-
},
|
|
131
|
-
phone: {
|
|
132
|
-
type: "tel",
|
|
133
|
-
inputMode: "tel"
|
|
134
|
-
},
|
|
135
|
-
password: {
|
|
136
|
-
type: "password",
|
|
137
|
-
inputMode: "text"
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
const Input = ({ value, placeholder, label, type = "text", maxLength, disabled, onChange, onSubmit }) => {
|
|
141
|
-
const { colors, radius } = useTheme();
|
|
142
|
-
const [text, setText] = useState(value ?? "");
|
|
143
|
-
const [awaitingEcho, setAwaitingEcho] = useState([]);
|
|
144
|
-
const [previousValue, setPreviousValue] = useState(value);
|
|
145
|
-
if (value !== previousValue) {
|
|
146
|
-
setPreviousValue(value);
|
|
147
|
-
const echo = awaitingEcho.indexOf(value ?? "");
|
|
148
|
-
if (echo >= 0) setAwaitingEcho(awaitingEcho.slice(echo + 1));
|
|
149
|
-
else {
|
|
150
|
-
setAwaitingEcho([]);
|
|
151
|
-
setText(value ?? "");
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return /* @__PURE__ */ jsx("input", {
|
|
155
|
-
className: "dot-input",
|
|
156
|
-
...HTML_TYPES[type],
|
|
157
|
-
value: text,
|
|
158
|
-
placeholder,
|
|
159
|
-
"aria-label": label,
|
|
160
|
-
maxLength,
|
|
161
|
-
disabled,
|
|
162
|
-
onChange: (event) => {
|
|
163
|
-
const next = event.currentTarget.value;
|
|
164
|
-
setText(next);
|
|
165
|
-
if (onChange && value !== void 0) setAwaitingEcho([...awaitingEcho, next]);
|
|
166
|
-
onChange?.(createEvent("change", { value: next }));
|
|
167
|
-
},
|
|
168
|
-
onKeyDown: (event) => {
|
|
169
|
-
if (event.key === "Enter" && onSubmit) onSubmit(createEvent("submit", { value: text }));
|
|
170
|
-
},
|
|
171
|
-
style: {
|
|
172
|
-
width: "100%",
|
|
173
|
-
boxSizing: "border-box",
|
|
174
|
-
padding: "12px 14px",
|
|
175
|
-
border: `1px solid ${colors.border}`,
|
|
176
|
-
borderRadius: radius,
|
|
177
|
-
background: colors.surface,
|
|
178
|
-
color: colors.text,
|
|
179
|
-
outlineColor: colors.primary,
|
|
180
|
-
font: "inherit",
|
|
181
|
-
fontSize: 16,
|
|
182
|
-
opacity: disabled ? DISABLED_OPACITY : 1
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
};
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/components/text.tsx
|
|
188
|
-
const VARIANTS = {
|
|
189
|
-
body: { fontSize: FONT_SIZE.body },
|
|
190
|
-
caption: { fontSize: FONT_SIZE.caption },
|
|
191
|
-
title: {
|
|
192
|
-
fontSize: FONT_SIZE.title,
|
|
193
|
-
fontWeight: 600
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
const Text = ({ variant = "body", children }) => /* @__PURE__ */ jsx("span", {
|
|
197
|
-
className: "dot-text",
|
|
198
|
-
style: VARIANTS[variant],
|
|
199
|
-
children
|
|
200
|
-
});
|
|
201
|
-
//#endregion
|
|
202
|
-
//#region src/components/view.tsx
|
|
203
|
-
const ALIGN = {
|
|
204
|
-
stretch: "stretch",
|
|
205
|
-
start: "flex-start",
|
|
206
|
-
center: "center",
|
|
207
|
-
end: "flex-end"
|
|
208
|
-
};
|
|
209
|
-
const View = ({ direction = "column", gap = "medium", align = "stretch", variant = "plain", onTap, children }) => {
|
|
210
|
-
const { colors, radius } = useTheme();
|
|
211
|
-
const card = variant === "card";
|
|
212
|
-
return /* @__PURE__ */ jsx("div", {
|
|
213
|
-
className: "dot-view",
|
|
214
|
-
onClick: onTap ? () => onTap(createEvent("tap")) : void 0,
|
|
215
|
-
style: {
|
|
216
|
-
display: "flex",
|
|
217
|
-
flexDirection: direction,
|
|
218
|
-
gap: GAP[gap],
|
|
219
|
-
alignItems: ALIGN[align],
|
|
220
|
-
padding: card ? 16 : void 0,
|
|
221
|
-
borderRadius: card ? radius * CARD_RADIUS_SCALE : void 0,
|
|
222
|
-
background: card ? colors.surface : void 0,
|
|
223
|
-
border: card ? `1px solid ${colors.border}` : void 0,
|
|
224
|
-
cursor: onTap ? "pointer" : void 0
|
|
225
|
-
},
|
|
226
|
-
children
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
//#endregion
|
|
230
|
-
//#region src/components/index.ts
|
|
231
|
-
const builtins = {
|
|
232
|
-
Button,
|
|
233
|
-
Image,
|
|
234
|
-
Input,
|
|
235
|
-
Text,
|
|
236
|
-
View
|
|
237
|
-
};
|
|
238
|
-
//#endregion
|
|
239
|
-
//#region src/page-root.tsx
|
|
240
|
-
function PageRoot({ page, components }) {
|
|
241
|
-
const state = useSyncExternalStore(page.subscribe, page.getState);
|
|
242
|
-
const context = useMemo(() => ({
|
|
243
|
-
h(type, props, ...children) {
|
|
244
|
-
const component = components[type];
|
|
245
|
-
if (!component) throw new Error(`The renderer has no component registered for tag '<${type}>'`);
|
|
246
|
-
return createElement(component, props, ...children);
|
|
247
|
-
},
|
|
248
|
-
text: toText,
|
|
249
|
-
on: (handler) => page.on(handler),
|
|
250
|
-
each: (items, render, key) => createElement(Fragment, null, toList(items).map((item, index) => createElement(Fragment, { key: key ? String(key(item, index)) : index }, ...render(item, index))))
|
|
251
|
-
}), [page, components]);
|
|
252
|
-
if (!state) return null;
|
|
253
|
-
return createElement(Fragment, null, ...page.viewRenderer(state, context));
|
|
254
|
-
}
|
|
255
|
-
//#endregion
|
|
256
|
-
//#region src/root.tsx
|
|
257
|
-
function Root({ page, dotContext, components, wrapper: Wrapper }) {
|
|
258
|
-
const theme = useSyncExternalStore(dotContext.theme.subscribe, dotContext.theme.get);
|
|
259
|
-
const systemContext = useSyncExternalStore(dotContext.systemContext.subscribe, dotContext.systemContext.get);
|
|
260
|
-
const resolved = useMemo(() => resolveTheme(theme, systemContext.scheme), [theme, systemContext.scheme]);
|
|
261
|
-
const content = /* @__PURE__ */ jsx(PageRoot, {
|
|
262
|
-
page,
|
|
263
|
-
components
|
|
264
|
-
});
|
|
265
|
-
return /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
266
|
-
value: resolved,
|
|
267
|
-
children: Wrapper ? /* @__PURE__ */ jsx(Wrapper, {
|
|
268
|
-
theme: {
|
|
269
|
-
...theme,
|
|
270
|
-
scheme: resolved.scheme
|
|
271
|
-
},
|
|
272
|
-
children: content
|
|
273
|
-
}) : /* @__PURE__ */ jsx(DefaultSurface, { children: content })
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
function DefaultSurface({ children }) {
|
|
277
|
-
const { colors } = useTheme();
|
|
278
|
-
return /* @__PURE__ */ jsx("div", {
|
|
279
|
-
className: "dot-surface",
|
|
280
|
-
style: {
|
|
281
|
-
minHeight: "100vh",
|
|
282
|
-
boxSizing: "border-box",
|
|
283
|
-
padding: 16,
|
|
284
|
-
display: "flex",
|
|
285
|
-
flexDirection: "column",
|
|
286
|
-
gap: 12,
|
|
287
|
-
background: colors.background,
|
|
288
|
-
color: colors.text,
|
|
289
|
-
fontFamily: FONT_FAMILY
|
|
290
|
-
},
|
|
291
|
-
children
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
//#endregion
|
|
295
|
-
//#region src/renderer.tsx
|
|
296
|
-
function reactRenderer({ components = {}, wrapper } = {}) {
|
|
297
|
-
const registry = {
|
|
298
|
-
...builtins,
|
|
299
|
-
...components
|
|
300
|
-
};
|
|
301
|
-
return {
|
|
302
|
-
name: "react",
|
|
303
|
-
mount(container, page, dotContext) {
|
|
304
|
-
const root = createRoot(container);
|
|
305
|
-
root.render(/* @__PURE__ */ jsx(Root, {
|
|
306
|
-
page,
|
|
307
|
-
dotContext,
|
|
308
|
-
components: registry,
|
|
309
|
-
wrapper
|
|
310
|
-
}));
|
|
311
|
-
return () => root.unmount();
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
//#endregion
|
|
1
|
+
import { resolveTheme, useTheme } from "./theme.js";
|
|
2
|
+
import { AmountInput } from "./components/amount-input.js";
|
|
3
|
+
import { Avatar } from "./components/avatar.js";
|
|
4
|
+
import { Spinner } from "./components/spinner.js";
|
|
5
|
+
import { Button } from "./components/button.js";
|
|
6
|
+
import { Carousel } from "./components/carousel.js";
|
|
7
|
+
import { Icon } from "./components/icon.js";
|
|
8
|
+
import { Chip } from "./components/chip.js";
|
|
9
|
+
import { CodeInput } from "./components/code-input.js";
|
|
10
|
+
import { DetailRow } from "./components/detail-row.js";
|
|
11
|
+
import { Disclosure } from "./components/disclosure.js";
|
|
12
|
+
import { Divider } from "./components/divider.js";
|
|
13
|
+
import { EmptyState } from "./components/empty-state.js";
|
|
14
|
+
import { Badge, Notice, ProgressBar } from "./components/feedback.js";
|
|
15
|
+
import { Footer } from "./components/footer.js";
|
|
16
|
+
import { Grid, GridItem } from "./components/grid.js";
|
|
17
|
+
import { Image } from "./components/image.js";
|
|
18
|
+
import { Input } from "./components/input.js";
|
|
19
|
+
import { Link } from "./components/link.js";
|
|
20
|
+
import { List, ListItem } from "./components/list.js";
|
|
21
|
+
import { Option } from "./components/option.js";
|
|
22
|
+
import { Bullet, BulletList, Prose, Quote } from "./components/prose.js";
|
|
23
|
+
import { QRCode } from "./components/qr-code.js";
|
|
24
|
+
import { Text } from "./components/text.js";
|
|
25
|
+
import { RichText } from "./components/rich-text.js";
|
|
26
|
+
import { Scroll } from "./components/scroll.js";
|
|
27
|
+
import { Sheet } from "./components/sheet.js";
|
|
28
|
+
import { Select } from "./components/select.js";
|
|
29
|
+
import { Skeleton } from "./components/skeleton.js";
|
|
30
|
+
import { Slider } from "./components/slider.js";
|
|
31
|
+
import { Stack } from "./components/stack.js";
|
|
32
|
+
import { Step, Steps } from "./components/steps.js";
|
|
33
|
+
import { Stepper } from "./components/stepper.js";
|
|
34
|
+
import { Tab, Tabs } from "./components/tabs.js";
|
|
35
|
+
import { TextArea } from "./components/text-area.js";
|
|
36
|
+
import { Toast } from "./components/toast.js";
|
|
37
|
+
import { Checkbox, Radio, RadioGroup, Switch } from "./components/toggles.js";
|
|
38
|
+
import { View } from "./components/view.js";
|
|
39
|
+
import { createReactRenderer, reactRenderer } from "./renderer.js";
|
|
316
40
|
//#region src/index.ts
|
|
317
41
|
var src_default = reactRenderer;
|
|
318
42
|
//#endregion
|
|
319
|
-
export {
|
|
320
|
-
|
|
321
|
-
//# sourceMappingURL=index.js.map
|
|
43
|
+
export { AmountInput, Avatar, Badge, Bullet, BulletList, Button, Carousel, Checkbox, Chip, CodeInput, DetailRow, Disclosure, Divider, EmptyState, Footer, Grid, GridItem, Icon, Image, Input, Link, List, ListItem, Notice, Option, ProgressBar, Prose, QRCode, Quote, Radio, RadioGroup, RichText, Scroll, Select, Sheet, Skeleton, Slider, Spinner, Stack, Step, Stepper, Steps, Switch, Tab, Tabs, Text, TextArea, Toast, View, createReactRenderer, src_default as default, resolveTheme, useTheme };
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
//#region src/markdown.ts
|
|
2
|
+
const HEADING = /^(#{1,6})\s+(.*?)\s*#*\s*$/;
|
|
3
|
+
const RULE = /^ {0,3}([-*_])( *\1){2,} *$/;
|
|
4
|
+
const QUOTE = /^ {0,3}> ?/;
|
|
5
|
+
const LIST_ITEM = /^ {0,3}([-*+]|\d{1,9}[.)])\s+/;
|
|
6
|
+
const LINK = /^(!?)\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/;
|
|
7
|
+
const AUTOLINK = /^<(https?:\/\/[^>\s]+)>/;
|
|
8
|
+
const PUNCTUATION = /[!-/:-@[-`{-~]/;
|
|
9
|
+
const ITEM_INDENT = " ";
|
|
10
|
+
function parseMarkdown(markdown) {
|
|
11
|
+
return parseBlocks(markdown.replace(/\r\n?/g, "\n").split("\n"));
|
|
12
|
+
}
|
|
13
|
+
function parseBlocks(lines) {
|
|
14
|
+
const blocks = [];
|
|
15
|
+
let index = 0;
|
|
16
|
+
while (index < lines.length) {
|
|
17
|
+
const line = lines[index];
|
|
18
|
+
if (line.trim() === "") {
|
|
19
|
+
index += 1;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const single = oneLineBlock(line);
|
|
23
|
+
if (single) {
|
|
24
|
+
blocks.push(single);
|
|
25
|
+
index += 1;
|
|
26
|
+
} else if (QUOTE.test(line)) {
|
|
27
|
+
const quoted = [];
|
|
28
|
+
while (index < lines.length && QUOTE.test(lines[index])) {
|
|
29
|
+
quoted.push(lines[index].replace(QUOTE, ""));
|
|
30
|
+
index += 1;
|
|
31
|
+
}
|
|
32
|
+
blocks.push({
|
|
33
|
+
kind: "quote",
|
|
34
|
+
blocks: parseBlocks(quoted)
|
|
35
|
+
});
|
|
36
|
+
} else if (LIST_ITEM.test(line)) {
|
|
37
|
+
const { list, next } = parseList(lines, index);
|
|
38
|
+
blocks.push(list);
|
|
39
|
+
index = next;
|
|
40
|
+
} else {
|
|
41
|
+
const paragraph = [];
|
|
42
|
+
while (index < lines.length && !endsParagraph(lines[index])) {
|
|
43
|
+
paragraph.push(lines[index]);
|
|
44
|
+
index += 1;
|
|
45
|
+
}
|
|
46
|
+
blocks.push({
|
|
47
|
+
kind: "paragraph",
|
|
48
|
+
content: parseInline(joinLines(paragraph))
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return blocks;
|
|
53
|
+
}
|
|
54
|
+
function oneLineBlock(line) {
|
|
55
|
+
const heading = HEADING.exec(line);
|
|
56
|
+
if (heading) return {
|
|
57
|
+
kind: "heading",
|
|
58
|
+
level: Math.min(heading[1].length, 3),
|
|
59
|
+
content: parseInline(heading[2])
|
|
60
|
+
};
|
|
61
|
+
if (RULE.test(line)) return { kind: "rule" };
|
|
62
|
+
const trimmed = line.trim();
|
|
63
|
+
const picture = LINK.exec(trimmed);
|
|
64
|
+
if (picture && picture[1] === "!" && picture[0].length === trimmed.length) return {
|
|
65
|
+
kind: "image",
|
|
66
|
+
alt: picture[2],
|
|
67
|
+
src: picture[3]
|
|
68
|
+
};
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function endsParagraph(line) {
|
|
72
|
+
return line.trim() === "" || HEADING.test(line) || RULE.test(line) || QUOTE.test(line) || LIST_ITEM.test(line);
|
|
73
|
+
}
|
|
74
|
+
function joinLines(lines) {
|
|
75
|
+
let text = "";
|
|
76
|
+
lines.forEach((line, index) => {
|
|
77
|
+
text += line.trim().replace(/\\$/, "");
|
|
78
|
+
if (index < lines.length - 1) text += /( {2,}|\\)$/.test(line) ? "\n" : " ";
|
|
79
|
+
});
|
|
80
|
+
return text;
|
|
81
|
+
}
|
|
82
|
+
function parseList(lines, start) {
|
|
83
|
+
const ordered = isOrdered(LIST_ITEM.exec(lines[start]));
|
|
84
|
+
const items = [];
|
|
85
|
+
let index = start;
|
|
86
|
+
while (index < lines.length) {
|
|
87
|
+
const marker = LIST_ITEM.exec(lines[index]);
|
|
88
|
+
if (!marker || isOrdered(marker) !== ordered) break;
|
|
89
|
+
const indent = marker[0].length;
|
|
90
|
+
const itemLines = [lines[index].slice(indent)];
|
|
91
|
+
index += 1;
|
|
92
|
+
while (index < lines.length) {
|
|
93
|
+
const line = lines[index];
|
|
94
|
+
if (line.trim() === "") {
|
|
95
|
+
if (!lines[index + 1]?.startsWith(ITEM_INDENT)) break;
|
|
96
|
+
itemLines.push("");
|
|
97
|
+
} else if (line.startsWith(ITEM_INDENT)) itemLines.push(withoutIndent(line, indent));
|
|
98
|
+
else if (endsParagraph(line)) break;
|
|
99
|
+
else itemLines.push(line);
|
|
100
|
+
index += 1;
|
|
101
|
+
}
|
|
102
|
+
items.push(parseBlocks(itemLines));
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
list: {
|
|
106
|
+
kind: "list",
|
|
107
|
+
ordered,
|
|
108
|
+
items
|
|
109
|
+
},
|
|
110
|
+
next: index
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function isOrdered(marker) {
|
|
114
|
+
return /\d/.test(marker[1]);
|
|
115
|
+
}
|
|
116
|
+
function withoutIndent(line, indent) {
|
|
117
|
+
const spaces = line.length - line.trimStart().length;
|
|
118
|
+
return line.slice(Math.min(spaces, indent));
|
|
119
|
+
}
|
|
120
|
+
function parseInline(text) {
|
|
121
|
+
const inlines = [];
|
|
122
|
+
let plain = "";
|
|
123
|
+
let index = 0;
|
|
124
|
+
const flush = () => {
|
|
125
|
+
if (plain) {
|
|
126
|
+
inlines.push({
|
|
127
|
+
kind: "text",
|
|
128
|
+
text: plain
|
|
129
|
+
});
|
|
130
|
+
plain = "";
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const take = (inline, length) => {
|
|
134
|
+
flush();
|
|
135
|
+
inlines.push(inline);
|
|
136
|
+
index += length;
|
|
137
|
+
};
|
|
138
|
+
while (index < text.length) {
|
|
139
|
+
const char = text[index];
|
|
140
|
+
const next = text[index + 1];
|
|
141
|
+
const rest = text.slice(index);
|
|
142
|
+
if (char === "\\" && next !== void 0 && PUNCTUATION.test(next)) {
|
|
143
|
+
plain += next;
|
|
144
|
+
index += 2;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (char === "\n") {
|
|
148
|
+
take({ kind: "break" }, 1);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (char === "`") {
|
|
152
|
+
const codeEnd = text.indexOf("`", index + 1);
|
|
153
|
+
if (codeEnd > index + 1) {
|
|
154
|
+
take({
|
|
155
|
+
kind: "code",
|
|
156
|
+
text: text.slice(index + 1, codeEnd)
|
|
157
|
+
}, codeEnd + 1 - index);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const link = LINK.exec(rest);
|
|
162
|
+
if (link) {
|
|
163
|
+
const [whole, picture, label, href] = link;
|
|
164
|
+
take(picture === "!" ? {
|
|
165
|
+
kind: "text",
|
|
166
|
+
text: label
|
|
167
|
+
} : {
|
|
168
|
+
kind: "link",
|
|
169
|
+
href,
|
|
170
|
+
children: parseInline(label)
|
|
171
|
+
}, whole.length);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const autolink = AUTOLINK.exec(rest);
|
|
175
|
+
if (autolink) {
|
|
176
|
+
const [whole, href] = autolink;
|
|
177
|
+
take({
|
|
178
|
+
kind: "link",
|
|
179
|
+
href,
|
|
180
|
+
children: [{
|
|
181
|
+
kind: "text",
|
|
182
|
+
text: href
|
|
183
|
+
}]
|
|
184
|
+
}, whole.length);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (char === "*" || char === "_") {
|
|
188
|
+
const strong = between(text, index, char + char);
|
|
189
|
+
if (strong) {
|
|
190
|
+
take({
|
|
191
|
+
kind: "strong",
|
|
192
|
+
children: parseInline(strong.inner)
|
|
193
|
+
}, strong.length);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const emphasis = between(text, index, char);
|
|
197
|
+
if (emphasis) {
|
|
198
|
+
take({
|
|
199
|
+
kind: "emphasis",
|
|
200
|
+
children: parseInline(emphasis.inner)
|
|
201
|
+
}, emphasis.length);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
plain += char;
|
|
206
|
+
index += 1;
|
|
207
|
+
}
|
|
208
|
+
flush();
|
|
209
|
+
return inlines;
|
|
210
|
+
}
|
|
211
|
+
function between(text, start, delimiter) {
|
|
212
|
+
const open = start + delimiter.length;
|
|
213
|
+
if (!text.startsWith(delimiter, start) || open >= text.length || /\s/.test(text[open])) return null;
|
|
214
|
+
const underscore = delimiter.startsWith("_");
|
|
215
|
+
if (underscore && /\w/.test(text[start - 1] ?? "")) return null;
|
|
216
|
+
let close = text.indexOf(delimiter, open + 1);
|
|
217
|
+
while (close !== -1) {
|
|
218
|
+
const touchesSpace = /\s/.test(text[close - 1]);
|
|
219
|
+
const insideWord = underscore && /\w/.test(text[close + delimiter.length] ?? "");
|
|
220
|
+
const startsPair = delimiter.length === 1 && text[close + 1] === delimiter;
|
|
221
|
+
if (!touchesSpace && !insideWord && !startsPair) return {
|
|
222
|
+
inner: text.slice(open, close),
|
|
223
|
+
length: close + delimiter.length - start
|
|
224
|
+
};
|
|
225
|
+
close = text.indexOf(delimiter, close + (startsPair ? 2 : 1));
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
export { parseInline, parseMarkdown };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { toList, toText } from "@monimesl/dot-core";
|
|
2
|
+
import { Fragment, createElement, useMemo, useSyncExternalStore } from "react";
|
|
3
|
+
//#region src/page-root.tsx
|
|
4
|
+
function PageRoot({ page, components }) {
|
|
5
|
+
const state = useSyncExternalStore(page.subscribe, page.getState);
|
|
6
|
+
const context = useMemo(() => ({
|
|
7
|
+
h(type, props, ...children) {
|
|
8
|
+
const component = components[type];
|
|
9
|
+
if (!component) throw new Error(`The renderer has no component for <${type}>. Check the tag's name, or pass a component for it to the renderer.`);
|
|
10
|
+
return createElement(component, props, ...children);
|
|
11
|
+
},
|
|
12
|
+
text: toText,
|
|
13
|
+
on: (handler, data) => page.on(handler, data),
|
|
14
|
+
each: (items, render, key) => createElement(Fragment, null, toList(items).map((item, index) => createElement(Fragment, { key: key ? String(key(item, index)) : index }, ...render(item, index))))
|
|
15
|
+
}), [page, components]);
|
|
16
|
+
if (!state) return null;
|
|
17
|
+
return page.viewRenderer(state, context);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { PageRoot };
|
package/dist/portal.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
//#region src/portal.ts
|
|
3
|
+
const PortalContainerContext = createContext(null);
|
|
4
|
+
function usePortalContainer() {
|
|
5
|
+
return useContext(PortalContainerContext) ?? void 0;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { PortalContainerContext, usePortalContainer };
|