fuma 0.0.1

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 (242) hide show
  1. package/README.md +58 -0
  2. package/dist/Meta.svelte +55 -0
  3. package/dist/Meta.svelte.d.ts +20 -0
  4. package/dist/action/index.d.ts +4 -0
  5. package/dist/action/index.js +4 -0
  6. package/dist/action/list/handlers.d.ts +16 -0
  7. package/dist/action/list/handlers.js +92 -0
  8. package/dist/action/list/index.css +40 -0
  9. package/dist/action/list/index.d.ts +23 -0
  10. package/dist/action/list/index.js +44 -0
  11. package/dist/action/list/store.d.ts +3 -0
  12. package/dist/action/list/store.js +1 -0
  13. package/dist/action/list/style.d.ts +2 -0
  14. package/dist/action/list/style.js +14 -0
  15. package/dist/action/list/trigger.d.ts +12 -0
  16. package/dist/action/list/trigger.js +124 -0
  17. package/dist/action/list/utils.d.ts +18 -0
  18. package/dist/action/list/utils.js +68 -0
  19. package/dist/action/portal.d.ts +3 -0
  20. package/dist/action/portal.js +9 -0
  21. package/dist/action/selector.d.ts +15 -0
  22. package/dist/action/selector.js +71 -0
  23. package/dist/action/tip.d.ts +6 -0
  24. package/dist/action/tip.js +12 -0
  25. package/dist/index.d.ts +3 -0
  26. package/dist/index.js +3 -0
  27. package/dist/server/index.d.ts +5 -0
  28. package/dist/server/index.js +5 -0
  29. package/dist/server/json.d.ts +1 -0
  30. package/dist/server/json.js +16 -0
  31. package/dist/server/parseFormData.d.ts +20 -0
  32. package/dist/server/parseFormData.js +63 -0
  33. package/dist/server/parseQuery.d.ts +11 -0
  34. package/dist/server/parseQuery.js +15 -0
  35. package/dist/server/sse.d.ts +6 -0
  36. package/dist/server/sse.js +35 -0
  37. package/dist/server/try.d.ts +6 -0
  38. package/dist/server/try.js +31 -0
  39. package/dist/store/index.d.ts +2 -0
  40. package/dist/store/index.js +2 -0
  41. package/dist/store/isSmallScreen.d.ts +2 -0
  42. package/dist/store/isSmallScreen.js +14 -0
  43. package/dist/store/param.d.ts +24 -0
  44. package/dist/store/param.js +61 -0
  45. package/dist/store/session.d.ts +2 -0
  46. package/dist/store/session.js +13 -0
  47. package/dist/ui/ButtonCopy.svelte +18 -0
  48. package/dist/ui/ButtonCopy.svelte.d.ts +18 -0
  49. package/dist/ui/ButtonDelete.svelte +43 -0
  50. package/dist/ui/ButtonDelete.svelte.d.ts +22 -0
  51. package/dist/ui/Dialog.svelte +58 -0
  52. package/dist/ui/Dialog.svelte.d.ts +25 -0
  53. package/dist/ui/DialogConfirm.svelte +22 -0
  54. package/dist/ui/DialogConfirm.svelte.d.ts +21 -0
  55. package/dist/ui/Icon.svelte +46 -0
  56. package/dist/ui/Icon.svelte.d.ts +24 -0
  57. package/dist/ui/Pagination.svelte +28 -0
  58. package/dist/ui/Pagination.svelte.d.ts +16 -0
  59. package/dist/ui/Placeholder.svelte +11 -0
  60. package/dist/ui/Placeholder.svelte.d.ts +19 -0
  61. package/dist/ui/PlaceholderImage.svelte +14 -0
  62. package/dist/ui/PlaceholderImage.svelte.d.ts +19 -0
  63. package/dist/ui/card/Card.svelte +38 -0
  64. package/dist/ui/card/Card.svelte.d.ts +26 -0
  65. package/dist/ui/card/CardBasic.svelte +14 -0
  66. package/dist/ui/card/CardBasic.svelte.d.ts +20 -0
  67. package/dist/ui/card/CardCollapse.svelte +61 -0
  68. package/dist/ui/card/CardCollapse.svelte.d.ts +22 -0
  69. package/dist/ui/card/CardFullScreen.svelte +28 -0
  70. package/dist/ui/card/CardFullScreen.svelte.d.ts +23 -0
  71. package/dist/ui/card/CardLink.svelte +21 -0
  72. package/dist/ui/card/CardLink.svelte.d.ts +20 -0
  73. package/dist/ui/card/index.d.ts +5 -0
  74. package/dist/ui/card/index.js +5 -0
  75. package/dist/ui/index.d.ts +14 -0
  76. package/dist/ui/index.js +14 -0
  77. package/dist/ui/input/FormControl.svelte +53 -0
  78. package/dist/ui/input/FormControl.svelte.d.ts +30 -0
  79. package/dist/ui/input/InputBoolean.svelte +29 -0
  80. package/dist/ui/input/InputBoolean.svelte.d.ts +21 -0
  81. package/dist/ui/input/InputCheckboxs.svelte +68 -0
  82. package/dist/ui/input/InputCheckboxs.svelte.d.ts +41 -0
  83. package/dist/ui/input/InputCheckboxsMenu.svelte +93 -0
  84. package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +43 -0
  85. package/dist/ui/input/InputCheckboxsTree.svelte +15 -0
  86. package/dist/ui/input/InputCheckboxsTree.svelte.d.ts +21 -0
  87. package/dist/ui/input/InputCheckboxsTreeNodes.svelte +60 -0
  88. package/dist/ui/input/InputCheckboxsTreeNodes.svelte.d.ts +23 -0
  89. package/dist/ui/input/InputDate.svelte +26 -0
  90. package/dist/ui/input/InputDate.svelte.d.ts +19 -0
  91. package/dist/ui/input/InputDatetime.svelte +21 -0
  92. package/dist/ui/input/InputDatetime.svelte.d.ts +19 -0
  93. package/dist/ui/input/InputImage.svelte +107 -0
  94. package/dist/ui/input/InputImage.svelte.d.ts +35 -0
  95. package/dist/ui/input/InputImagePreview.svelte +56 -0
  96. package/dist/ui/input/InputImagePreview.svelte.d.ts +23 -0
  97. package/dist/ui/input/InputNumber.svelte +22 -0
  98. package/dist/ui/input/InputNumber.svelte.d.ts +23 -0
  99. package/dist/ui/input/InputOptionInParam.svelte +34 -0
  100. package/dist/ui/input/InputOptionInParam.svelte.d.ts +20 -0
  101. package/dist/ui/input/InputOptions.svelte +79 -0
  102. package/dist/ui/input/InputOptions.svelte.d.ts +17 -0
  103. package/dist/ui/input/InputPassword.svelte +21 -0
  104. package/dist/ui/input/InputPassword.svelte.d.ts +36 -0
  105. package/dist/ui/input/InputRadio.svelte +79 -0
  106. package/dist/ui/input/InputRadio.svelte.d.ts +40 -0
  107. package/dist/ui/input/InputRelation.svelte +114 -0
  108. package/dist/ui/input/InputRelation.svelte.d.ts +52 -0
  109. package/dist/ui/input/InputRelations.svelte +138 -0
  110. package/dist/ui/input/InputRelations.svelte.d.ts +49 -0
  111. package/dist/ui/input/InputSearch.svelte +43 -0
  112. package/dist/ui/input/InputSearch.svelte.d.ts +23 -0
  113. package/dist/ui/input/InputSelect.svelte +59 -0
  114. package/dist/ui/input/InputSelect.svelte.d.ts +26 -0
  115. package/dist/ui/input/InputText.svelte +32 -0
  116. package/dist/ui/input/InputText.svelte.d.ts +31 -0
  117. package/dist/ui/input/InputTextarea.svelte +20 -0
  118. package/dist/ui/input/InputTextarea.svelte.d.ts +23 -0
  119. package/dist/ui/input/InputTime.svelte +19 -0
  120. package/dist/ui/input/InputTime.svelte.d.ts +19 -0
  121. package/dist/ui/input/RelationAfter.svelte +42 -0
  122. package/dist/ui/input/RelationAfter.svelte.d.ts +22 -0
  123. package/dist/ui/input/SelectorList.svelte +46 -0
  124. package/dist/ui/input/SelectorList.svelte.d.ts +40 -0
  125. package/dist/ui/input/action.d.ts +13 -0
  126. package/dist/ui/input/action.js +56 -0
  127. package/dist/ui/input/index.d.ts +25 -0
  128. package/dist/ui/input/index.js +25 -0
  129. package/dist/ui/input/textRich/InputTextRich.svelte +58 -0
  130. package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +20 -0
  131. package/dist/ui/input/textRich/SuggesionList.svelte +21 -0
  132. package/dist/ui/input/textRich/SuggesionList.svelte.d.ts +19 -0
  133. package/dist/ui/input/textRich/ToolMark.svelte +19 -0
  134. package/dist/ui/input/textRich/ToolMark.svelte.d.ts +21 -0
  135. package/dist/ui/input/textRich/ToolMarkColor.svelte +32 -0
  136. package/dist/ui/input/textRich/ToolMarkColor.svelte.d.ts +19 -0
  137. package/dist/ui/input/textRich/ToolMarkLink.svelte +63 -0
  138. package/dist/ui/input/textRich/ToolMarkLink.svelte.d.ts +17 -0
  139. package/dist/ui/input/textRich/ToolMenu.svelte +50 -0
  140. package/dist/ui/input/textRich/ToolMenu.svelte.d.ts +29 -0
  141. package/dist/ui/input/textRich/ToolMenuAlign.svelte +46 -0
  142. package/dist/ui/input/textRich/ToolMenuAlign.svelte.d.ts +17 -0
  143. package/dist/ui/input/textRich/ToolMenuInsert.svelte +49 -0
  144. package/dist/ui/input/textRich/ToolMenuInsert.svelte.d.ts +19 -0
  145. package/dist/ui/input/textRich/ToolMenuNode.svelte +56 -0
  146. package/dist/ui/input/textRich/ToolMenuNode.svelte.d.ts +17 -0
  147. package/dist/ui/input/textRich/ToolsBar.svelte +60 -0
  148. package/dist/ui/input/textRich/ToolsBar.svelte.d.ts +18 -0
  149. package/dist/ui/input/textRich/extensions.d.ts +2 -0
  150. package/dist/ui/input/textRich/extensions.js +62 -0
  151. package/dist/ui/input/textRich/indent.d.ts +13 -0
  152. package/dist/ui/input/textRich/indent.js +112 -0
  153. package/dist/ui/input/textRich/suggestion.d.ts +9 -0
  154. package/dist/ui/input/textRich/suggestion.js +56 -0
  155. package/dist/ui/input/types.d.ts +15 -0
  156. package/dist/ui/input/types.js +1 -0
  157. package/dist/ui/menu/ContextMenu.svelte +47 -0
  158. package/dist/ui/menu/ContextMenu.svelte.d.ts +28 -0
  159. package/dist/ui/menu/DropDown.svelte +110 -0
  160. package/dist/ui/menu/DropDown.svelte.d.ts +38 -0
  161. package/dist/ui/menu/dropdown.css +33 -0
  162. package/dist/ui/menu/index.d.ts +2 -0
  163. package/dist/ui/menu/index.js +2 -0
  164. package/dist/ui/period/PeriodPicker.svelte +53 -0
  165. package/dist/ui/period/PeriodPicker.svelte.d.ts +22 -0
  166. package/dist/ui/period/PeriodPickerButton.svelte +73 -0
  167. package/dist/ui/period/PeriodPickerButton.svelte.d.ts +14 -0
  168. package/dist/ui/period/index.d.ts +6 -0
  169. package/dist/ui/period/index.js +2 -0
  170. package/dist/ui/table/Table.svelte +42 -0
  171. package/dist/ui/table/Table.svelte.d.ts +39 -0
  172. package/dist/ui/table/TableBody.svelte +29 -0
  173. package/dist/ui/table/TableBody.svelte.d.ts +33 -0
  174. package/dist/ui/table/TableCell.svelte +27 -0
  175. package/dist/ui/table/TableCell.svelte.d.ts +28 -0
  176. package/dist/ui/table/TableFieldsEdition.svelte +122 -0
  177. package/dist/ui/table/TableFieldsEdition.svelte.d.ts +31 -0
  178. package/dist/ui/table/TableHead.svelte +31 -0
  179. package/dist/ui/table/TableHead.svelte.d.ts +29 -0
  180. package/dist/ui/table/TableViewSelect.svelte +127 -0
  181. package/dist/ui/table/TableViewSelect.svelte.d.ts +24 -0
  182. package/dist/ui/table/cell/TableCellArray.svelte +10 -0
  183. package/dist/ui/table/cell/TableCellArray.svelte.d.ts +16 -0
  184. package/dist/ui/table/cell/TableCellBoolean.svelte +12 -0
  185. package/dist/ui/table/cell/TableCellBoolean.svelte.d.ts +16 -0
  186. package/dist/ui/table/cell/TableCellNumber.svelte +6 -0
  187. package/dist/ui/table/cell/TableCellNumber.svelte.d.ts +16 -0
  188. package/dist/ui/table/cell/TableCellString.svelte +7 -0
  189. package/dist/ui/table/cell/TableCellString.svelte.d.ts +18 -0
  190. package/dist/ui/table/cell/index.d.ts +4 -0
  191. package/dist/ui/table/cell/index.js +4 -0
  192. package/dist/ui/table/context.d.ts +14 -0
  193. package/dist/ui/table/context.js +10 -0
  194. package/dist/ui/table/field.d.ts +79 -0
  195. package/dist/ui/table/field.js +29 -0
  196. package/dist/ui/table/head/TableHeadBoolean.svelte +12 -0
  197. package/dist/ui/table/head/TableHeadBoolean.svelte.d.ts +17 -0
  198. package/dist/ui/table/head/TableHeadDate.svelte +100 -0
  199. package/dist/ui/table/head/TableHeadDate.svelte.d.ts +17 -0
  200. package/dist/ui/table/head/TableHeadDefault.svelte +7 -0
  201. package/dist/ui/table/head/TableHeadDefault.svelte.d.ts +17 -0
  202. package/dist/ui/table/head/TableHeadNumber.svelte +80 -0
  203. package/dist/ui/table/head/TableHeadNumber.svelte.d.ts +17 -0
  204. package/dist/ui/table/head/TableHeadSelect.svelte +75 -0
  205. package/dist/ui/table/head/TableHeadSelect.svelte.d.ts +20 -0
  206. package/dist/ui/table/head/TableHeadString.svelte +35 -0
  207. package/dist/ui/table/head/TableHeadString.svelte.d.ts +17 -0
  208. package/dist/ui/table/head/index.d.ts +19 -0
  209. package/dist/ui/table/head/index.js +22 -0
  210. package/dist/ui/table/index.d.ts +10 -0
  211. package/dist/ui/table/index.js +10 -0
  212. package/dist/ui/table/server.d.ts +1 -0
  213. package/dist/ui/table/server.js +32 -0
  214. package/dist/ui/tabs/Tabs.svelte +28 -0
  215. package/dist/ui/tabs/Tabs.svelte.d.ts +18 -0
  216. package/dist/ui/tabs/TabsIcon.svelte +56 -0
  217. package/dist/ui/tabs/TabsIcon.svelte.d.ts +20 -0
  218. package/dist/ui/tabs/index.d.ts +8 -0
  219. package/dist/ui/tabs/index.js +2 -0
  220. package/dist/utils/avatar.d.ts +1 -0
  221. package/dist/utils/avatar.js +5 -0
  222. package/dist/utils/component.d.ts +7 -0
  223. package/dist/utils/component.js +3 -0
  224. package/dist/utils/formatRange.d.ts +8 -0
  225. package/dist/utils/formatRange.js +25 -0
  226. package/dist/utils/index.d.ts +7 -0
  227. package/dist/utils/index.js +7 -0
  228. package/dist/utils/jsonParse.d.ts +1 -0
  229. package/dist/utils/jsonParse.js +10 -0
  230. package/dist/utils/normalizePath.d.ts +1 -0
  231. package/dist/utils/normalizePath.js +11 -0
  232. package/dist/utils/options.d.ts +7 -0
  233. package/dist/utils/options.js +20 -0
  234. package/dist/utils/tippy.d.ts +5 -0
  235. package/dist/utils/tippy.js +4 -0
  236. package/dist/validation/form.d.ts +31 -0
  237. package/dist/validation/form.js +94 -0
  238. package/dist/validation/index.d.ts +2 -0
  239. package/dist/validation/index.js +2 -0
  240. package/dist/validation/zod.d.ts +338 -0
  241. package/dist/validation/zod.js +100 -0
  242. package/package.json +86 -0
