@monimesl/dot-renderer-react 0.1.0-alpha.2 → 0.1.0-alpha.21

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.
Files changed (267) hide show
  1. package/README.md +41 -1
  2. package/dist/LICENSE-PHOSPHOR +21 -0
  3. package/dist/_virtual/_rolldown/runtime.js +14 -0
  4. package/dist/_virtual/builtin_esm-external-require-react.js +9 -0
  5. package/dist/color.js +107 -0
  6. package/dist/components/amount-input.d.ts +6 -0
  7. package/dist/components/amount-input.js +109 -0
  8. package/dist/components/avatar.d.ts +6 -0
  9. package/dist/components/avatar.js +63 -0
  10. package/dist/components/box.js +58 -0
  11. package/dist/components/button.d.ts +6 -0
  12. package/dist/components/button.js +42 -0
  13. package/dist/components/carousel.d.ts +6 -0
  14. package/dist/components/carousel.js +254 -0
  15. package/dist/components/chip.d.ts +6 -0
  16. package/dist/components/chip.js +41 -0
  17. package/dist/components/code-input.d.ts +6 -0
  18. package/dist/components/code-input.js +97 -0
  19. package/dist/components/detail-row.d.ts +6 -0
  20. package/dist/components/detail-row.js +40 -0
  21. package/dist/components/disclosure.d.ts +6 -0
  22. package/dist/components/disclosure.js +76 -0
  23. package/dist/components/divider.d.ts +6 -0
  24. package/dist/components/divider.js +18 -0
  25. package/dist/components/empty-state.d.ts +6 -0
  26. package/dist/components/empty-state.js +66 -0
  27. package/dist/components/feedback.d.ts +8 -0
  28. package/dist/components/feedback.js +101 -0
  29. package/dist/components/field-box.js +44 -0
  30. package/dist/components/field.js +43 -0
  31. package/dist/components/footer.d.ts +6 -0
  32. package/dist/components/footer.js +24 -0
  33. package/dist/components/grid.d.ts +7 -0
  34. package/dist/components/grid.js +98 -0
  35. package/dist/components/https.js +11 -0
  36. package/dist/components/icon-artwork.js +143 -0
  37. package/dist/components/icon-button.js +28 -0
  38. package/dist/components/icon-svg.js +27 -0
  39. package/dist/components/icon.d.ts +6 -0
  40. package/dist/components/icon.js +25 -0
  41. package/dist/components/image.d.ts +6 -0
  42. package/dist/components/image.js +40 -0
  43. package/dist/components/index.d.ts +38 -0
  44. package/dist/components/index.js +92 -0
  45. package/dist/components/input.d.ts +6 -0
  46. package/dist/components/input.js +108 -0
  47. package/dist/components/link.d.ts +6 -0
  48. package/dist/components/link.js +32 -0
  49. package/dist/components/list.d.ts +7 -0
  50. package/dist/components/list.js +145 -0
  51. package/dist/components/option-place.js +9 -0
  52. package/dist/components/option.d.ts +6 -0
  53. package/dist/components/option.js +44 -0
  54. package/dist/components/padding.d.ts +2 -0
  55. package/dist/components/padding.js +27 -0
  56. package/dist/components/pressable.js +17 -0
  57. package/dist/components/prose-context.js +5 -0
  58. package/dist/components/prose.d.ts +9 -0
  59. package/dist/components/prose.js +67 -0
  60. package/dist/components/qr-code.d.ts +6 -0
  61. package/dist/components/qr-code.js +58 -0
  62. package/dist/components/rich-text.d.ts +6 -0
  63. package/dist/components/rich-text.js +73 -0
  64. package/dist/components/scroll.d.ts +6 -0
  65. package/dist/components/scroll.js +55 -0
  66. package/dist/components/select.d.ts +6 -0
  67. package/dist/components/select.js +93 -0
  68. package/dist/components/sheet.d.ts +8 -0
  69. package/dist/components/sheet.js +106 -0
  70. package/dist/components/skeleton.d.ts +6 -0
  71. package/dist/components/skeleton.js +55 -0
  72. package/dist/components/slider.d.ts +6 -0
  73. package/dist/components/slider.js +57 -0
  74. package/dist/components/spinner.d.ts +6 -0
  75. package/dist/components/spinner.js +48 -0
  76. package/dist/components/stack.d.ts +6 -0
  77. package/dist/components/stack.js +25 -0
  78. package/dist/components/stepper.d.ts +6 -0
  79. package/dist/components/stepper.js +94 -0
  80. package/dist/components/steps.d.ts +7 -0
  81. package/dist/components/steps.js +112 -0
  82. package/dist/components/tabs.d.ts +7 -0
  83. package/dist/components/tabs.js +91 -0
  84. package/dist/components/text-area.d.ts +6 -0
  85. package/dist/components/text-area.js +42 -0
  86. package/dist/components/text.d.ts +6 -0
  87. package/dist/components/text.js +106 -0
  88. package/dist/components/toast.d.ts +6 -0
  89. package/dist/components/toast.js +56 -0
  90. package/dist/components/toggles.d.ts +9 -0
  91. package/dist/components/toggles.js +150 -0
  92. package/dist/components/tokens.js +44 -0
  93. package/dist/components/tones.js +30 -0
  94. package/dist/components/typed-text.js +28 -0
  95. package/dist/components/utils.js +6 -0
  96. package/dist/components/view.d.ts +6 -0
  97. package/dist/components/view.js +54 -0
  98. package/dist/index.d.ts +43 -44
  99. package/dist/index.js +40 -318
  100. package/dist/markdown.js +226 -0
  101. package/dist/page-root.d.ts +2 -0
  102. package/dist/page-root.js +20 -0
  103. package/dist/portal.js +8 -0
  104. package/dist/pull-to-refresh.js +118 -0
  105. package/dist/react-host/19.3.0/react-dom.js +3 -0
  106. package/dist/react-host/19.3.0/react-host.js +6 -6
  107. package/dist/renderer.d.ts +17 -0
  108. package/dist/renderer.js +33 -0
  109. package/dist/root.d.ts +10 -0
  110. package/dist/root.js +55 -0
  111. package/dist/styles.css +1 -0
  112. package/dist/theme.d.ts +26 -0
  113. package/dist/theme.js +93 -0
  114. package/dist/types.d.ts +7 -0
  115. package/dist/vendor/@base-ui/react/checkbox/indicator/CheckboxIndicator.js +51 -0
  116. package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRoot.js +265 -0
  117. package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootContext.js +13 -0
  118. package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootDataAttributes.js +11 -0
  119. package/dist/vendor/@base-ui/react/checkbox/utils/getCheckboxStateAttributesMapping.js +15 -0
  120. package/dist/vendor/@base-ui/react/checkbox-group/CheckboxGroupContext.js +10 -0
  121. package/dist/vendor/@base-ui/react/dialog/backdrop/DialogBackdrop.js +40 -0
  122. package/dist/vendor/@base-ui/react/dialog/close/DialogClose.js +39 -0
  123. package/dist/vendor/@base-ui/react/dialog/popup/DialogPopup.js +92 -0
  124. package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupCssVars.js +8 -0
  125. package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupDataAttributes.js +7 -0
  126. package/dist/vendor/@base-ui/react/dialog/portal/DialogPortal.js +38 -0
  127. package/dist/vendor/@base-ui/react/dialog/portal/DialogPortalContext.js +13 -0
  128. package/dist/vendor/@base-ui/react/dialog/root/DialogRoot.js +16 -0
  129. package/dist/vendor/@base-ui/react/dialog/root/DialogRootContext.js +13 -0
  130. package/dist/vendor/@base-ui/react/dialog/root/useDialogRoot.js +77 -0
  131. package/dist/vendor/@base-ui/react/dialog/root/useRenderDialogRoot.js +65 -0
  132. package/dist/vendor/@base-ui/react/dialog/store/DialogStore.js +70 -0
  133. package/dist/vendor/@base-ui/react/dialog/title/DialogTitle.js +25 -0
  134. package/dist/vendor/@base-ui/react/dialog/utils/stateAttributesMapping.js +17 -0
  135. package/dist/vendor/@base-ui/react/field/control/FieldControlDataAttributes.js +11 -0
  136. package/dist/vendor/@base-ui/react/field/item/FieldItemContext.js +10 -0
  137. package/dist/vendor/@base-ui/react/field/root/useFieldValidation.js +18 -0
  138. package/dist/vendor/@base-ui/react/fieldset/root/FieldsetRootContext.js +13 -0
  139. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingFocusManager.js +477 -0
  140. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingPortal.js +165 -0
  141. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingRootStore.js +65 -0
  142. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingTree.js +22 -0
  143. package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useDismiss.js +373 -0
  144. package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.js +58 -0
  145. package/dist/vendor/@base-ui/react/floating-ui-react/utils/composite.js +40 -0
  146. package/dist/vendor/@base-ui/react/floating-ui-react/utils/constants.js +5 -0
  147. package/dist/vendor/@base-ui/react/floating-ui-react/utils/createAttribute.js +6 -0
  148. package/dist/vendor/@base-ui/react/floating-ui-react/utils/createEventEmitter.js +18 -0
  149. package/dist/vendor/@base-ui/react/floating-ui-react/utils/element.js +26 -0
  150. package/dist/vendor/@base-ui/react/floating-ui-react/utils/enqueueFocus.js +25 -0
  151. package/dist/vendor/@base-ui/react/floating-ui-react/utils/event.js +25 -0
  152. package/dist/vendor/@base-ui/react/floating-ui-react/utils/markOthers.js +116 -0
  153. package/dist/vendor/@base-ui/react/floating-ui-react/utils/nodes.js +16 -0
  154. package/dist/vendor/@base-ui/react/floating-ui-react/utils/tabbable.js +135 -0
  155. package/dist/vendor/@base-ui/react/internals/TransitionStatusDataAttributes.js +11 -0
  156. package/dist/vendor/@base-ui/react/internals/composite/composite.js +89 -0
  157. package/dist/vendor/@base-ui/react/internals/composite/constants.js +4 -0
  158. package/dist/vendor/@base-ui/react/internals/composite/item/CompositeItem.js +21 -0
  159. package/dist/vendor/@base-ui/react/internals/composite/item/useCompositeItem.js +31 -0
  160. package/dist/vendor/@base-ui/react/internals/composite/list/CompositeList.js +180 -0
  161. package/dist/vendor/@base-ui/react/internals/composite/list/CompositeListContext.js +15 -0
  162. package/dist/vendor/@base-ui/react/internals/composite/list/useCompositeListItem.js +54 -0
  163. package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRoot.js +62 -0
  164. package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRootContext.js +13 -0
  165. package/dist/vendor/@base-ui/react/internals/composite/root/useCompositeRoot.js +170 -0
  166. package/dist/vendor/@base-ui/react/internals/constants.js +18 -0
  167. package/dist/vendor/@base-ui/react/internals/createBaseUIEventDetails.js +40 -0
  168. package/dist/vendor/@base-ui/react/internals/direction-context/DirectionContext.js +10 -0
  169. package/dist/vendor/@base-ui/react/internals/field-constants/constants.js +33 -0
  170. package/dist/vendor/@base-ui/react/internals/field-register-control/useRegisterFieldControl.js +40 -0
  171. package/dist/vendor/@base-ui/react/internals/field-root-context/FieldRootContext.js +45 -0
  172. package/dist/vendor/@base-ui/react/internals/form-context/FormContext.js +18 -0
  173. package/dist/vendor/@base-ui/react/internals/getStateAttributesProps.js +17 -0
  174. package/dist/vendor/@base-ui/react/internals/labelable-provider/LabelableContext.js +24 -0
  175. package/dist/vendor/@base-ui/react/internals/labelable-provider/useAriaLabelledBy.js +35 -0
  176. package/dist/vendor/@base-ui/react/internals/labelable-provider/useLabelableId.js +57 -0
  177. package/dist/vendor/@base-ui/react/internals/reason-parts.js +14 -0
  178. package/dist/vendor/@base-ui/react/internals/serializeValue.js +12 -0
  179. package/dist/vendor/@base-ui/react/internals/stateAttributesMapping.js +11 -0
  180. package/dist/vendor/@base-ui/react/internals/use-button/useButton.js +137 -0
  181. package/dist/vendor/@base-ui/react/internals/useAnimationsFinished.js +94 -0
  182. package/dist/vendor/@base-ui/react/internals/useBaseUiId.js +13 -0
  183. package/dist/vendor/@base-ui/react/internals/useOpenChangeComplete.js +28 -0
  184. package/dist/vendor/@base-ui/react/internals/useRenderElement.js +109 -0
  185. package/dist/vendor/@base-ui/react/internals/useTransitionStatus.js +70 -0
  186. package/dist/vendor/@base-ui/react/internals/useValueChanged.js +15 -0
  187. package/dist/vendor/@base-ui/react/merge-props/mergeProps.js +153 -0
  188. package/dist/vendor/@base-ui/react/radio/indicator/RadioIndicator.js +46 -0
  189. package/dist/vendor/@base-ui/react/radio/root/RadioRoot.js +179 -0
  190. package/dist/vendor/@base-ui/react/radio/root/RadioRootContext.js +13 -0
  191. package/dist/vendor/@base-ui/react/radio/root/RadioRootDataAttributes.js +11 -0
  192. package/dist/vendor/@base-ui/react/radio/utils/stateAttributesMapping.js +14 -0
  193. package/dist/vendor/@base-ui/react/radio-group/RadioGroup.js +170 -0
  194. package/dist/vendor/@base-ui/react/radio-group/RadioGroupContext.js +10 -0
  195. package/dist/vendor/@base-ui/react/switch/root/SwitchRoot.js +170 -0
  196. package/dist/vendor/@base-ui/react/switch/root/SwitchRootContext.js +13 -0
  197. package/dist/vendor/@base-ui/react/switch/root/SwitchRootDataAttributes.js +11 -0
  198. package/dist/vendor/@base-ui/react/switch/stateAttributesMapping.js +12 -0
  199. package/dist/vendor/@base-ui/react/switch/thumb/SwitchThumb.js +25 -0
  200. package/dist/vendor/@base-ui/react/tabs/list/TabsList.js +98 -0
  201. package/dist/vendor/@base-ui/react/tabs/list/TabsListContext.js +13 -0
  202. package/dist/vendor/@base-ui/react/tabs/root/TabsRoot.js +213 -0
  203. package/dist/vendor/@base-ui/react/tabs/root/TabsRootContext.js +16 -0
  204. package/dist/vendor/@base-ui/react/tabs/root/TabsRootDataAttributes.js +8 -0
  205. package/dist/vendor/@base-ui/react/tabs/root/stateAttributesMapping.js +5 -0
  206. package/dist/vendor/@base-ui/react/tabs/tab/TabsTab.js +137 -0
  207. package/dist/vendor/@base-ui/react/utils/CommonPopupDataAttributes.js +24 -0
  208. package/dist/vendor/@base-ui/react/utils/CommonTriggerDataAttributes.js +11 -0
  209. package/dist/vendor/@base-ui/react/utils/FocusGuard.js +32 -0
  210. package/dist/vendor/@base-ui/react/utils/InternalBackdrop.js +30 -0
  211. package/dist/vendor/@base-ui/react/utils/dispatchClickWithModifiers.js +25 -0
  212. package/dist/vendor/@base-ui/react/utils/popupStateMapping.js +22 -0
  213. package/dist/vendor/@base-ui/react/utils/popups/popupStoreUtils.js +247 -0
  214. package/dist/vendor/@base-ui/react/utils/popups/popupTriggerMap.js +96 -0
  215. package/dist/vendor/@base-ui/react/utils/popups/store.js +94 -0
  216. package/dist/vendor/@base-ui/react/utils/resolveClassName.js +13 -0
  217. package/dist/vendor/@base-ui/react/utils/resolveRef.js +11 -0
  218. package/dist/vendor/@base-ui/react/utils/resolveStyle.js +13 -0
  219. package/dist/vendor/@base-ui/react/utils/useFocusableWhenDisabled.js +30 -0
  220. package/dist/vendor/@base-ui/utils/addEventListener.js +12 -0
  221. package/dist/vendor/@base-ui/utils/createLogOnce.js +20 -0
  222. package/dist/vendor/@base-ui/utils/empty.js +6 -0
  223. package/dist/vendor/@base-ui/utils/error.js +5 -0
  224. package/dist/vendor/@base-ui/utils/fastHooks.js +68 -0
  225. package/dist/vendor/@base-ui/utils/formatErrorMessage.js +27 -0
  226. package/dist/vendor/@base-ui/utils/getDefaultFormSubmitter.js +25 -0
  227. package/dist/vendor/@base-ui/utils/getReactElementRef.js +14 -0
  228. package/dist/vendor/@base-ui/utils/inertValue.js +8 -0
  229. package/dist/vendor/@base-ui/utils/isElementDisabled.js +6 -0
  230. package/dist/vendor/@base-ui/utils/mergeCleanups.js +14 -0
  231. package/dist/vendor/@base-ui/utils/mergeObjects.js +11 -0
  232. package/dist/vendor/@base-ui/utils/owner.js +7 -0
  233. package/dist/vendor/@base-ui/utils/platform/engine.js +8 -0
  234. package/dist/vendor/@base-ui/utils/platform/env.js +6 -0
  235. package/dist/vendor/@base-ui/utils/platform/os.js +15 -0
  236. package/dist/vendor/@base-ui/utils/platform/screen-reader.js +9 -0
  237. package/dist/vendor/@base-ui/utils/platform/shared.js +36 -0
  238. package/dist/vendor/@base-ui/utils/reactVersion.js +8 -0
  239. package/dist/vendor/@base-ui/utils/safeReact.js +13 -0
  240. package/dist/vendor/@base-ui/utils/shadowDom.js +26 -0
  241. package/dist/vendor/@base-ui/utils/store/ReactStore.js +181 -0
  242. package/dist/vendor/@base-ui/utils/store/Store.js +102 -0
  243. package/dist/vendor/@base-ui/utils/store/useStore.js +97 -0
  244. package/dist/vendor/@base-ui/utils/useAnimationFrame.js +87 -0
  245. package/dist/vendor/@base-ui/utils/useControlled.js +52 -0
  246. package/dist/vendor/@base-ui/utils/useId.js +32 -0
  247. package/dist/vendor/@base-ui/utils/useIsoLayoutEffect.js +7 -0
  248. package/dist/vendor/@base-ui/utils/useMergedRefs.js +87 -0
  249. package/dist/vendor/@base-ui/utils/useOnMount.js +12 -0
  250. package/dist/vendor/@base-ui/utils/useRefWithInit.js +18 -0
  251. package/dist/vendor/@base-ui/utils/useScrollLock.js +206 -0
  252. package/dist/vendor/@base-ui/utils/useStableCallback.js +38 -0
  253. package/dist/vendor/@base-ui/utils/useTimeout.js +43 -0
  254. package/dist/vendor/@base-ui/utils/useValueAsRef.js +27 -0
  255. package/dist/vendor/@base-ui/utils/visuallyHidden.js +23 -0
  256. package/dist/vendor/@base-ui/utils/warn.js +5 -0
  257. package/dist/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js +49 -0
  258. package/dist/vendor/uqr/dist/index.js +858 -0
  259. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +74 -0
  260. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +77 -0
  261. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +69 -0
  262. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +64 -0
  263. package/dist/vendor/use-sync-external-store/shim/index.js +11 -0
  264. package/dist/vendor/use-sync-external-store/shim/with-selector.js +11 -0
  265. package/package.json +13 -6
  266. package/dist/index.d.ts.map +0 -1
  267. package/dist/index.js.map +0 -1
