fuma 2.0.49 → 2.1.0
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/dist/action/index.d.ts +2 -5
- package/dist/action/index.js +2 -5
- package/dist/action/list/handlers.d.ts +6 -6
- package/dist/action/list/handlers.js +6 -5
- package/dist/action/list/index.d.ts +1 -1
- package/dist/action/list/index.js +11 -5
- package/dist/action/list/trigger.js +6 -2
- package/dist/action/list/utils.js +1 -1
- package/dist/action/tip.js +2 -2
- package/dist/command/command.svelte.d.ts +16 -0
- package/dist/command/command.svelte.js +68 -0
- package/dist/command/index.d.ts +1 -0
- package/dist/command/index.js +1 -0
- package/dist/data.d.ts +87 -0
- package/dist/data.js +51 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/input/InputBoolean.svelte +107 -0
- package/dist/input/InputBoolean.svelte.d.ts +12 -0
- package/dist/input/InputNumber.svelte +33 -0
- package/dist/input/InputNumber.svelte.d.ts +10 -0
- package/dist/input/InputRadio.svelte +56 -0
- package/dist/input/InputRadio.svelte.d.ts +11 -0
- package/dist/input/InputRange.svelte +30 -0
- package/dist/input/InputRange.svelte.d.ts +10 -0
- package/dist/input/InputRelation.svelte +119 -0
- package/dist/input/InputRelation.svelte.d.ts +39 -0
- package/dist/input/InputSelect.svelte +113 -0
- package/dist/input/InputSelect.svelte.d.ts +37 -0
- package/dist/input/InputSelectNative.svelte +56 -0
- package/dist/input/InputSelectNative.svelte.d.ts +12 -0
- package/dist/input/InputString.svelte +48 -0
- package/dist/input/InputString.svelte.d.ts +11 -0
- package/dist/input/InputTextarea.svelte +47 -0
- package/dist/input/InputTextarea.svelte.d.ts +11 -0
- package/dist/input/Issues.svelte +21 -0
- package/dist/input/Issues.svelte.d.ts +7 -0
- package/dist/input/index.d.ts +11 -0
- package/dist/input/index.js +10 -0
- package/dist/input/type.d.ts +5 -0
- package/dist/input/type.js +1 -0
- package/dist/popover/Popover.svelte +50 -0
- package/dist/popover/index.d.ts +2 -0
- package/dist/popover/index.js +2 -0
- package/dist/popover/popover.svelte.d.ts +26 -0
- package/dist/popover/popover.svelte.js +101 -0
- package/dist/remote/useForm.d.ts +6 -0
- package/dist/remote/useForm.js +22 -0
- package/dist/search/Spans.svelte +15 -0
- package/dist/search/Spans.svelte.d.ts +7 -0
- package/dist/search/index.d.ts +2 -0
- package/dist/search/index.js +2 -0
- package/dist/search/search.js +96 -0
- package/dist/server/index.d.ts +0 -4
- package/dist/server/index.js +0 -4
- package/dist/server/parseQuery.js +1 -1
- package/dist/server/sse.js +4 -4
- package/dist/server/table.js +1 -1
- package/dist/state/index.d.ts +1 -0
- package/dist/state/index.js +1 -0
- package/dist/state/param.svelte.d.ts +18 -0
- package/dist/state/param.svelte.js +66 -0
- package/dist/ui/button/ButtonDelete.svelte +49 -28
- package/dist/ui/button/ButtonDelete.svelte.d.ts +12 -31
- package/dist/ui/button/index.d.ts +0 -1
- package/dist/ui/button/index.js +0 -1
- package/dist/ui/copy/ButtonCopy.svelte +43 -0
- package/dist/ui/copy/ButtonCopy.svelte.d.ts +17 -0
- package/dist/ui/copy/index.d.ts +2 -0
- package/dist/ui/copy/index.js +2 -0
- package/dist/ui/copy/useCopy.svelte.d.ts +10 -0
- package/dist/ui/copy/useCopy.svelte.js +36 -0
- package/dist/ui/dialog/Dialog.svelte +56 -26
- package/dist/ui/dialog/Dialog.svelte.d.ts +14 -35
- package/dist/ui/dialog/index.d.ts +0 -1
- package/dist/ui/dialog/index.js +0 -1
- package/dist/ui/drawer/Drawer.svelte +53 -45
- package/dist/ui/drawer/Drawer.svelte.d.ts +8 -63
- package/dist/ui/drawer/drawerFly.js +1 -1
- package/dist/ui/drawer/useLayer.svelte.d.ts +5 -0
- package/dist/ui/drawer/useLayer.svelte.js +33 -0
- package/dist/ui/index.d.ts +4 -12
- package/dist/ui/index.js +4 -12
- package/dist/ui/menu/ContextMenu.svelte +27 -26
- package/dist/ui/menu/ContextMenu.svelte.d.ts +9 -35
- package/dist/ui/menu/DropDown.svelte +44 -26
- package/dist/ui/menu/DropDown.svelte.d.ts +18 -43
- package/dist/ui/menu/DropDownMenu.svelte +51 -41
- package/dist/ui/menu/DropDownMenu.svelte.d.ts +7 -29
- package/dist/ui/menu/dropdown.css +4 -4
- package/dist/ui/menu/index.d.ts +1 -1
- package/dist/ui/menu/index.js +2 -1
- package/dist/ui/mode/ToggleMode.svelte +25 -14
- package/dist/ui/mode/ToggleMode.svelte.d.ts +10 -35
- package/dist/ui/mode/index.d.ts +1 -1
- package/dist/ui/mode/index.js +1 -1
- package/dist/ui/mode/useMode.svelte.d.ts +8 -0
- package/dist/ui/mode/useMode.svelte.js +40 -0
- package/dist/ui/pagination/Pagination.svelte +18 -14
- package/dist/ui/pagination/Pagination.svelte.d.ts +4 -18
- package/dist/ui/range/RangePicker.svelte +3 -2
- package/dist/ui/range/RangePickerButton.svelte +49 -37
- package/dist/ui/range/RangePickerButton.svelte.d.ts +7 -21
- package/dist/ui/range/index.d.ts +1 -1
- package/dist/ui/range/index.js +1 -1
- package/dist/ui/table/Table.svelte +15 -21
- package/dist/ui/table/Table.svelte.d.ts +1 -1
- package/dist/ui/table/TableBody.svelte +1 -1
- package/dist/ui/table/TableBody.svelte.d.ts +1 -1
- package/dist/ui/table/TableFieldsEdition.svelte +90 -78
- package/dist/ui/table/TableFieldsEdition.svelte.d.ts +14 -13
- package/dist/ui/table/TableHead.svelte +1 -1
- package/dist/ui/table/TableViewSelect.svelte +69 -69
- package/dist/ui/table/TableViewSelect.svelte.d.ts +10 -23
- package/dist/ui/table/cell/TableCellArray.svelte +1 -1
- package/dist/ui/table/cell/TableCellBoolean.svelte +3 -4
- package/dist/ui/table/cell/index.d.ts +1 -1
- package/dist/ui/table/cell/index.js +1 -1
- package/dist/ui/table/head/OrderButtons.svelte +18 -13
- package/dist/ui/table/head/OrderButtons.svelte.d.ts +11 -23
- package/dist/ui/table/head/TableHeadBoolean.svelte +3 -3
- package/dist/ui/table/head/TableHeadDate.svelte +41 -53
- package/dist/ui/table/head/TableHeadDate.svelte.d.ts +1 -1
- package/dist/ui/table/head/TableHeadDefault.svelte +2 -1
- package/dist/ui/table/head/TableHeadNumber.svelte +94 -108
- package/dist/ui/table/head/TableHeadNumber.svelte.d.ts +13 -10
- package/dist/ui/table/head/TableHeadSelect.svelte +55 -52
- package/dist/ui/table/head/TableHeadSelect.svelte.d.ts +13 -10
- package/dist/ui/table/head/TableHeadString.svelte +28 -34
- package/dist/ui/table/head/index.d.ts +3 -3
- package/dist/ui/table/head/index.js +3 -3
- package/dist/ui/table/index.d.ts +5 -5
- package/dist/ui/table/index.js +4 -5
- package/dist/utils/csv.js +1 -1
- package/dist/utils/eventEmitter.d.ts +2 -2
- package/dist/utils/eventEmitter.js +18 -11
- package/dist/utils/index.d.ts +4 -6
- package/dist/utils/index.js +4 -6
- package/dist/utils/normalizePath.js +1 -1
- package/dist/utils/options.d.ts +6 -5
- package/dist/utils/options.js +3 -2
- package/dist/utils/tippy.d.ts +1 -1
- package/dist/utils/tippy.js +1 -1
- package/dist/validation/index.d.ts +0 -1
- package/dist/validation/index.js +0 -1
- package/dist/validation/zod.d.ts +12 -393
- package/dist/validation/zod.js +22 -82
- package/package.json +111 -134
- package/dist/action/heightScreen.d.ts +0 -10
- package/dist/action/heightScreen.js +0 -24
- package/dist/action/portal.d.ts +0 -3
- package/dist/action/portal.js +0 -9
- package/dist/action/selector.d.ts +0 -15
- package/dist/action/selector.js +0 -71
- package/dist/api/client.d.ts +0 -3
- package/dist/api/client.js +0 -24
- package/dist/api/config.d.ts +0 -46
- package/dist/api/config.js +0 -7
- package/dist/api/index.d.ts +0 -3
- package/dist/api/index.js +0 -3
- package/dist/api/server.d.ts +0 -11
- package/dist/api/server.js +0 -17
- package/dist/private/Meta.svelte +0 -16
- package/dist/private/Meta.svelte.d.ts +0 -30
- package/dist/private/api.d.ts +0 -61
- package/dist/private/api.js +0 -10
- package/dist/private/constant.d.ts +0 -14
- package/dist/private/constant.js +0 -6
- package/dist/private/model.d.ts +0 -70
- package/dist/private/model.js +0 -25
- package/dist/private/prisma.d.ts +0 -2
- package/dist/private/prisma.js +0 -2
- package/dist/private/store.d.ts +0 -1
- package/dist/private/store.js +0 -2
- package/dist/server/auth.d.ts +0 -12
- package/dist/server/auth.js +0 -15
- package/dist/server/formAction.d.ts +0 -13
- package/dist/server/formAction.js +0 -8
- package/dist/server/json.d.ts +0 -1
- package/dist/server/json.js +0 -16
- package/dist/server/parseFormData.d.ts +0 -10
- package/dist/server/parseFormData.js +0 -85
- package/dist/server/try.d.ts +0 -9
- package/dist/server/try.js +0 -41
- package/dist/store/index.d.ts +0 -2
- package/dist/store/index.js +0 -2
- package/dist/store/isSmallScreen.d.ts +0 -1
- package/dist/store/isSmallScreen.js +0 -14
- package/dist/store/param.d.ts +0 -22
- package/dist/store/param.js +0 -61
- package/dist/store/session.d.ts +0 -1
- package/dist/store/session.js +0 -13
- package/dist/ui/badge/Badge.svelte +0 -9
- package/dist/ui/badge/Badge.svelte.d.ts +0 -21
- package/dist/ui/badge/index.d.ts +0 -1
- package/dist/ui/badge/index.js +0 -1
- package/dist/ui/button/ButtonCopy.svelte +0 -59
- package/dist/ui/button/ButtonCopy.svelte.d.ts +0 -27
- package/dist/ui/card/Card.svelte +0 -43
- package/dist/ui/card/Card.svelte.d.ts +0 -41
- package/dist/ui/card/CardBasic.svelte +0 -15
- package/dist/ui/card/CardBasic.svelte.d.ts +0 -31
- package/dist/ui/card/CardCollapse.svelte +0 -71
- package/dist/ui/card/CardCollapse.svelte.d.ts +0 -39
- package/dist/ui/card/CardFullScreen.svelte +0 -31
- package/dist/ui/card/CardFullScreen.svelte.d.ts +0 -38
- package/dist/ui/card/CardLink.svelte +0 -22
- package/dist/ui/card/CardLink.svelte.d.ts +0 -31
- package/dist/ui/card/index.d.ts +0 -5
- package/dist/ui/card/index.js +0 -5
- package/dist/ui/context.d.ts +0 -6
- package/dist/ui/context.js +0 -12
- package/dist/ui/dialog/DialogConfirm.svelte +0 -24
- package/dist/ui/dialog/DialogConfirm.svelte.d.ts +0 -35
- package/dist/ui/drawer/layers.d.ts +0 -7
- package/dist/ui/drawer/layers.js +0 -68
- package/dist/ui/form/Form.svelte +0 -168
- package/dist/ui/form/Form.svelte.d.ts +0 -62
- package/dist/ui/form/FormInput.svelte +0 -15
- package/dist/ui/form/FormSection.svelte +0 -78
- package/dist/ui/form/FormSection.svelte.d.ts +0 -39
- package/dist/ui/form/form.d.ts +0 -37
- package/dist/ui/form/form.js +0 -57
- package/dist/ui/form/formInput.js +0 -33
- package/dist/ui/form/index.d.ts +0 -3
- package/dist/ui/form/index.js +0 -3
- package/dist/ui/icon/Icon.svelte +0 -53
- package/dist/ui/icon/Icon.svelte.d.ts +0 -29
- package/dist/ui/icon/index.d.ts +0 -1
- package/dist/ui/icon/index.js +0 -1
- package/dist/ui/input/FormControl.svelte +0 -77
- package/dist/ui/input/FormControl.svelte.d.ts +0 -34
- package/dist/ui/input/InputBoolean.svelte +0 -33
- package/dist/ui/input/InputBoolean.svelte.d.ts +0 -46
- package/dist/ui/input/InputCheckboxs.svelte +0 -71
- package/dist/ui/input/InputCheckboxs.svelte.d.ts +0 -57
- package/dist/ui/input/InputCheckboxsMenu.svelte +0 -106
- package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +0 -59
- package/dist/ui/input/InputCheckboxsTree.svelte +0 -18
- package/dist/ui/input/InputCheckboxsTree.svelte.d.ts +0 -25
- package/dist/ui/input/InputCheckboxsTreeNodes.svelte +0 -68
- package/dist/ui/input/InputCheckboxsTreeNodes.svelte.d.ts +0 -27
- package/dist/ui/input/InputCombo.svelte +0 -99
- package/dist/ui/input/InputCombo.svelte.d.ts +0 -59
- package/dist/ui/input/InputDate.svelte +0 -47
- package/dist/ui/input/InputDate.svelte.d.ts +0 -46
- package/dist/ui/input/InputDateTime.svelte +0 -41
- package/dist/ui/input/InputDateTime.svelte.d.ts +0 -23
- package/dist/ui/input/InputImage.svelte +0 -116
- package/dist/ui/input/InputImage.svelte.d.ts +0 -48
- package/dist/ui/input/InputImagePreview.svelte +0 -60
- package/dist/ui/input/InputImagePreview.svelte.d.ts +0 -27
- package/dist/ui/input/InputNumber.svelte +0 -31
- package/dist/ui/input/InputNumber.svelte.d.ts +0 -23
- package/dist/ui/input/InputOptionInParam.svelte +0 -36
- package/dist/ui/input/InputOptionInParam.svelte.d.ts +0 -24
- package/dist/ui/input/InputOptions.svelte +0 -85
- package/dist/ui/input/InputOptions.svelte.d.ts +0 -21
- package/dist/ui/input/InputPassword.svelte +0 -25
- package/dist/ui/input/InputPassword.svelte.d.ts +0 -45
- package/dist/ui/input/InputRadio.svelte +0 -84
- package/dist/ui/input/InputRadio.svelte.d.ts +0 -56
- package/dist/ui/input/InputRelation.svelte +0 -171
- package/dist/ui/input/InputRelation.svelte.d.ts +0 -76
- package/dist/ui/input/InputRelations.svelte +0 -166
- package/dist/ui/input/InputRelations.svelte.d.ts +0 -55
- package/dist/ui/input/InputSearch.svelte +0 -59
- package/dist/ui/input/InputSearch.svelte.d.ts +0 -29
- package/dist/ui/input/InputSelect.svelte +0 -84
- package/dist/ui/input/InputSelect.svelte.d.ts +0 -29
- package/dist/ui/input/InputText.svelte +0 -46
- package/dist/ui/input/InputText.svelte.d.ts +0 -30
- package/dist/ui/input/InputTextarea.svelte +0 -23
- package/dist/ui/input/InputTextarea.svelte.d.ts +0 -23
- package/dist/ui/input/InputTime.svelte +0 -47
- package/dist/ui/input/InputTime.svelte.d.ts +0 -46
- package/dist/ui/input/RelationAfter.svelte +0 -34
- package/dist/ui/input/RelationAfter.svelte.d.ts +0 -26
- package/dist/ui/input/SelectorList.svelte +0 -50
- package/dist/ui/input/SelectorList.svelte.d.ts +0 -49
- package/dist/ui/input/action.d.ts +0 -13
- package/dist/ui/input/action.js +0 -56
- package/dist/ui/input/index.d.ts +0 -26
- package/dist/ui/input/index.js +0 -26
- package/dist/ui/input/textRich/InputTextRich.svelte +0 -72
- package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +0 -48
- package/dist/ui/input/textRich/SuggesionList.svelte +0 -25
- package/dist/ui/input/textRich/SuggesionList.svelte.d.ts +0 -23
- package/dist/ui/input/textRich/ToolMark.svelte +0 -22
- package/dist/ui/input/textRich/ToolMark.svelte.d.ts +0 -25
- package/dist/ui/input/textRich/ToolMarkColor.svelte +0 -36
- package/dist/ui/input/textRich/ToolMarkColor.svelte.d.ts +0 -23
- package/dist/ui/input/textRich/ToolMarkLink.svelte +0 -72
- package/dist/ui/input/textRich/ToolMarkLink.svelte.d.ts +0 -21
- package/dist/ui/input/textRich/ToolMenu.svelte +0 -66
- package/dist/ui/input/textRich/ToolMenu.svelte.d.ts +0 -33
- package/dist/ui/input/textRich/ToolMenuAlign.svelte +0 -50
- package/dist/ui/input/textRich/ToolMenuAlign.svelte.d.ts +0 -21
- package/dist/ui/input/textRich/ToolMenuInsert.svelte +0 -54
- package/dist/ui/input/textRich/ToolMenuInsert.svelte.d.ts +0 -23
- package/dist/ui/input/textRich/ToolMenuNode.svelte +0 -60
- package/dist/ui/input/textRich/ToolMenuNode.svelte.d.ts +0 -21
- package/dist/ui/input/textRich/ToolsBar.svelte +0 -61
- package/dist/ui/input/textRich/ToolsBar.svelte.d.ts +0 -24
- package/dist/ui/input/textRich/extensions.d.ts +0 -2
- package/dist/ui/input/textRich/extensions.js +0 -62
- package/dist/ui/input/textRich/indent.d.ts +0 -13
- package/dist/ui/input/textRich/indent.js +0 -112
- package/dist/ui/input/textRich/index.d.ts +0 -3
- package/dist/ui/input/textRich/index.js +0 -3
- package/dist/ui/input/textRich/suggestion.d.ts +0 -7
- package/dist/ui/input/textRich/suggestion.js +0 -55
- package/dist/ui/input/textRich/tiptapParser.d.ts +0 -4
- package/dist/ui/input/textRich/tiptapParser.js +0 -29
- package/dist/ui/input/types.d.ts +0 -15
- package/dist/ui/input/types.js +0 -1
- package/dist/ui/login/Login.svelte +0 -99
- package/dist/ui/login/Login.svelte.d.ts +0 -20
- package/dist/ui/login/index.d.ts +0 -1
- package/dist/ui/login/index.js +0 -1
- package/dist/ui/placeholder/Placeholder.svelte +0 -12
- package/dist/ui/placeholder/Placeholder.svelte.d.ts +0 -30
- package/dist/ui/placeholder/PlaceholderImage.svelte +0 -16
- package/dist/ui/placeholder/PlaceholderImage.svelte.d.ts +0 -30
- package/dist/ui/placeholder/index.d.ts +0 -2
- package/dist/ui/placeholder/index.js +0 -2
- package/dist/ui/tabs/Tabs.svelte +0 -32
- package/dist/ui/tabs/Tabs.svelte.d.ts +0 -22
- package/dist/ui/tabs/TabsIcon.svelte +0 -60
- package/dist/ui/tabs/TabsIcon.svelte.d.ts +0 -24
- package/dist/ui/tabs/index.d.ts +0 -8
- package/dist/ui/tabs/index.js +0 -2
- package/dist/utils/avatar.d.ts +0 -1
- package/dist/utils/avatar.js +0 -5
- package/dist/utils/component.d.ts +0 -6
- package/dist/utils/component.js +0 -3
- package/dist/validation/form.d.ts +0 -34
- package/dist/validation/form.js +0 -103
package/dist/action/index.d.ts
CHANGED
package/dist/action/index.js
CHANGED
|
@@ -7,14 +7,14 @@ export type Position = {
|
|
|
7
7
|
export type DragHandler = ReturnType<typeof createDragHandler>;
|
|
8
8
|
export declare function createDragHandler<Type = unknown>(listElement: HTMLDivElement | HTMLUListElement, itemElement: HTMLElement, options: ListEditableOptions<Type>): {
|
|
9
9
|
on: <K extends "dragStart" | "dragMove" | "dragEnd">(eventKey: K, callback: (arg: {
|
|
10
|
-
dragStart:
|
|
11
|
-
dragMove:
|
|
12
|
-
dragEnd:
|
|
10
|
+
dragStart: undefined;
|
|
11
|
+
dragMove: undefined;
|
|
12
|
+
dragEnd: undefined;
|
|
13
13
|
}[K]) => unknown) => () => void;
|
|
14
14
|
off: <K extends "dragStart" | "dragMove" | "dragEnd">(eventKey: K, callback: (arg: {
|
|
15
|
-
dragStart:
|
|
16
|
-
dragMove:
|
|
17
|
-
dragEnd:
|
|
15
|
+
dragStart: undefined;
|
|
16
|
+
dragMove: undefined;
|
|
17
|
+
dragEnd: undefined;
|
|
18
18
|
}[K]) => unknown) => void;
|
|
19
19
|
start(position: Position): void;
|
|
20
20
|
move(position?: Position): void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import './index.css';
|
|
2
|
+
import { createEventEmitter } from '../../utils/eventEmitter.js';
|
|
2
3
|
import { CLASSNAME_DRAG_ACTIVE } from './index.js';
|
|
3
|
-
import { initDragStyle, resetDragStyle } from './style.js';
|
|
4
|
-
import { createPlaceholder, computeLimits, getNewOrderIndex, getListItemIndex } from './utils.js';
|
|
5
4
|
import { scroll } from './store.js';
|
|
6
|
-
import {
|
|
5
|
+
import { initDragStyle, resetDragStyle } from './style.js';
|
|
6
|
+
import { computeLimits, createPlaceholder, getListItemIndex, getNewOrderIndex } from './utils.js';
|
|
7
7
|
export function createDragHandler(listElement, itemElement, options) {
|
|
8
8
|
let originMouseY = 0;
|
|
9
9
|
let limits = null;
|
|
@@ -67,11 +67,12 @@ export function createDragHandler(listElement, itemElement, options) {
|
|
|
67
67
|
if (options.onReindex)
|
|
68
68
|
options.onReindex(newOrderIndex);
|
|
69
69
|
if (options.onChange) {
|
|
70
|
-
|
|
70
|
+
const { items } = options;
|
|
71
|
+
if (!items) {
|
|
71
72
|
console.error('WARNING', 'The option "onChange" require "items"');
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
|
-
const newOrderItems = newOrderIndex.map((index) =>
|
|
75
|
+
const newOrderItems = newOrderIndex.map((index) => items[index]);
|
|
75
76
|
options.onChange(newOrderItems);
|
|
76
77
|
options.items = newOrderItems;
|
|
77
78
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mouseDragTrigger,
|
|
1
|
+
import { mouseDragTrigger, scrollTrigger, touchDragTrigger } from './trigger.js';
|
|
2
2
|
export declare const CLASSNAME_LIST = "editable-list";
|
|
3
3
|
export declare const CLASSNAME_DRAG_ACTIVE = "drag-active";
|
|
4
4
|
export declare const CLASSNAME_PLACEHOLDER = "item-placeholder";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDragHandler } from './handlers.js';
|
|
2
|
-
import { mouseDragTrigger,
|
|
2
|
+
import { mouseDragTrigger, scrollTrigger, touchDragTrigger } from './trigger.js';
|
|
3
3
|
export const CLASSNAME_LIST = 'editable-list';
|
|
4
4
|
export const CLASSNAME_DRAG_ACTIVE = 'drag-active';
|
|
5
5
|
export const CLASSNAME_PLACEHOLDER = 'item-placeholder';
|
|
@@ -16,7 +16,7 @@ export function listEditable(node, options = {}) {
|
|
|
16
16
|
const dragElements = [
|
|
17
17
|
...(dragElementsSelector ? node.querySelectorAll(dragElementsSelector) : itemElements)
|
|
18
18
|
];
|
|
19
|
-
const dragHandlers = dragElements.map((
|
|
19
|
+
const dragHandlers = dragElements.map((_element, index) => createDragHandler(node, itemElements[index], options));
|
|
20
20
|
mouseListeners = dragElements.map((dragElement, index) => mouseDragTrigger(dragElement, dragHandlers[index]));
|
|
21
21
|
touchListeners = dragElements.map((dragElement, index) => touchDragTrigger(dragElement, dragHandlers[index]));
|
|
22
22
|
const scrollContainer = node.parentElement;
|
|
@@ -25,9 +25,15 @@ export function listEditable(node, options = {}) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function removeListeners() {
|
|
28
|
-
mouseListeners.forEach((listener) =>
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
mouseListeners.forEach((listener) => {
|
|
29
|
+
listener.destroy();
|
|
30
|
+
});
|
|
31
|
+
touchListeners.forEach((listener) => {
|
|
32
|
+
listener.destroy();
|
|
33
|
+
});
|
|
34
|
+
scrollListeners.forEach((listener) => {
|
|
35
|
+
listener.destroy();
|
|
36
|
+
});
|
|
31
37
|
}
|
|
32
38
|
return {
|
|
33
39
|
destroy() {
|
|
@@ -109,7 +109,9 @@ export function scrollTrigger(handler, scrollContainer) {
|
|
|
109
109
|
listeners = [createScrollListener(), createMouseListener()];
|
|
110
110
|
}
|
|
111
111
|
function dragEnd() {
|
|
112
|
-
listeners.forEach(({ destroy }) =>
|
|
112
|
+
listeners.forEach(({ destroy }) => {
|
|
113
|
+
destroy();
|
|
114
|
+
});
|
|
113
115
|
listeners = [];
|
|
114
116
|
}
|
|
115
117
|
handler.on('dragStart', dragStart);
|
|
@@ -118,7 +120,9 @@ export function scrollTrigger(handler, scrollContainer) {
|
|
|
118
120
|
destroy() {
|
|
119
121
|
handler.off('dragStart', dragStart);
|
|
120
122
|
handler.off('dragEnd', dragEnd);
|
|
121
|
-
listeners.forEach(({ destroy }) =>
|
|
123
|
+
listeners.forEach(({ destroy }) => {
|
|
124
|
+
destroy();
|
|
125
|
+
});
|
|
122
126
|
}
|
|
123
127
|
};
|
|
124
128
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CLASSNAME_PLACEHOLDER } from './index.js';
|
|
2
2
|
export function getListItemIndex(listElement, itemEl) {
|
|
3
|
-
return [...listElement.children].
|
|
3
|
+
return [...listElement.children].indexOf(itemEl);
|
|
4
4
|
}
|
|
5
5
|
export function createPlaceholder({ listElement, itemElement, indexFrom }) {
|
|
6
6
|
const itemsEl = [...listElement.children];
|
package/dist/action/tip.js
CHANGED
|
@@ -2,8 +2,8 @@ import { tippy } from '../utils/tippy.js';
|
|
|
2
2
|
export function tip(node, options = { disable: false }) {
|
|
3
3
|
let _tip = null;
|
|
4
4
|
init(options);
|
|
5
|
-
function init({ disable, ...tippyProps }) {
|
|
6
|
-
_tip = disable ? null : tippy(node, tippyProps);
|
|
5
|
+
function init({ disable, content, ...tippyProps }) {
|
|
6
|
+
_tip = disable || !content ? null : tippy(node, { ...tippyProps, content });
|
|
7
7
|
}
|
|
8
8
|
return {
|
|
9
9
|
destroy() {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type CommandOptions = {
|
|
2
|
+
isEnable?: () => boolean;
|
|
3
|
+
onSelect?: (index: number) => unknown;
|
|
4
|
+
onFocus?: (index: number) => unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare function useCommand({ onSelect, onFocus, isEnable }?: CommandOptions): {
|
|
7
|
+
readonly focusIndex: number;
|
|
8
|
+
readonly selectedIndex: number;
|
|
9
|
+
trigger: {
|
|
10
|
+
[x: symbol]: (node: HTMLElement) => () => void;
|
|
11
|
+
};
|
|
12
|
+
item: (index: number, scrollMargin?: string) => {
|
|
13
|
+
[x: symbol]: (node: HTMLElement) => () => void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createAttachmentKey } from 'svelte/attachments';
|
|
2
|
+
import { on } from 'svelte/events';
|
|
3
|
+
export function useCommand({ onSelect, onFocus, isEnable = () => true } = {}) {
|
|
4
|
+
let focusIndex = $state(0);
|
|
5
|
+
let selectedIndex = $state(-1);
|
|
6
|
+
const items = [];
|
|
7
|
+
function onKeydown(event) {
|
|
8
|
+
if (!isEnable())
|
|
9
|
+
return;
|
|
10
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
onSelect?.(focusIndex);
|
|
13
|
+
selectedIndex = focusIndex;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (event.key === 'ArrowUp') {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
focusIndex--;
|
|
19
|
+
if (focusIndex < 0)
|
|
20
|
+
focusIndex = items.length - 1;
|
|
21
|
+
onFocus?.(focusIndex);
|
|
22
|
+
scrollFocusIntoView();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (event.key === 'ArrowDown') {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
focusIndex++;
|
|
28
|
+
if (focusIndex > items.length - 1)
|
|
29
|
+
focusIndex = 0;
|
|
30
|
+
onFocus?.(focusIndex);
|
|
31
|
+
scrollFocusIntoView();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function scrollFocusIntoView() {
|
|
36
|
+
items.at(focusIndex)?.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
get focusIndex() {
|
|
40
|
+
return focusIndex;
|
|
41
|
+
},
|
|
42
|
+
get selectedIndex() {
|
|
43
|
+
return selectedIndex;
|
|
44
|
+
},
|
|
45
|
+
trigger: {
|
|
46
|
+
[createAttachmentKey()]: (node) => {
|
|
47
|
+
return on(node, 'keydown', onKeydown);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
item: (index, scrollMargin = '8px') => ({
|
|
51
|
+
[createAttachmentKey()]: (node) => {
|
|
52
|
+
node.style.scrollMargin = scrollMargin;
|
|
53
|
+
if (!items.includes(node))
|
|
54
|
+
items.splice(index, 0, node);
|
|
55
|
+
const cleanup = on(node, 'click', () => {
|
|
56
|
+
focusIndex = selectedIndex = items.indexOf(node);
|
|
57
|
+
onSelect?.(selectedIndex);
|
|
58
|
+
});
|
|
59
|
+
return () => {
|
|
60
|
+
cleanup();
|
|
61
|
+
const i = items.indexOf(node);
|
|
62
|
+
if (i !== -1)
|
|
63
|
+
items.splice(i, 1);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './command.svelte.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './command.svelte.ts';
|
package/dist/data.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export declare const users: User[];
|
|
3
|
+
export type UserGender = (typeof userGenders)[number];
|
|
4
|
+
export type UserTag = (typeof userTags)[number];
|
|
5
|
+
export type User = {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
age: number;
|
|
9
|
+
level: number;
|
|
10
|
+
cv: string;
|
|
11
|
+
isValided: boolean;
|
|
12
|
+
subscribeAt: string;
|
|
13
|
+
gender: UserGender;
|
|
14
|
+
gender2: UserGender;
|
|
15
|
+
loveId?: string | null;
|
|
16
|
+
};
|
|
17
|
+
export declare const userGenders: readonly ["male", "female", "other"];
|
|
18
|
+
export declare const userTags: readonly ["rider", "biker", "skier"];
|
|
19
|
+
export declare const schemaUser: z.ZodObject<{
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
age: z.ZodNumber;
|
|
22
|
+
level: z.ZodNumber;
|
|
23
|
+
cv: z.ZodString;
|
|
24
|
+
isValided: z.ZodLiteral<true>;
|
|
25
|
+
subscribeAt: z.z.ZodISODate;
|
|
26
|
+
gender: z.ZodEnum<{
|
|
27
|
+
other: "other";
|
|
28
|
+
female: "female";
|
|
29
|
+
male: "male";
|
|
30
|
+
}>;
|
|
31
|
+
gender2: z.ZodEnum<{
|
|
32
|
+
other: "other";
|
|
33
|
+
female: "female";
|
|
34
|
+
male: "male";
|
|
35
|
+
}>;
|
|
36
|
+
loveId: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.z.core.$strip>;
|
|
38
|
+
export declare const userGenderOptions: {
|
|
39
|
+
male: {
|
|
40
|
+
label: string;
|
|
41
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
42
|
+
};
|
|
43
|
+
female: {
|
|
44
|
+
label: string;
|
|
45
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
46
|
+
};
|
|
47
|
+
other: {
|
|
48
|
+
label: string;
|
|
49
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare const userTagOptions: {
|
|
53
|
+
biker: {
|
|
54
|
+
label: string;
|
|
55
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
56
|
+
};
|
|
57
|
+
rider: {
|
|
58
|
+
label: string;
|
|
59
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
60
|
+
};
|
|
61
|
+
skier: {
|
|
62
|
+
label: string;
|
|
63
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export declare const fruitsOptions: {
|
|
67
|
+
apple: {
|
|
68
|
+
label: string;
|
|
69
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
70
|
+
};
|
|
71
|
+
banana: {
|
|
72
|
+
label: string;
|
|
73
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
74
|
+
};
|
|
75
|
+
cherry: {
|
|
76
|
+
label: string;
|
|
77
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
78
|
+
};
|
|
79
|
+
citrus: {
|
|
80
|
+
label: string;
|
|
81
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
82
|
+
};
|
|
83
|
+
grape: {
|
|
84
|
+
label: string;
|
|
85
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
86
|
+
};
|
|
87
|
+
};
|
package/dist/data.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker/locale/fr_CH';
|
|
2
|
+
import { AppleIcon, BananaIcon, BikeIcon, CableCarIcon, CherryIcon, CitrusIcon, GrapeIcon, MarsIcon, MotorbikeIcon, VenusAndMarsIcon, VenusIcon } from '@lucide/svelte';
|
|
3
|
+
import z from 'zod';
|
|
4
|
+
// NOT A PART OF PACKAGE
|
|
5
|
+
function createRandomUser() {
|
|
6
|
+
return {
|
|
7
|
+
id: Math.random().toString().slice(-16),
|
|
8
|
+
name: faker.person.fullName(),
|
|
9
|
+
age: Math.round(Math.random() * 100),
|
|
10
|
+
level: Math.round(Math.random() * 100),
|
|
11
|
+
cv: faker.person.bio(),
|
|
12
|
+
isValided: Math.random() < 0.5,
|
|
13
|
+
subscribeAt: faker.date.past().toISOString(),
|
|
14
|
+
gender: faker.person.sexType(),
|
|
15
|
+
gender2: faker.person.sexType()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export const users = faker.helpers.multiple(createRandomUser, {
|
|
19
|
+
count: 40
|
|
20
|
+
});
|
|
21
|
+
export const userGenders = ['male', 'female', 'other'];
|
|
22
|
+
export const userTags = ['rider', 'biker', 'skier'];
|
|
23
|
+
export const schemaUser = z.object({
|
|
24
|
+
name: z.string().min(3),
|
|
25
|
+
age: z.number().min(18).max(120),
|
|
26
|
+
level: z.number().min(0).max(100),
|
|
27
|
+
cv: z.string(),
|
|
28
|
+
isValided: z.literal(true, 'Validation requise'),
|
|
29
|
+
subscribeAt: z.iso.date(),
|
|
30
|
+
gender: z.enum(userGenders),
|
|
31
|
+
gender2: z.enum(userGenders),
|
|
32
|
+
loveId: z.string().optional()
|
|
33
|
+
// tags: z.array(z.enum(userTags)).default([]),
|
|
34
|
+
});
|
|
35
|
+
export const userGenderOptions = {
|
|
36
|
+
male: { label: 'Homme', icon: MarsIcon },
|
|
37
|
+
female: { label: 'Femme', icon: VenusIcon },
|
|
38
|
+
other: { label: 'Autre', icon: VenusAndMarsIcon }
|
|
39
|
+
};
|
|
40
|
+
export const userTagOptions = {
|
|
41
|
+
biker: { label: 'Biker', icon: BikeIcon },
|
|
42
|
+
rider: { label: 'Rider', icon: MotorbikeIcon },
|
|
43
|
+
skier: { label: 'Skier', icon: CableCarIcon }
|
|
44
|
+
};
|
|
45
|
+
export const fruitsOptions = {
|
|
46
|
+
apple: { label: 'Apple', icon: AppleIcon },
|
|
47
|
+
banana: { label: 'Banana', icon: BananaIcon },
|
|
48
|
+
cherry: { label: 'Cherry', icon: CherryIcon },
|
|
49
|
+
citrus: { label: 'Citrus', icon: CitrusIcon },
|
|
50
|
+
grape: { label: 'Grape', icon: GrapeIcon }
|
|
51
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './action/index.ts';
|
|
2
|
+
export * from './state/index.ts';
|
|
3
|
+
export * from './ui/index.ts';
|
|
4
|
+
export * from './utils/index.ts';
|
|
5
|
+
export * from './validation/index.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './action/index.ts';
|
|
2
|
+
export * from './state/index.ts';
|
|
3
|
+
export * from './ui/index.ts';
|
|
4
|
+
export * from './utils/index.ts';
|
|
5
|
+
export * from './validation/index.ts';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { CheckIcon } from '@lucide/svelte'
|
|
3
|
+
import type { RemoteFormField } from '@sveltejs/kit'
|
|
4
|
+
import Issues from './Issues.svelte'
|
|
5
|
+
import type { InputProps } from './type.ts'
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
field,
|
|
9
|
+
label,
|
|
10
|
+
checked = $bindable(),
|
|
11
|
+
hint,
|
|
12
|
+
variant = 'checkbox',
|
|
13
|
+
class: klass,
|
|
14
|
+
...props
|
|
15
|
+
}: {
|
|
16
|
+
label: string
|
|
17
|
+
field?: RemoteFormField<boolean>
|
|
18
|
+
checked?: boolean
|
|
19
|
+
hint?: string
|
|
20
|
+
variant?: 'checkbox' | 'switch'
|
|
21
|
+
} & InputProps = $props()
|
|
22
|
+
|
|
23
|
+
let isChecked = $derived(field?.value() ?? checked)
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<div>
|
|
27
|
+
<label
|
|
28
|
+
class={[
|
|
29
|
+
'input block not-disabled:cursor-pointer not-disabled:hover:bg-base-200',
|
|
30
|
+
'group h-auto min-h-10'
|
|
31
|
+
]}
|
|
32
|
+
>
|
|
33
|
+
<div class="flex h-(--size) items-center gap-2">
|
|
34
|
+
<div class="grow">{label}</div>
|
|
35
|
+
{#if field}
|
|
36
|
+
<input {...field.as('checkbox')} class={['peer w-0']} {...props} />
|
|
37
|
+
{:else}
|
|
38
|
+
<input type="checkbox" class={['peer w-0']} bind:checked {...props} />
|
|
39
|
+
{/if}
|
|
40
|
+
{#if variant === 'checkbox'}
|
|
41
|
+
{@render variantCheckbox()}
|
|
42
|
+
{:else}
|
|
43
|
+
{@render variantSwitch()}
|
|
44
|
+
{/if}
|
|
45
|
+
</div>
|
|
46
|
+
{#if hint}
|
|
47
|
+
<div
|
|
48
|
+
class={[
|
|
49
|
+
'-translate-y-2.5 text-xs text-wrap opacity-70',
|
|
50
|
+
variant === 'checkbox' ? 'pr-8' : 'pr-10'
|
|
51
|
+
]}
|
|
52
|
+
>
|
|
53
|
+
{hint}
|
|
54
|
+
</div>
|
|
55
|
+
{/if}
|
|
56
|
+
</label>
|
|
57
|
+
<Issues {field} />
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
{#snippet variantCheckbox()}
|
|
61
|
+
<div class={['squircle h-5 w-5 outline', 'bg-base-100']}>
|
|
62
|
+
<div
|
|
63
|
+
class={[
|
|
64
|
+
'squircle grid h-5 w-5 place-content-center',
|
|
65
|
+
'bg-base-content',
|
|
66
|
+
'ease scale-0 opacity-0',
|
|
67
|
+
isChecked && 'scale-[80%] opacity-100'
|
|
68
|
+
]}
|
|
69
|
+
>
|
|
70
|
+
<CheckIcon size={18} class={['stroke-base-100']} strokeWidth={4} />
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
{/snippet}
|
|
74
|
+
|
|
75
|
+
{#snippet variantSwitch()}
|
|
76
|
+
<div class={['h-5 w-9 rounded-full bg-base-100 p-1 outline-1']}>
|
|
77
|
+
<div
|
|
78
|
+
class={[
|
|
79
|
+
'grid h-3 w-3 place-content-center rounded-full bg-base-100 outline-1',
|
|
80
|
+
'ease translate-x-0',
|
|
81
|
+
isChecked ? 'translate-x-4 bg-base-content' : 'opacity-100'
|
|
82
|
+
]}
|
|
83
|
+
>
|
|
84
|
+
<CheckIcon size={11} class={['stroke-base-100']} strokeWidth={4} />
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
{/snippet}
|
|
88
|
+
|
|
89
|
+
<style>
|
|
90
|
+
.ease {
|
|
91
|
+
transition-property: translate background-color opacity;
|
|
92
|
+
transition-timing-function: cubic-bezier(0.275, 0.485, 0.515, 1.45);
|
|
93
|
+
transition-duration: 200ms;
|
|
94
|
+
}
|
|
95
|
+
.squircle {
|
|
96
|
+
corner-shape: squircle;
|
|
97
|
+
border-radius: 100%;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
label:has(input[aria-invalid='true']) {
|
|
101
|
+
--input-color: var(--color-error);
|
|
102
|
+
}
|
|
103
|
+
label:has(input:disabled) {
|
|
104
|
+
cursor: not-allowed;
|
|
105
|
+
border-color: var(--input-color);
|
|
106
|
+
}
|
|
107
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RemoteFormField } from '@sveltejs/kit';
|
|
2
|
+
import type { InputProps } from './type.ts';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
label: string;
|
|
5
|
+
field?: RemoteFormField<boolean>;
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
hint?: string;
|
|
8
|
+
variant?: 'checkbox' | 'switch';
|
|
9
|
+
} & InputProps;
|
|
10
|
+
declare const InputBoolean: import("svelte").Component<$$ComponentProps, {}, "checked">;
|
|
11
|
+
type InputBoolean = ReturnType<typeof InputBoolean>;
|
|
12
|
+
export default InputBoolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { RemoteFormField } from '@sveltejs/kit'
|
|
3
|
+
import Issues from './Issues.svelte'
|
|
4
|
+
import type { InputProps } from './type.ts'
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
label,
|
|
8
|
+
field,
|
|
9
|
+
value = $bindable(),
|
|
10
|
+
class: klass,
|
|
11
|
+
...props
|
|
12
|
+
}: {
|
|
13
|
+
label: string
|
|
14
|
+
field?: RemoteFormField<number>
|
|
15
|
+
value?: number
|
|
16
|
+
} & InputProps = $props()
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<label class="floating-label">
|
|
20
|
+
<span class="label">{label}</span>
|
|
21
|
+
{#if field}
|
|
22
|
+
<input placeholder={label} class={['input', klass]} {...field.as('number')} {...props} />
|
|
23
|
+
{:else}
|
|
24
|
+
<input placeholder={label} class={['input', klass]} type="number" bind:value {...props} />
|
|
25
|
+
{/if}
|
|
26
|
+
<Issues {field} />
|
|
27
|
+
</label>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
input[aria-invalid='true'] {
|
|
31
|
+
--input-color: var(--color-error);
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RemoteFormField } from '@sveltejs/kit';
|
|
2
|
+
import type { InputProps } from './type.ts';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
label: string;
|
|
5
|
+
field?: RemoteFormField<number>;
|
|
6
|
+
value?: number;
|
|
7
|
+
} & InputProps;
|
|
8
|
+
declare const InputNumber: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
9
|
+
type InputNumber = ReturnType<typeof InputNumber>;
|
|
10
|
+
export default InputNumber;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { RemoteFormField } from '@sveltejs/kit'
|
|
3
|
+
import { type Options, parseOptions } from '../utils/index.ts'
|
|
4
|
+
import Issues from './Issues.svelte'
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
field,
|
|
8
|
+
label,
|
|
9
|
+
value = $bindable(),
|
|
10
|
+
options: optionsProp
|
|
11
|
+
}: {
|
|
12
|
+
field?: RemoteFormField<string>
|
|
13
|
+
label: string
|
|
14
|
+
value?: string
|
|
15
|
+
options: Options
|
|
16
|
+
} = $props()
|
|
17
|
+
|
|
18
|
+
const options = $derived(parseOptions(optionsProp))
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div class="flex flex-col gap-1">
|
|
22
|
+
<span class="label px-3 text-sm">{label}</span>
|
|
23
|
+
<div class="join join-vertical">
|
|
24
|
+
{#each options as option}
|
|
25
|
+
{@const { class: klass, ...props } = option}
|
|
26
|
+
<label class="input join-item not-disabled:cursor-pointer not-disabled:hover:bg-base-200">
|
|
27
|
+
{#if option.icon}
|
|
28
|
+
<option.icon size={18} opacity={0.8} />
|
|
29
|
+
{/if}
|
|
30
|
+
<span>{option.label}</span>
|
|
31
|
+
{#if field}
|
|
32
|
+
<input
|
|
33
|
+
{...field.as('radio', option.value)}
|
|
34
|
+
class={['radio ml-auto radio-sm', klass]}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
{:else}
|
|
38
|
+
<input
|
|
39
|
+
type="radio"
|
|
40
|
+
checked={value === option.value}
|
|
41
|
+
onchange={() => (value = option.value)}
|
|
42
|
+
class={['radio ml-auto radio-sm', klass]}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
{/if}
|
|
46
|
+
</label>
|
|
47
|
+
{/each}
|
|
48
|
+
</div>
|
|
49
|
+
<Issues {field} />
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<style>
|
|
53
|
+
input {
|
|
54
|
+
--input-color: var(--color-base-content);
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RemoteFormField } from '@sveltejs/kit';
|
|
2
|
+
import { type Options } from '../utils/index.ts';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
field?: RemoteFormField<string>;
|
|
5
|
+
label: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
options: Options;
|
|
8
|
+
};
|
|
9
|
+
declare const InputRadio: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
10
|
+
type InputRadio = ReturnType<typeof InputRadio>;
|
|
11
|
+
export default InputRadio;
|