@@ -0,0 +1,56 @@
1
+ import { get } from 'svelte/store';
2
+ import debounce from 'debounce';
3
+ import { urlParam } from '../../index.js';
4
+ import { goto } from '$app/navigation';
5
+ export function bindValueWithParams(node, { bindEnable = false, debounceTime = 200, initValue = (initalValue) => (node.value = initalValue), listenerType = 'input' }) {
6
+ const { name } = node;
7
+ if (!name || !bindEnable)
8
+ return;
9
+ const importValueFromParams = () => {
10
+ const _urlParam = get(urlParam);
11
+ const value = _urlParam.get(name);
12
+ if (value)
13
+ return initValue(value);
14
+ };
15
+ const handleInput = debounce(async () => {
16
+ const _urlParam = get(urlParam);
17
+ const newUrl = node.value
18
+ ? _urlParam.with({ [name]: node.value }, 'skip', 'take')
19
+ : _urlParam.without(name, 'skip', 'take');
20
+ await goto(newUrl, { replaceState: true, keepFocus: true, noScroll: true });
21
+ }, debounceTime);
22
+ importValueFromParams();
23
+ node.addEventListener(listenerType, handleInput);
24
+ return {
25
+ destroy() {
26
+ node.removeEventListener(listenerType, handleInput);
27
+ }
28
+ };
29
+ }
30
+ export function bindCheckedWithParams(node, { bindEnable = false, listenerType = 'input', debounceTime = 0, initValue = (initalValue) => (node.checked = node.value === initalValue) }) {
31
+ const { name } = node;
32
+ if (!name || !bindEnable)
33
+ return;
34
+ const importValueFromParams = () => {
35
+ const _urlParam = get(urlParam);
36
+ if (!_urlParam.has(name))
37
+ return;
38
+ const paramValue = _urlParam.get(name);
39
+ if (paramValue)
40
+ initValue(paramValue);
41
+ };
42
+ const handleInput = debounce(async () => {
43
+ const _urlParam = get(urlParam);
44
+ const newUrl = node.checked
45
+ ? _urlParam.with({ [name]: node.value }, 'skip', 'take')
46
+ : _urlParam.without(name, 'skip', 'take');
47
+ await goto(newUrl, { replaceState: true, keepFocus: true, noScroll: true });
48
+ }, debounceTime);
49
+ importValueFromParams();
50
+ node.addEventListener(listenerType, handleInput);
51
+ return {
52
+ destroy: () => {
53
+ node.removeEventListener(listenerType, handleInput);
54
+ }
55
+ };
56
+ }
@@ -0,0 +1,25 @@
1
+ export * from './types.js';
2
+ export * from './action.js';
3
+ export { default as FormControl } from './FormControl.svelte';
4
+ export { default as InputText } from './InputText.svelte';
5
+ export { default as InputTextRich } from './textRich/InputTextRich.svelte';
6
+ export { default as InputPassword } from './InputPassword.svelte';
7
+ export { default as InputTextarea } from './InputTextarea.svelte';
8
+ export { default as InputRelations } from './InputRelations.svelte';
9
+ export { default as InputRelation } from './InputRelation.svelte';
10
+ export { default as InputDate } from './InputDate.svelte';
11
+ export { default as InputDatetime } from './InputDatetime.svelte';
12
+ export { default as InputTime } from './InputTime.svelte';
13
+ export { default as InputNumber } from './InputNumber.svelte';
14
+ export { default as InputBoolean } from './InputBoolean.svelte';
15
+ export { default as InputRadio } from './InputRadio.svelte';
16
+ export { default as InputOptionInParam } from './InputOptionInParam.svelte';
17
+ export { default as InputCheckboxs } from './InputCheckboxs.svelte';
18
+ export { default as InputCheckboxsMenu } from './InputCheckboxsMenu.svelte';
19
+ export { default as InputCheckboxsTree } from './InputCheckboxsTree.svelte';
20
+ export { default as InputSelect } from './InputSelect.svelte';
21
+ export { default as InputOptions } from './InputOptions.svelte';
22
+ export { default as InputSearch } from './InputSearch.svelte';
23
+ export { default as InputImage, type Crop } from './InputImage.svelte';
24
+ export { default as InputImagePreview } from './InputImagePreview.svelte';
25
+ export { default as SelectorList } from './SelectorList.svelte';
@@ -0,0 +1,25 @@
1
+ export * from './types.js';
2
+ export * from './action.js';
3
+ export { default as FormControl } from './FormControl.svelte';
4
+ export { default as InputText } from './InputText.svelte';
5
+ export { default as InputTextRich } from './textRich/InputTextRich.svelte';
6
+ export { default as InputPassword } from './InputPassword.svelte';
7
+ export { default as InputTextarea } from './InputTextarea.svelte';
8
+ export { default as InputRelations } from './InputRelations.svelte';
9
+ export { default as InputRelation } from './InputRelation.svelte';
10
+ export { default as InputDate } from './InputDate.svelte';
11
+ export { default as InputDatetime } from './InputDatetime.svelte';
12
+ export { default as InputTime } from './InputTime.svelte';
13
+ export { default as InputNumber } from './InputNumber.svelte';
14
+ export { default as InputBoolean } from './InputBoolean.svelte';
15
+ export { default as InputRadio } from './InputRadio.svelte';
16
+ export { default as InputOptionInParam } from './InputOptionInParam.svelte';
17
+ export { default as InputCheckboxs } from './InputCheckboxs.svelte';
18
+ export { default as InputCheckboxsMenu } from './InputCheckboxsMenu.svelte';
19
+ export { default as InputCheckboxsTree } from './InputCheckboxsTree.svelte';
20
+ export { default as InputSelect } from './InputSelect.svelte';
21
+ export { default as InputOptions } from './InputOptions.svelte';
22
+ export { default as InputSearch } from './InputSearch.svelte';
23
+ export { default as InputImage } from './InputImage.svelte';
24
+ export { default as InputImagePreview } from './InputImagePreview.svelte';
25
+ export { default as SelectorList } from './SelectorList.svelte';
@@ -0,0 +1,58 @@
1
+ <script>import { createEventDispatcher, onMount } from "svelte";
2
+ import { Editor } from "@tiptap/core";
3
+ import debounce from "debounce";
4
+ import { jsonParse } from "../../../utils/jsonParse.js";
5
+ import ToolsBar from "./ToolsBar.svelte";
6
+ import { extensions } from "./extensions.js";
7
+ export let value = "";
8
+ export let key = "";
9
+ export let classToolbar = "";
10
+ let element;
11
+ let editor = null;
12
+ const dispatch = createEventDispatcher();
13
+ onMount(() => {
14
+ initEditor();
15
+ return () => {
16
+ if (editor)
17
+ editor.destroy();
18
+ };
19
+ });
20
+ function initEditor() {
21
+ const valueAsHtml = !value.startsWith("{") && value !== "null";
22
+ editor = new Editor({
23
+ element,
24
+ content: valueAsHtml ? value : jsonParse(value, void 0),
25
+ editorProps: {
26
+ attributes: {
27
+ class: "prose max-w-[210mm] mx-auto focus:outline-none"
28
+ }
29
+ },
30
+ extensions,
31
+ onTransaction() {
32
+ editor = editor;
33
+ updateValue();
34
+ }
35
+ });
36
+ }
37
+ const updateValue = debounce(() => {
38
+ if (!editor)
39
+ return;
40
+ const newValue = JSON.stringify(editor.getJSON());
41
+ console.log(newValue);
42
+ if (newValue === value)
43
+ return;
44
+ value = newValue;
45
+ dispatch("change");
46
+ }, 120);
47
+ </script>
48
+
49
+ <div class="bordered relative rounded-lg border">
50
+ {#if editor}
51
+ <ToolsBar {editor} class={classToolbar} />
52
+ {/if}
53
+ <div bind:this={element} class="min-h-[20rem] p-4 pb-10" />
54
+ </div>
55
+
56
+ {#if key}
57
+ <input type="hidden" name={key} {value} />
58
+ {/if}
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ value?: string | undefined;
5
+ key?: string | undefined;
6
+ classToolbar?: string | undefined;
7
+ };
8
+ events: {
9
+ change: CustomEvent<void>;
10
+ } & {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {};
14
+ };
15
+ export type InputTextRichProps = typeof __propDef.props;
16
+ export type InputTextRichEvents = typeof __propDef.events;
17
+ export type InputTextRichSlots = typeof __propDef.slots;
18
+ export default class InputTextRich extends SvelteComponent<InputTextRichProps, InputTextRichEvents, InputTextRichSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,21 @@
1
+ <script>import { SelectorList } from "../index.js";
2
+ export let props;
3
+ export let keyDownEvent = void 0;
4
+ function handleSelect(index) {
5
+ const item = props.items[index];
6
+ if (!item)
7
+ return;
8
+ props.command(item);
9
+ }
10
+ </script>
11
+
12
+ <SelectorList
13
+ items={props.items}
14
+ {keyDownEvent}
15
+ keyDownPreventDefault={false}
16
+ let:item
17
+ on:select={(event) => handleSelect(event.detail)}
18
+ class=" max-h-64 overflow-auto"
19
+ >
20
+ <span>{item.label}</span>
21
+ </SelectorList>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { SuggestionProps } from '@tiptap/suggestion';
3
+ import type { SuggestionItem } from './suggestion.js';
4
+ declare const __propDef: {
5
+ props: {
6
+ props: SuggestionProps<SuggestionItem>;
7
+ keyDownEvent?: KeyboardEvent | undefined;
8
+ };
9
+ events: {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {};
13
+ };
14
+ export type SuggesionListProps = typeof __propDef.props;
15
+ export type SuggesionListEvents = typeof __propDef.events;
16
+ export type SuggesionListSlots = typeof __propDef.slots;
17
+ export default class SuggesionList extends SvelteComponent<SuggesionListProps, SuggesionListEvents, SuggesionListSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,19 @@
1
+ <script>import { Icon } from "../../index.js";
2
+ import { tip } from "../../../action/tip.js";
3
+ export let editor;
4
+ export let key;
5
+ export let label;
6
+ export let icon;
7
+ export let action;
8
+ $:
9
+ isActive = editor.isActive(key);
10
+ </script>
11
+
12
+ <button
13
+ type="button"
14
+ use:tip={{ content: label, arrow: true }}
15
+ class="menu-item {isActive ? 'bg-base-200/60' : ''}"
16
+ on:click={action}
17
+ >
18
+ <Icon path={icon} size={19} class={isActive ? 'opacity-90' : 'opacity-60'} />
19
+ </button>
@@ -0,0 +1,21 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Editor } from '@tiptap/core';
3
+ declare const __propDef: {
4
+ props: {
5
+ editor: Editor;
6
+ key: string;
7
+ label: string;
8
+ icon: string;
9
+ action: () => void;
10
+ };
11
+ events: {
12
+ [evt: string]: CustomEvent<any>;
13
+ };
14
+ slots: {};
15
+ };
16
+ export type ToolMarkProps = typeof __propDef.props;
17
+ export type ToolMarkEvents = typeof __propDef.events;
18
+ export type ToolMarkSlots = typeof __propDef.slots;
19
+ export default class ToolMark extends SvelteComponent<ToolMarkProps, ToolMarkEvents, ToolMarkSlots> {
20
+ }
21
+ export {};
@@ -0,0 +1,32 @@
1
+ <script>import { Icon } from "../../index.js";
2
+ import { tip } from "../../../action/tip.js";
3
+ export let icon;
4
+ export let label;
5
+ export let color;
6
+ export let setColor;
7
+ let inputColor;
8
+ function handleClick() {
9
+ inputColor.click();
10
+ setColor(color);
11
+ }
12
+ </script>
13
+
14
+ <div class="flex align-bottom">
15
+ <input
16
+ type="color"
17
+ tabindex="-1"
18
+ bind:value={color}
19
+ class="h-0 w-0 translate-y-8 border-none opacity-0 outline-none"
20
+ bind:this={inputColor}
21
+ on:input={() => setColor(color)}
22
+ />
23
+ <button type="button" class="menu-item gap-2" on:click={handleClick} use:tip={{ content: label }}>
24
+ <div class="indicator">
25
+ <span
26
+ class="badge indicator-item badge-xs scale-75 border transition-none"
27
+ style:background={color}
28
+ />
29
+ <Icon path={icon} size={19} class="opacity-70" />
30
+ </div>
31
+ </button>
32
+ </div>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ icon: string;
5
+ label: string;
6
+ color: string;
7
+ setColor: (color: string) => void;
8
+ };
9
+ events: {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {};
13
+ };
14
+ export type ToolMarkColorProps = typeof __propDef.props;
15
+ export type ToolMarkColorEvents = typeof __propDef.events;
16
+ export type ToolMarkColorSlots = typeof __propDef.slots;
17
+ export default class ToolMarkColor extends SvelteComponent<ToolMarkColorProps, ToolMarkColorEvents, ToolMarkColorSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,63 @@
1
+ <script>import { mdiLinkVariant } from "@mdi/js";
2
+ import { Dialog, InputText } from "../../index.js";
3
+ import { z } from "../../../validation/zod.js";
4
+ import ToolMark from "./ToolMark.svelte";
5
+ export let editor;
6
+ let dialogLink;
7
+ let linkHref = "";
8
+ let linkError = "";
9
+ async function handleNewLink() {
10
+ if (!linkHref) {
11
+ linkError = "URL requis";
12
+ return;
13
+ }
14
+ const isEmail = z.string().email().safeParse(linkHref);
15
+ if (isEmail.success)
16
+ linkHref = "mailto:" + linkHref;
17
+ else if (!linkHref.match(/^http(s)?:\/\//)) {
18
+ linkHref = "https://" + linkHref;
19
+ }
20
+ const isUrl = z.string().url().safeParse(linkHref);
21
+ if (!isUrl.success) {
22
+ linkError = "URL invalide";
23
+ return;
24
+ }
25
+ editor.chain().focus().setLink({ href: linkHref }).run();
26
+ dialogLink.close();
27
+ }
28
+ function handleRemoveLink() {
29
+ editor.chain().focus().unsetLink().run();
30
+ dialogLink.close();
31
+ }
32
+ function handleKeyDown(event) {
33
+ if (event.key !== "Enter")
34
+ return;
35
+ event.preventDefault();
36
+ handleNewLink();
37
+ }
38
+ </script>
39
+
40
+ <ToolMark
41
+ {editor}
42
+ key="link"
43
+ label="Lien"
44
+ icon={mdiLinkVariant}
45
+ action={() => {
46
+ const firstChild = editor.state.selection.content().content.firstChild
47
+ linkHref = editor.getAttributes('link').href || firstChild?.textContent || ''
48
+ dialogLink.showModal()
49
+ }}
50
+ />
51
+
52
+ <Dialog bind:dialog={dialogLink}>
53
+ <h3 slot="header" class="title">Éditer un lien</h3>
54
+ <div class="flex flex-col gap-2">
55
+ <InputText bind:value={linkHref} bind:error={linkError} on:keydown={handleKeyDown} />
56
+ <div class="flex flex-row-reverse gap-2">
57
+ <button type="button" class="btn" on:click={handleNewLink}> Valider </button>
58
+ <button type="button" class="btn btn-ghost text-error" on:click={handleRemoveLink}>
59
+ Supprimer
60
+ </button>
61
+ </div>
62
+ </div>
63
+ </Dialog>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Editor } from '@tiptap/core';
3
+ declare const __propDef: {
4
+ props: {
5
+ editor: Editor;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type ToolMarkLinkProps = typeof __propDef.props;
13
+ export type ToolMarkLinkEvents = typeof __propDef.events;
14
+ export type ToolMarkLinkSlots = typeof __propDef.slots;
15
+ export default class ToolMarkLink extends SvelteComponent<ToolMarkLinkProps, ToolMarkLinkEvents, ToolMarkLinkSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,50 @@
1
+ <script>import { mdiChevronDown } from "@mdi/js";
2
+ import { Icon, DropDown } from "../../index.js";
3
+ export let editor;
4
+ export let tools;
5
+ export let hideLabel = false;
6
+ let dropdown;
7
+ function handleClick(tool) {
8
+ tool.action();
9
+ dropdown.hide();
10
+ }
11
+ $:
12
+ toolSelected = tools.find((t) => {
13
+ if (t.key)
14
+ return editor.isActive(t.key, t.attributes);
15
+ if (t.attributes)
16
+ return editor.isActive(t.attributes);
17
+ return false;
18
+ }) || tools[0];
19
+ </script>
20
+
21
+ <DropDown hideOnBlur bind:this={dropdown}>
22
+ <button slot="activator" type="button" class="menu-item gap-2">
23
+ <slot name="activator">
24
+ <Icon path={toolSelected.icon} size={20} class="opacity-70" />
25
+ {#if !hideLabel}
26
+ <span class="text-sm font-light">{toolSelected.label}</span>
27
+ {/if}
28
+ </slot>
29
+ <Icon path={mdiChevronDown} size={20} class="translate-y-[1px] opacity-70" />
30
+ </button>
31
+
32
+ {#each tools as tool}
33
+ {#if tool.newSection}
34
+ <hr class="my-2" />
35
+ {/if}
36
+ <button
37
+ disabled={tool.disable}
38
+ type="button"
39
+ class="menu-item w-full"
40
+ class:disabled={tool.disable}
41
+ class:opacity-60={tool.disable}
42
+ on:click={() => handleClick(tool)}
43
+ >
44
+ <Icon path={tool.icon} size={20} class="opacity-70" />
45
+ <span>
46
+ {tool.label}
47
+ </span>
48
+ </button>
49
+ {/each}
50
+ </DropDown>
@@ -0,0 +1,29 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Editor } from '@tiptap/core';
3
+ declare const __propDef: {
4
+ props: {
5
+ editor: Editor;
6
+ tools: {
7
+ key?: string | undefined;
8
+ attributes?: {} | undefined;
9
+ label: string;
10
+ icon: string;
11
+ action: () => unknown;
12
+ newSection?: true | undefined;
13
+ disable?: boolean | undefined;
14
+ }[];
15
+ hideLabel?: boolean | undefined;
16
+ };
17
+ events: {
18
+ [evt: string]: CustomEvent<any>;
19
+ };
20
+ slots: {
21
+ activator: {};
22
+ };
23
+ };
24
+ export type ToolMenuProps = typeof __propDef.props;
25
+ export type ToolMenuEvents = typeof __propDef.events;
26
+ export type ToolMenuSlots = typeof __propDef.slots;
27
+ export default class ToolMenu extends SvelteComponent<ToolMenuProps, ToolMenuEvents, ToolMenuSlots> {
28
+ }
29
+ export {};
@@ -0,0 +1,46 @@
1
+ <script>import {
2
+ mdiAlignHorizontalLeft,
3
+ mdiAlignHorizontalCenter,
4
+ mdiAlignHorizontalRight,
5
+ mdiFormatIndentIncrease,
6
+ mdiFormatIndentDecrease
7
+ } from "@mdi/js";
8
+ import ToolMenu from "./ToolMenu.svelte";
9
+ export let editor;
10
+ </script>
11
+
12
+ <ToolMenu
13
+ {editor}
14
+ hideLabel
15
+ tools={[
16
+ {
17
+ attributes: { textAlign: 'left' },
18
+ label: 'Aligner à gauche',
19
+ icon: mdiAlignHorizontalLeft,
20
+ action: () => editor.commands.setTextAlign('left'),
21
+ },
22
+ {
23
+ attributes: { textAlign: 'center' },
24
+ label: 'Aligner au centre',
25
+ icon: mdiAlignHorizontalCenter,
26
+ action: () => editor.commands.setTextAlign('center'),
27
+ },
28
+ {
29
+ attributes: { textAlign: 'right' },
30
+ label: 'Aligner à droite',
31
+ icon: mdiAlignHorizontalRight,
32
+ action: () => editor.commands.setTextAlign('right'),
33
+ },
34
+ {
35
+ newSection: true,
36
+ label: 'Retrait à droite',
37
+ icon: mdiFormatIndentIncrease,
38
+ action: () => editor.commands.indent(),
39
+ },
40
+ {
41
+ label: 'Retrait à droite',
42
+ icon: mdiFormatIndentDecrease,
43
+ action: () => editor.commands.outdent(),
44
+ },
45
+ ]}
46
+ />
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Editor } from '@tiptap/core';
3
+ declare const __propDef: {
4
+ props: {
5
+ editor: Editor;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type ToolMenuAlignProps = typeof __propDef.props;
13
+ export type ToolMenuAlignEvents = typeof __propDef.events;
14
+ export type ToolMenuAlignSlots = typeof __propDef.slots;
15
+ export default class ToolMenuAlign extends SvelteComponent<ToolMenuAlignProps, ToolMenuAlignEvents, ToolMenuAlignSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,49 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ import { mdiPlus, mdiMinus, mdiImageOutline, mdiYoutube, mdiAt } from "@mdi/js";
3
+ import { Icon } from "../../index.js";
4
+ import ToolMenu from "./ToolMenu.svelte";
5
+ import { suggestionItems } from "./suggestion.js";
6
+ export let editor;
7
+ const dispatch = createEventDispatcher();
8
+ </script>
9
+
10
+ <ToolMenu
11
+ {editor}
12
+ tools={[
13
+ {
14
+ label: 'Séparateur',
15
+ icon: mdiMinus,
16
+ action: () => editor.commands.setHorizontalRule()
17
+ },
18
+ {
19
+ label: 'Image',
20
+ icon: mdiImageOutline,
21
+ action: () => dispatch('insertMedia')
22
+ },
23
+ {
24
+ label: 'Vidéo',
25
+ icon: mdiYoutube,
26
+ action: () => {
27
+ const src = prompt('Lien youtube')
28
+ if (!src) return
29
+ editor.commands.setYoutubeVideo({ src })
30
+ }
31
+ },
32
+ {
33
+ label: 'Valeur dynamic',
34
+ icon: mdiAt,
35
+ disable: !$suggestionItems.length,
36
+ action: () => {
37
+ const { from } = editor.state.selection
38
+ const lastChar = editor.state.doc.textBetween(from - 1, from)
39
+ const charToAdd = lastChar === '' || lastChar === ' ' ? '@' : ' @'
40
+ editor.chain().insertContent(charToAdd).focus().run()
41
+ }
42
+ }
43
+ ]}
44
+ hideLabel
45
+ >
46
+ <svelte:fragment slot="activator">
47
+ <Icon path={mdiPlus} size={20} class="opacity-70" />
48
+ </svelte:fragment>
49
+ </ToolMenu>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Editor } from '@tiptap/core';
3
+ declare const __propDef: {
4
+ props: {
5
+ editor: Editor;
6
+ };
7
+ events: {
8
+ insertMedia: CustomEvent<void>;
9
+ } & {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {};
13
+ };
14
+ export type ToolMenuInsertProps = typeof __propDef.props;
15
+ export type ToolMenuInsertEvents = typeof __propDef.events;
16
+ export type ToolMenuInsertSlots = typeof __propDef.slots;
17
+ export default class ToolMenuInsert extends SvelteComponent<ToolMenuInsertProps, ToolMenuInsertEvents, ToolMenuInsertSlots> {
18
+ }
19
+ export {};