package/README.md CHANGED
@@ -1,3 +1,43 @@
1
1
  # @monimesl/dot-renderer-react
2
2
 
3
- Renders Dot pages with React. It is the compiler's default renderer.
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` and `text`, each for light and dark. The renderer fills in the rest of the palette (the
25
+ neutrals and the status colors) from Dash's own look. `useTheme()` gives a component the resolved
26
+ theme.
27
+
28
+ ## Only the components a dot uses
29
+
30
+ A dot's production build carries only the components its pages use. The compiler lists them from
31
+ the pages, imports each one by name and makes the webview with
32
+ `createReactRenderer({ components })`. The renderer is built as one file per module, with the
33
+ libraries it bundles under `dist/vendor/`. So a dot's bundle can leave out a component, and
34
+ anything only that component imports. A development build has every component, because a hot reload
35
+ keeps the renderer the page already runs with.
36
+
37
+ `reactRenderer()`, the default export, makes a renderer with every built-in component. Pass
38
+ `components` to add or replace some, and `wrapper` to wrap each page.
39
+
40
+ ## React
41
+
42
+ Hosts serve React, so dots don't bundle it. This package's build makes the React that hosts ship,
43
+ 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,107 @@
1
+ //#region src/color.ts
2
+ const READABLE_CONTRAST = 4.5;
3
+ function contrast(first, second) {
4
+ const firstLuminance = luminance(first);
5
+ const secondLuminance = luminance(second);
6
+ const lighter = Math.max(firstLuminance, secondLuminance);
7
+ const darker = Math.min(firstLuminance, secondLuminance);
8
+ return (lighter + .05) / (darker + .05);
9
+ }
10
+ function darken(color, points) {
11
+ const [hue, saturation, lightness] = toHsl(channels(color));
12
+ return toHex(fromHsl(hue, saturation, Math.max(0, lightness - points / 100)));
13
+ }
14
+ function luminance(color) {
15
+ const [red, green, blue] = channels(color).map(linearLight);
16
+ return .2126 * red + .7152 * green + .0722 * blue;
17
+ }
18
+ function linearLight(channel) {
19
+ const share = channel / 255;
20
+ if (share <= .03928) return share / 12.92;
21
+ return ((share + .055) / 1.055) ** 2.4;
22
+ }
23
+ function channels(color) {
24
+ let hex = color.slice(1);
25
+ if (hex.length === 3 || hex.length === 4) hex = [...hex].map((digit) => digit + digit).join("");
26
+ const [red, green, blue] = [
27
+ 0,
28
+ 2,
29
+ 4
30
+ ].map((start) => parseInt(hex.slice(start, start + 2), 16));
31
+ return [
32
+ red,
33
+ green,
34
+ blue
35
+ ];
36
+ }
37
+ function toHex(rgb) {
38
+ return `#${rgb.map((channel) => Math.round(channel).toString(16).padStart(2, "0")).join("")}`;
39
+ }
40
+ function toHsl([red, green, blue]) {
41
+ const redShare = red / 255;
42
+ const greenShare = green / 255;
43
+ const blueShare = blue / 255;
44
+ const max = Math.max(redShare, greenShare, blueShare);
45
+ const min = Math.min(redShare, greenShare, blueShare);
46
+ const lightness = (max + min) / 2;
47
+ const chroma = max - min;
48
+ if (chroma === 0) return [
49
+ 0,
50
+ 0,
51
+ lightness
52
+ ];
53
+ const saturation = chroma / (1 - Math.abs(2 * lightness - 1));
54
+ let hue;
55
+ if (max === redShare) hue = (greenShare - blueShare) / chroma % 6;
56
+ else if (max === greenShare) hue = (blueShare - redShare) / chroma + 2;
57
+ else hue = (redShare - greenShare) / chroma + 4;
58
+ return [
59
+ (hue * 60 + 360) % 360,
60
+ saturation,
61
+ lightness
62
+ ];
63
+ }
64
+ function fromHsl(hue, saturation, lightness) {
65
+ const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
66
+ const middle = chroma * (1 - Math.abs(hue / 60 % 2 - 1));
67
+ const [red, green, blue] = [
68
+ [
69
+ chroma,
70
+ middle,
71
+ 0
72
+ ],
73
+ [
74
+ middle,
75
+ chroma,
76
+ 0
77
+ ],
78
+ [
79
+ 0,
80
+ chroma,
81
+ middle
82
+ ],
83
+ [
84
+ 0,
85
+ middle,
86
+ chroma
87
+ ],
88
+ [
89
+ middle,
90
+ 0,
91
+ chroma
92
+ ],
93
+ [
94
+ chroma,
95
+ 0,
96
+ middle
97
+ ]
98
+ ][Math.floor(hue / 60) % 6];
99
+ const lift = lightness - chroma / 2;
100
+ return [
101
+ (red + lift) * 255,
102
+ (green + lift) * 255,
103
+ (blue + lift) * 255
104
+ ];
105
+ }
106
+ //#endregion
107
+ export { READABLE_CONTRAST, contrast, darken };
@@ -0,0 +1,6 @@
1
+ import { ReactComponent } from "../types.js";
2
+ import { AmountInput } from "@monimesl/dot-core";
3
+ //#region src/components/amount-input.d.ts
4
+ declare const AmountInput$1: ReactComponent<typeof AmountInput>;
5
+ //#endregion
6
+ export { AmountInput$1 as AmountInput };
@@ -0,0 +1,109 @@
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 show = (minor) => formatMinorUnits(minor, decimalPlaces);
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: 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(show(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
+ const digits = whole.replace(/^0+/, "") || whole.slice(0, 1);
85
+ if (decimalPlaces === 0 || fractions.length === 0) return groupThousands(digits);
86
+ const fraction = fractions.join("").slice(0, decimalPlaces);
87
+ return `${groupThousands(digits) || "0"}.${fraction}`;
88
+ }
89
+ function toMinorUnits(text, decimalPlaces) {
90
+ const plain = text.replaceAll(",", "");
91
+ if (plain === "") return null;
92
+ const [whole = "", fraction = ""] = plain.split(".");
93
+ const fractionDigits = fraction.padEnd(decimalPlaces, "0").slice(0, decimalPlaces);
94
+ return Number(`${whole}${fractionDigits}`);
95
+ }
96
+ function formatMinorUnits(minorUnits, decimalPlaces) {
97
+ const digits = String(Math.abs(minorUnits)).padStart(decimalPlaces + 1, "0");
98
+ const wholeEnd = digits.length - decimalPlaces;
99
+ const grouped = groupThousands(digits.slice(0, wholeEnd));
100
+ if (decimalPlaces === 0) return grouped;
101
+ return `${grouped}.${digits.slice(wholeEnd)}`;
102
+ }
103
+ function groupThousands(digits) {
104
+ const groups = [];
105
+ for (let end = digits.length; end > 0; end -= 3) groups.unshift(digits.slice(Math.max(0, end - 3), end));
106
+ return groups.join(",");
107
+ }
108
+ //#endregion
109
+ export { AmountInput$1 as AmountInput };
@@ -0,0 +1,6 @@
1
+ import { ReactComponent } from "../types.js";
2
+ import { Avatar } from "@monimesl/dot-core";
3
+ //#region src/components/avatar.d.ts
4
+ declare const Avatar$1: ReactComponent<typeof Avatar>;
5
+ //#endregion
6
+ export { Avatar$1 as Avatar };
@@ -0,0 +1,63 @@
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
+ return (words.length === 1 ? [words[0]] : [words[0], words[words.length - 1]]).map((word) => word.charAt(0).toUpperCase()).join("");
17
+ }
18
+ const Avatar = ({ name = "", image, size = "medium" }) => {
19
+ const { colors } = useTheme();
20
+ const [failed, setFailed] = useState();
21
+ const pixels = AVATAR_SIZE[size];
22
+ const letters = initials(name);
23
+ let content;
24
+ if (image && failed !== image) content = /* @__PURE__ */ jsx("img", {
25
+ src: image,
26
+ alt: "",
27
+ onError: () => setFailed(image),
28
+ style: {
29
+ width: "100%",
30
+ height: "100%",
31
+ objectFit: "cover"
32
+ }
33
+ });
34
+ else if (letters) content = letters;
35
+ else content = /* @__PURE__ */ jsx(IconSvg, {
36
+ artwork: USER_ARTWORK,
37
+ size: Math.round(pixels * .55),
38
+ color: "currentColor"
39
+ });
40
+ return /* @__PURE__ */ jsx("span", {
41
+ className: "dot-avatar",
42
+ role: "img",
43
+ "aria-label": name || void 0,
44
+ style: {
45
+ display: "inline-flex",
46
+ flexShrink: 0,
47
+ alignItems: "center",
48
+ justifyContent: "center",
49
+ width: pixels,
50
+ height: pixels,
51
+ borderRadius: "50%",
52
+ overflow: "hidden",
53
+ background: colors.muted,
54
+ color: colors.subtle,
55
+ fontSize: Math.round(pixels * .4),
56
+ fontWeight: WEIGHTS.bold,
57
+ lineHeight: 1
58
+ },
59
+ children: content
60
+ });
61
+ };
62
+ //#endregion
63
+ export { Avatar };
@@ -0,0 +1,58 @@
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 !== void 0) {
20
+ const color = border === "strong" ? theme.colors.subtle : theme.colors.border;
21
+ style.border = border === "none" ? "none" : `1px solid ${color}`;
22
+ }
23
+ if (radius !== void 0) {
24
+ style.borderRadius = radius === "full" ? FULL_RADIUS : theme.radius * RADIUS_SCALE[radius];
25
+ style.overflow = "hidden";
26
+ }
27
+ if (props.width !== void 0) {
28
+ style.width = cssLength(props.width);
29
+ style.flexShrink = 0;
30
+ }
31
+ if (props.aspect !== void 0) style.aspectRatio = props.aspect.replace(":", " / ");
32
+ else if (props.height !== void 0) {
33
+ style.height = cssLength(props.height);
34
+ style.flexShrink = 0;
35
+ }
36
+ if (props.minHeight !== void 0) style.minHeight = props.minHeight;
37
+ if (props.maxWidth !== void 0) style.maxWidth = props.maxWidth;
38
+ return style;
39
+ }
40
+ function backgroundColor(background, theme) {
41
+ if (isTone(background)) return toneBackground(theme.colors, background);
42
+ if (BACKGROUND_WORDS.has(background)) return theme.colors[background];
43
+ return customColor(background, theme);
44
+ }
45
+ function customColor(name, theme) {
46
+ const color = theme.customColors[name];
47
+ if (color === void 0 && !unknownColors.has(name)) {
48
+ unknownColors.add(name);
49
+ console.warn(`The theme has no colour named "${name}". Add it to colors.custom in dot.ts.`);
50
+ }
51
+ return color;
52
+ }
53
+ const unknownColors = /* @__PURE__ */ new Set();
54
+ function cssLength(value) {
55
+ return value === "fill" ? "100%" : value;
56
+ }
57
+ //#endregion
58
+ export { boxStyle, customColor };
@@ -0,0 +1,6 @@
1
+ import { ReactComponent } from "../types.js";
2
+ import { Button } from "@monimesl/dot-core";
3
+ //#region src/components/button.d.ts
4
+ declare const Button$1: ReactComponent<typeof Button>;
5
+ //#endregion
6
+ export { Button$1 as Button };
@@ -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,6 @@
1
+ import { ReactComponent } from "../types.js";
2
+ import { Carousel } from "@monimesl/dot-core";
3
+ //#region src/components/carousel.d.ts
4
+ declare const Carousel$1: ReactComponent<typeof Carousel>;
5
+ //#endregion
6
+ export { Carousel$1 as Carousel };