native-document 1.0.138 → 1.0.140
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/components.js +1 -1
- package/devtools/ComponentRegistry.js +3 -2
- package/dist/native-document.components.min.css +1 -0
- package/dist/native-document.components.min.js +11506 -8566
- package/dist/native-document.dev.js +2645 -2166
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/index.js +1 -0
- package/package.json +5 -2
- package/rollup.config.js +5 -2
- package/src/components/$traits/has-draggable/HasDraggable.js +69 -0
- package/src/components/$traits/has-draggable/has-draggable.css +8 -0
- package/src/components/$traits/{HasItems.js → has-items/HasItems.js} +2 -11
- package/src/components/$traits/has-position/HasFullPosition.js +51 -0
- package/src/components/$traits/has-position/HasPosition.js +23 -0
- package/src/components/$traits/has-resizable/HasResizable.js +113 -0
- package/src/components/$traits/has-resizable/has-resizable.css +121 -0
- package/src/components/$traits/has-validation/HasValidation.js +86 -0
- package/src/components/BaseComponent.js +109 -4
- package/src/components/accordion/Accordion.js +37 -31
- package/src/components/accordion/AccordionItem.js +14 -21
- package/src/components/alert/Alert.js +48 -40
- package/src/components/avatar/Avatar.js +4 -3
- package/src/components/avatar/AvatarGroup.js +8 -2
- package/src/components/badge/Badge.js +7 -7
- package/src/components/base-component.css +0 -0
- package/src/components/breadcrumb/BreadCrumb.js +30 -21
- package/src/components/button/Button.js +3 -14
- package/src/components/context-menu/ContextMenu.js +49 -26
- package/src/components/dropdown/Dropdown.js +172 -34
- package/src/components/dropdown/DropdownDivider.js +4 -3
- package/src/components/dropdown/DropdownGroup.js +19 -19
- package/src/components/dropdown/DropdownItem.js +24 -18
- package/src/components/dropdown/helpers.js +52 -0
- package/src/components/form/FormControl.js +207 -108
- package/src/components/form/field/Field.js +106 -174
- package/src/components/form/field/FieldCollection.js +110 -203
- package/src/components/form/field/types/AutocompleteField.js +26 -5
- package/src/components/form/field/types/CheckboxField.js +4 -4
- package/src/components/form/field/types/CheckboxGroupField.js +11 -5
- package/src/components/form/field/types/ColorField.js +4 -4
- package/src/components/form/field/types/DateField.js +110 -18
- package/src/components/form/field/types/EmailField.js +2 -2
- package/src/components/form/field/types/FileField.js +87 -21
- package/src/components/form/field/types/HiddenField.js +4 -4
- package/src/components/form/field/types/ImageField.js +4 -4
- package/src/components/form/field/types/NumberField.js +5 -5
- package/src/components/form/field/types/PasswordField.js +28 -6
- package/src/components/form/field/types/RadioField.js +12 -8
- package/src/components/form/field/types/RangeField.js +29 -5
- package/src/components/form/field/types/SearchField.js +4 -4
- package/src/components/form/field/types/SelectField.js +75 -8
- package/src/components/form/field/types/StringField.js +4 -4
- package/src/components/form/field/types/TelField.js +4 -4
- package/src/components/form/field/types/TextAreaField.js +7 -5
- package/src/components/form/field/types/TimeField.js +52 -6
- package/src/components/form/field/types/UrlField.js +4 -5
- package/src/components/form/field/types/file-field-mode/FileAvatarMode.js +104 -0
- package/src/components/form/field/types/file-field-mode/FileDropzoneMode.js +59 -0
- package/src/components/form/field/types/file-field-mode/FileItemPreview.js +74 -0
- package/src/components/form/field/types/file-field-mode/FileNativeMode.js +21 -0
- package/src/components/form/field/types/file-field-mode/FileUploadButtonMode.js +59 -0
- package/src/components/form/field/types/file-field-mode/FileWallMode.js +53 -0
- package/src/components/form/index.js +14 -2
- package/src/components/form/validation/Validation.js +9 -0
- package/src/components/list/List.js +1 -1
- package/src/components/list/ListGroup.js +1 -1
- package/src/components/menu/HasMenuItem.js +133 -0
- package/src/components/menu/Menu.js +47 -56
- package/src/components/menu/MenuGroup.js +36 -8
- package/src/components/menu/MenuItem.js +24 -10
- package/src/components/menu/MenuLink.js +2 -0
- package/src/components/modal/Modal.js +153 -23
- package/src/components/pagination/Pagination.js +55 -21
- package/src/components/popover/Popover.js +127 -40
- package/src/components/progress/Progress.js +14 -24
- package/src/components/skeleton/Skeleton.js +36 -13
- package/src/components/slider/Slider.js +96 -70
- package/src/components/spinner/Spinner.js +4 -2
- package/src/components/splitter/Splitter.js +15 -8
- package/src/components/splitter/SplitterGutter.js +28 -7
- package/src/components/splitter/SplitterPanel.js +9 -15
- package/src/components/splitter/index.js +3 -1
- package/src/components/stacks/AbsoluteStack.js +33 -0
- package/src/components/stacks/FixedStack.js +33 -0
- package/src/components/stacks/PositionStack.js +146 -0
- package/src/components/stacks/RelativeStack.js +33 -0
- package/src/components/{layouts → stacks}/Stack.js +22 -3
- package/src/components/{layouts → stacks}/index.js +6 -4
- package/src/components/stepper/Stepper.js +159 -67
- package/src/components/stepper/StepperStep.js +49 -12
- package/src/components/switch/Switch.js +59 -29
- package/src/components/switch/index.js +6 -0
- package/src/components/table/Column.js +22 -26
- package/src/components/table/ColumnGroup.js +4 -13
- package/src/components/table/DataTable.js +388 -103
- package/src/components/table/SimpleTable.js +28 -143
- package/src/components/tabs/Tabs.js +142 -44
- package/src/components/toast/Toast.js +40 -35
- package/src/components/tooltip/Tooltip.js +152 -35
- package/src/core/data/ObservableArray.js +94 -30
- package/src/core/data/ObservableChecker.js +20 -75
- package/src/core/data/ObservableItem.js +35 -3
- package/src/core/data/observable-helpers/computed.js +2 -1
- package/src/core/data/observable-helpers/object.js +13 -8
- package/src/core/data/observable-helpers/observable.is-to.js +196 -0
- package/src/core/elements/anchor/anchor.js +3 -2
- package/src/core/elements/control/for-each-array.js +44 -30
- package/src/core/elements/control/for-each.js +6 -3
- package/src/core/elements/control/show-if.js +11 -6
- package/src/core/elements/control/switch.js +2 -1
- package/src/core/elements/index.js +1 -1
- package/src/core/elements/svg.js +61 -0
- package/src/core/utils/HasEventEmitter.js +6 -0
- package/src/core/utils/debug-manager.js +2 -5
- package/src/core/utils/filters/standard.js +2 -1
- package/src/core/utils/property-accumulator.js +35 -6
- package/src/core/utils/shortcut-manager.js +242 -0
- package/src/core/utils/validator.js +1 -1
- package/src/core/wrappers/AttributesWrapper.js +41 -4
- package/src/core/wrappers/DocumentObserver.js +0 -1
- package/src/core/wrappers/HtmlElementWrapper.js +1 -1
- package/src/core/wrappers/NDElement.js +15 -2
- package/src/core/wrappers/SvgElementWrapper.js +15 -0
- package/src/core/wrappers/prototypes/attributes-extensions.js +4 -1
- package/src/core/wrappers/prototypes/nd-element-extensions.js +8 -1
- package/src/router/Router.js +0 -1
- package/src/ui/components/accordion/AccordionItemRender.js +63 -0
- package/src/ui/components/accordion/AccordionRender.js +34 -0
- package/src/ui/components/accordion/accordion.css +121 -0
- package/src/ui/components/alert/AlertRender.js +80 -0
- package/src/ui/components/alert/alert.css +163 -0
- package/src/ui/components/avatar/avata-group/AvatarGroupRender.js +49 -0
- package/src/ui/components/avatar/avata-group/avatar-group.css +38 -0
- package/src/ui/components/avatar/avatar/AvatarRender.js +87 -0
- package/src/ui/components/avatar/avatar/avatar.css +189 -0
- package/src/ui/components/badge/BadgeRender.js +24 -0
- package/src/ui/components/badge/badge.css +168 -0
- package/src/ui/components/breadcrumb/BreadcrumbRender.js +43 -0
- package/src/ui/components/breadcrumb/breadcrumb.css +55 -0
- package/src/ui/components/button/ButtonRender.js +65 -0
- package/src/ui/components/button/button.css +288 -354
- package/src/ui/components/contextmenu/ContextmenuRender.js +70 -0
- package/src/ui/components/contextmenu/contextmenu.css +36 -0
- package/src/ui/components/divider/DividerRender.js +70 -0
- package/src/ui/components/divider/divider.css +70 -0
- package/src/ui/components/dropdown/DropdownRender.js +92 -0
- package/src/ui/components/dropdown/divider/DropdownDividerRender.js +9 -0
- package/src/ui/components/dropdown/divider/dropdown-divider.css +0 -0
- package/src/ui/components/dropdown/dropdown.css +179 -0
- package/src/ui/components/dropdown/group/DropdownGroupRender.js +23 -0
- package/src/ui/components/dropdown/group/dropdown-group.css +0 -0
- package/src/ui/components/dropdown/item/DropdownItemRender.js +29 -0
- package/src/ui/components/dropdown/item/dropdown-item.css +0 -0
- package/src/ui/components/form/FieldCollectionRender.js +110 -0
- package/src/ui/components/form/FormControlRender.js +84 -0
- package/src/ui/components/form/field-collection.css +55 -0
- package/src/ui/components/form/fields/AutocompleteFieldRender.js +143 -0
- package/src/ui/components/form/fields/CheckboxFieldRender.js +59 -0
- package/src/ui/components/form/fields/CheckboxGroupFieldRender.js +92 -0
- package/src/ui/components/form/fields/ColorFieldRender.js +30 -0
- package/src/ui/components/form/fields/DateFieldRender.js +154 -0
- package/src/ui/components/form/fields/EmailFieldRender.js +5 -0
- package/src/ui/components/form/fields/FieldRender.js +117 -0
- package/src/ui/components/form/fields/FileFieldRender.js +41 -0
- package/src/ui/components/form/fields/HiddenFieldRender.js +14 -0
- package/src/ui/components/form/fields/ImageFieldRender.js +0 -0
- package/src/ui/components/form/fields/NumberFieldRender.js +52 -0
- package/src/ui/components/form/fields/PasswordFieldRender.js +65 -0
- package/src/ui/components/form/fields/RadioFieldRender.js +77 -0
- package/src/ui/components/form/fields/RangeFieldRender.js +121 -0
- package/src/ui/components/form/fields/SelectFieldRender.js +248 -0
- package/src/ui/components/form/fields/SliderFieldRender.js +359 -0
- package/src/ui/components/form/fields/StringFieldRender.js +6 -0
- package/src/ui/components/form/fields/TelFieldRender.js +6 -0
- package/src/ui/components/form/fields/TextAreaFieldRender.js +96 -0
- package/src/ui/components/form/fields/TimeFieldRender.js +141 -0
- package/src/ui/components/form/fields/UrlFieldRender.js +6 -0
- package/src/ui/components/form/fields/date-field.css +32 -0
- package/src/ui/components/form/fields/field.css +402 -0
- package/src/ui/components/form/fields/file-field.css +79 -0
- package/src/ui/components/form/fields/password-field.css +50 -0
- package/src/ui/components/form/fields/range-field.css +120 -0
- package/src/ui/components/form/fields/slider.css +195 -0
- package/src/ui/components/form/file-upload-mode/FileAvatarModeRender.js +143 -0
- package/src/ui/components/form/file-upload-mode/FileDropzoneModeRender.js +108 -0
- package/src/ui/components/form/file-upload-mode/FileNativeModeRender.js +22 -0
- package/src/ui/components/form/file-upload-mode/FileUploadButtonModeRender.js +89 -0
- package/src/ui/components/form/file-upload-mode/FileWallModeRender.js +91 -0
- package/src/ui/components/form/file-upload-mode/file-avatar-mode.css +139 -0
- package/src/ui/components/form/file-upload-mode/file-dropzone-mode.css +88 -0
- package/src/ui/components/form/file-upload-mode/file-upload-button-mode.css +44 -0
- package/src/ui/components/form/file-upload-mode/file-wall-mode.css +88 -0
- package/src/ui/components/form/form-control.css +40 -0
- package/src/ui/components/form/helpers.js +112 -0
- package/src/ui/components/form/index.js +61 -0
- package/src/ui/components/menu/MenuDividerRender.js +12 -0
- package/src/ui/components/menu/MenuGroupRender.js +60 -0
- package/src/ui/components/menu/MenuItemRender.js +57 -0
- package/src/ui/components/menu/MenuLinkRender.js +55 -0
- package/src/ui/components/menu/MenuRender.js +21 -0
- package/src/ui/components/menu/helpers.js +121 -0
- package/src/ui/components/menu/menu.css +308 -0
- package/src/ui/components/modal/ModalRender.js +119 -0
- package/src/ui/components/modal/modal.css +156 -0
- package/src/ui/components/pagination/PaginationRender.js +112 -0
- package/src/ui/components/pagination/pagination.css +63 -0
- package/src/ui/components/popover/PopoverRender.js +234 -0
- package/src/ui/components/popover/popover.css +139 -0
- package/src/ui/components/progress/ProgressRender.js +168 -0
- package/src/ui/components/progress/progress.css +197 -0
- package/src/ui/components/skeleton/SkeletonRender.js +79 -0
- package/src/ui/components/skeleton/skeleton.css +154 -0
- package/src/ui/components/spinner/SpinnerRender.js +46 -0
- package/src/ui/components/spinner/spinner.css +152 -0
- package/src/ui/components/splitter/SplitterGutterRender.js +94 -0
- package/src/ui/components/splitter/SplitterPanelRender.js +38 -0
- package/src/ui/components/splitter/SplitterRender.js +74 -0
- package/src/ui/components/splitter/splitter.css +128 -0
- package/src/ui/components/stacks/PositionStackRender.js +38 -0
- package/src/ui/components/stacks/StackRender.js +42 -0
- package/src/ui/components/stacks/absolute-stack/AbsoluteStackRender.js +5 -0
- package/src/ui/components/stacks/fixed-stack/FixedStackRender.js +5 -0
- package/src/ui/components/stacks/h-stack/HStackRender.js +7 -0
- package/src/ui/components/stacks/h-stack/h-stack.css +4 -0
- package/src/ui/components/stacks/index.js +15 -0
- package/src/ui/components/stacks/position-stack.css +62 -0
- package/src/ui/components/stacks/relative-stack/RelativeStackRender.js +7 -0
- package/src/ui/components/stacks/relative-stack/relative-stack.css +3 -0
- package/src/ui/components/stacks/stack.css +78 -0
- package/src/ui/components/stacks/v-stack/VStackRender.js +5 -0
- package/src/ui/components/stacks/v-stack/v-stack.css +4 -0
- package/src/ui/components/stepper/StepperRender.js +70 -0
- package/src/ui/components/stepper/StepperStepRender.js +67 -0
- package/src/ui/components/stepper/stepper.css +359 -0
- package/src/ui/components/switch/SwitchRender.js +82 -0
- package/src/ui/components/switch/switch.css +143 -0
- package/src/ui/components/table/data-table/DataTableRender.js +49 -0
- package/src/ui/components/table/data-table/bulk-actions.js +35 -0
- package/src/ui/components/table/data-table/data-table.css +246 -0
- package/src/ui/components/table/data-table/pagination.js +56 -0
- package/src/ui/components/table/data-table/tables.js +363 -0
- package/src/ui/components/table/data-table/toolbar.js +67 -0
- package/src/ui/components/table/simple-table/SimpleTableRender.js +188 -0
- package/src/ui/components/table/simple-table/simple-table.css +50 -0
- package/src/ui/components/tabs/TabsRender.js +226 -0
- package/src/ui/components/tabs/tabs.css +253 -0
- package/src/ui/components/toast/ToastRender.js +98 -0
- package/src/ui/components/toast/toast.css +201 -0
- package/src/ui/components/tooltip/TooltipRender.js +8 -0
- package/src/ui/components/tooltip/tooltip.css +113 -0
- package/src/ui/index.js +82 -0
- package/src/ui/tokens/colors-dark.scss +2 -1
- package/src/ui/tokens/reset.scss +3 -0
- package/types/control-flow.d.ts +2 -2
- package/src/components/layouts/ZStack.js +0 -41
- package/src/ui/components/button/button.render.js +0 -63
- /package/src/components/{layouts → stacks}/HStack.js +0 -0
- /package/src/components/{layouts → stacks}/VStack.js +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* Shared file field styles */
|
|
2
|
+
.field-file-input {
|
|
3
|
+
display: none;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.file-item-remove {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
width: 18px;
|
|
11
|
+
height: 18px;
|
|
12
|
+
border-radius: 50%;
|
|
13
|
+
background: var(--color-danger);
|
|
14
|
+
color: white;
|
|
15
|
+
font-size: 10px;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
transition: opacity 0.15s ease;
|
|
19
|
+
|
|
20
|
+
&:hover {
|
|
21
|
+
opacity: 0.8;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.file-item-info {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
gap: 2px;
|
|
29
|
+
flex: 1;
|
|
30
|
+
min-width: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.file-item-name {
|
|
34
|
+
font-size: var(--description-size);
|
|
35
|
+
color: var(--text-color);
|
|
36
|
+
font-weight: 500;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
text-overflow: ellipsis;
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.file-item-size {
|
|
43
|
+
font-size: var(--note-size);
|
|
44
|
+
color: var(--gray);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.file-item-icon {
|
|
48
|
+
font-size: 20px;
|
|
49
|
+
flex-shrink: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.file-item-progress {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
gap: var(--space-cozy);
|
|
56
|
+
flex: 1;
|
|
57
|
+
max-width: 120px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.file-item-progress-track {
|
|
61
|
+
flex: 1;
|
|
62
|
+
height: 4px;
|
|
63
|
+
background: var(--gray-lite-4);
|
|
64
|
+
border-radius: 2px;
|
|
65
|
+
overflow: hidden;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.file-item-progress-bar {
|
|
69
|
+
height: 100%;
|
|
70
|
+
background: var(--color-primary);
|
|
71
|
+
border-radius: 2px;
|
|
72
|
+
transition: width 0.2s ease;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.file-item-progress-label {
|
|
76
|
+
font-size: var(--note-size);
|
|
77
|
+
color: var(--gray);
|
|
78
|
+
flex-shrink: 0;
|
|
79
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
.field-visibility-toggle {
|
|
2
|
+
background: none;
|
|
3
|
+
border: none;
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
padding: 0 var(--space-cozy);
|
|
6
|
+
color: var(--gray);
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
transition: color 0.15s ease;
|
|
10
|
+
|
|
11
|
+
&:hover {
|
|
12
|
+
color: var(--text-color);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.field-strength-meter {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: var(--space-cozy);
|
|
20
|
+
margin-top: var(--space-tiny);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.field-strength-track {
|
|
24
|
+
flex: 1;
|
|
25
|
+
height: 4px;
|
|
26
|
+
background: var(--gray-lite-4);
|
|
27
|
+
border-radius: 2px;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.field-strength-bar {
|
|
32
|
+
display: block;
|
|
33
|
+
height: 100%;
|
|
34
|
+
border-radius: 2px;
|
|
35
|
+
transition: width 0.3s ease, background 0.3s ease;
|
|
36
|
+
|
|
37
|
+
&.is-score-0 { background: transparent; }
|
|
38
|
+
&.is-score-1 { background: var(--color-danger); }
|
|
39
|
+
&.is-score-2 { background: var(--color-warning); }
|
|
40
|
+
&.is-score-3 { background: var(--color-info); }
|
|
41
|
+
&.is-score-4 { background: var(--color-success); }
|
|
42
|
+
&.is-score-5 { background: var(--color-success); }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.field-strength-label {
|
|
46
|
+
font-size: var(--note-size);
|
|
47
|
+
color: var(--gray);
|
|
48
|
+
min-width: 60px;
|
|
49
|
+
text-align: right;
|
|
50
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
.is-range-field {
|
|
2
|
+
&.is-vertical {
|
|
3
|
+
.range-field-wrapper {
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.range-field-input {
|
|
9
|
+
writing-mode: vertical-lr;
|
|
10
|
+
direction: rtl;
|
|
11
|
+
width: auto;
|
|
12
|
+
height: 160px;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.range-field-wrapper {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: var(--space-comfortable);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.range-field-input {
|
|
24
|
+
flex: 1;
|
|
25
|
+
height: 4px;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
accent-color: var(--color-primary);
|
|
28
|
+
|
|
29
|
+
&::-webkit-slider-runnable-track {
|
|
30
|
+
height: 4px;
|
|
31
|
+
border-radius: 2px;
|
|
32
|
+
background: var(--gray-lite-4);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&::-webkit-slider-thumb {
|
|
36
|
+
-webkit-appearance: none;
|
|
37
|
+
width: 18px;
|
|
38
|
+
height: 18px;
|
|
39
|
+
border-radius: 50%;
|
|
40
|
+
background: var(--background);
|
|
41
|
+
border: 2px solid var(--color-primary);
|
|
42
|
+
margin-top: -7px;
|
|
43
|
+
cursor: grab;
|
|
44
|
+
transition: box-shadow 0.15s ease;
|
|
45
|
+
|
|
46
|
+
&:hover {
|
|
47
|
+
box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary) 15%, transparent);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&:active {
|
|
51
|
+
cursor: grabbing;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&::-moz-range-track {
|
|
56
|
+
height: 4px;
|
|
57
|
+
border-radius: 2px;
|
|
58
|
+
background: var(--gray-lite-4);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&::-moz-range-thumb {
|
|
62
|
+
width: 18px;
|
|
63
|
+
height: 18px;
|
|
64
|
+
border-radius: 50%;
|
|
65
|
+
background: var(--background);
|
|
66
|
+
border: 2px solid var(--color-primary);
|
|
67
|
+
cursor: grab;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&:focus-visible {
|
|
71
|
+
outline: none;
|
|
72
|
+
|
|
73
|
+
&::-webkit-slider-thumb {
|
|
74
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&:disabled {
|
|
79
|
+
opacity: 0.5;
|
|
80
|
+
cursor: not-allowed;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.range-field-value {
|
|
85
|
+
font-size: var(--description-size);
|
|
86
|
+
color: var(--gray);
|
|
87
|
+
min-width: 32px;
|
|
88
|
+
text-align: right;
|
|
89
|
+
flex-shrink: 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Marks */
|
|
93
|
+
.range-field-marks {
|
|
94
|
+
position: relative;
|
|
95
|
+
width: 100%;
|
|
96
|
+
height: 20px;
|
|
97
|
+
margin-top: var(--space-tiny);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.range-field-mark {
|
|
101
|
+
position: absolute;
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-direction: column;
|
|
104
|
+
align-items: center;
|
|
105
|
+
transform: translateX(-50%);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.range-field-mark-dot {
|
|
109
|
+
width: 6px;
|
|
110
|
+
height: 6px;
|
|
111
|
+
border-radius: 50%;
|
|
112
|
+
background: var(--gray-lite-3);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.range-field-mark-label {
|
|
116
|
+
font-size: var(--note-size);
|
|
117
|
+
color: var(--gray);
|
|
118
|
+
margin-top: 2px;
|
|
119
|
+
white-space: nowrap;
|
|
120
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--slider-track-height: 4px;
|
|
3
|
+
--slider-thumb-size: 18px;
|
|
4
|
+
--slider-thumb-offset: calc(var(--slider-thumb-size) / 2);
|
|
5
|
+
--slider-fill-color: var(--color-primary);
|
|
6
|
+
--slider-track-color: var(--gray-lite-4);
|
|
7
|
+
--slider-thumb-color: var(--background);
|
|
8
|
+
--slider-thumb-border: var(--slider-fill-color);
|
|
9
|
+
--slider-thumb-shadow: color-mix(in srgb, var(--slider-thumb-border) 15%, transparent);
|
|
10
|
+
--slider-vertical-height: 200px;
|
|
11
|
+
--slider-horizontal-width: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.slider {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: var(--space-cozy);
|
|
18
|
+
user-select: none;
|
|
19
|
+
width: var(--slider-horizontal-width);
|
|
20
|
+
|
|
21
|
+
&.is-vertical {
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
align-items: stretch;
|
|
24
|
+
width: fit-content;
|
|
25
|
+
height: var(--slider-vertical-height);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&.is-disabled {
|
|
29
|
+
opacity: 0.5;
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.is-readonly {
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Variants */
|
|
38
|
+
&.is-success { --slider-fill-color: var(--color-success); --slider-thumb-border: var(--color-success); --slider-thumb-shadow: color-mix(in srgb, var(--color-success) 15%, transparent); }
|
|
39
|
+
&.is-warning { --slider-fill-color: var(--color-warning); --slider-thumb-border: var(--color-warning); --slider-thumb-shadow: color-mix(in srgb, var(--color-warning) 15%, transparent); }
|
|
40
|
+
&.is-danger { --slider-fill-color: var(--color-danger); --slider-thumb-border: var(--color-danger); --slider-thumb-shadow: color-mix(in srgb, var(--color-danger) 15%, transparent); }
|
|
41
|
+
&.is-info { --slider-fill-color: var(--color-info); --slider-thumb-border: var(--color-info); --slider-thumb-shadow: color-mix(in srgb, var(--color-info) 15%, transparent); }
|
|
42
|
+
&.is-secondary{ --slider-fill-color: var(--gray); --slider-thumb-border: var(--gray); --slider-thumb-shadow: color-mix(in srgb, var(--gray) 15%, transparent); }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.slider-wrapper {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: var(--space-comfortable);
|
|
49
|
+
|
|
50
|
+
.is-vertical & {
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
align-items: center;
|
|
53
|
+
height: 100%;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.slider-inner {
|
|
58
|
+
position: relative;
|
|
59
|
+
flex: 1;
|
|
60
|
+
height: 20px;
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
|
|
65
|
+
.is-vertical & {
|
|
66
|
+
width: 20px;
|
|
67
|
+
height: 100%;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Track */
|
|
74
|
+
.slider-track {
|
|
75
|
+
position: absolute;
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: var(--slider-track-height);
|
|
78
|
+
background: var(--slider-track-color);
|
|
79
|
+
border-radius: calc(var(--slider-track-height) / 2);
|
|
80
|
+
|
|
81
|
+
.is-vertical & {
|
|
82
|
+
width: var(--slider-track-height);
|
|
83
|
+
height: 100%;
|
|
84
|
+
left: 50%;
|
|
85
|
+
transform: translateX(-50%);
|
|
86
|
+
top: 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.slider-fill {
|
|
91
|
+
position: absolute;
|
|
92
|
+
height: 100%;
|
|
93
|
+
background: var(--slider-fill-color);
|
|
94
|
+
border-radius: calc(var(--slider-track-height) / 2);
|
|
95
|
+
left: 0;
|
|
96
|
+
top: 0;
|
|
97
|
+
bottom: auto;
|
|
98
|
+
|
|
99
|
+
.is-vertical & {
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: auto;
|
|
102
|
+
left: 0;
|
|
103
|
+
top: auto;
|
|
104
|
+
bottom: 0;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* Thumb */
|
|
109
|
+
.slider-thumb {
|
|
110
|
+
position: absolute;
|
|
111
|
+
width: var(--slider-thumb-size);
|
|
112
|
+
height: var(--slider-thumb-size);
|
|
113
|
+
cursor: grab;
|
|
114
|
+
z-index: 2;
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
|
|
119
|
+
&:active {
|
|
120
|
+
cursor: grabbing;
|
|
121
|
+
z-index: 3;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&.is-start { z-index: 2; }
|
|
125
|
+
&.is-end { z-index: 2; }
|
|
126
|
+
|
|
127
|
+
&:active { z-index: 4; }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.slider-thumb-inner {
|
|
131
|
+
width: var(--slider-thumb-size);
|
|
132
|
+
height: var(--slider-thumb-size);
|
|
133
|
+
border-radius: 50%;
|
|
134
|
+
background: var(--slider-thumb-color);
|
|
135
|
+
border: 2px solid var(--slider-thumb-border);
|
|
136
|
+
transition: box-shadow 0.15s ease;
|
|
137
|
+
|
|
138
|
+
.slider-thumb:hover & {
|
|
139
|
+
box-shadow: 0 0 0 4px var(--slider-thumb-shadow);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/* Value */
|
|
144
|
+
.slider-value {
|
|
145
|
+
font-size: var(--description-size);
|
|
146
|
+
color: var(--gray);
|
|
147
|
+
min-width: 32px;
|
|
148
|
+
text-align: right;
|
|
149
|
+
flex-shrink: 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* Marks */
|
|
153
|
+
.slider-marks {
|
|
154
|
+
position: absolute;
|
|
155
|
+
inset: 0;
|
|
156
|
+
pointer-events: none;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.slider-mark {
|
|
160
|
+
position: absolute;
|
|
161
|
+
display: flex;
|
|
162
|
+
flex-direction: column;
|
|
163
|
+
align-items: center;
|
|
164
|
+
transform: translateX(-50%);
|
|
165
|
+
|
|
166
|
+
.is-vertical & {
|
|
167
|
+
flex-direction: row;
|
|
168
|
+
transform: translateY(50%);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.slider-mark-dot {
|
|
173
|
+
width: 6px;
|
|
174
|
+
height: 6px;
|
|
175
|
+
border-radius: 50%;
|
|
176
|
+
background: var(--gray-lite-3);
|
|
177
|
+
margin-top: 7px;
|
|
178
|
+
|
|
179
|
+
.is-vertical & {
|
|
180
|
+
margin-top: 0;
|
|
181
|
+
margin-left: 7px;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.slider-mark-label {
|
|
186
|
+
font-size: var(--note-size);
|
|
187
|
+
color: var(--gray);
|
|
188
|
+
margin-top: var(--space-tiny);
|
|
189
|
+
white-space: nowrap;
|
|
190
|
+
|
|
191
|
+
.is-vertical & {
|
|
192
|
+
margin-top: 0;
|
|
193
|
+
margin-left: var(--space-tiny);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {Div, Input, Span, Img, Button, ShowIf, Switch} from '../../../../../elements';
|
|
2
|
+
import { $ } from '../../../../../index';
|
|
3
|
+
|
|
4
|
+
import './file-avatar-mode.css';
|
|
5
|
+
|
|
6
|
+
export default function FileAvatarModeRender($desc, modeInstance) {
|
|
7
|
+
const {$files, fieldDesc, fieldInstance} = $desc.$context;
|
|
8
|
+
const $preview = $(null);
|
|
9
|
+
|
|
10
|
+
const input = buildInput(fieldDesc, fieldInstance, $files, $preview);
|
|
11
|
+
|
|
12
|
+
const variant = $desc.variant || 'hover-overlay';
|
|
13
|
+
|
|
14
|
+
const avatar = buildAvatar($desc, $preview);
|
|
15
|
+
|
|
16
|
+
fieldInstance.onReset(() => $preview.set(null));
|
|
17
|
+
|
|
18
|
+
if(variant === 'hover-overlay') {
|
|
19
|
+
return buildHoverOverlay($desc, avatar, input, $files, modeInstance);
|
|
20
|
+
}
|
|
21
|
+
if(variant === 'corner-badge') {
|
|
22
|
+
return buildCornerBadge($desc, avatar, input, $files, modeInstance);
|
|
23
|
+
}
|
|
24
|
+
if(variant === 'action-buttons') {
|
|
25
|
+
return buildActionButtons($desc, avatar, input, $files, modeInstance, fieldInstance);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return avatar;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const buildInput = (fieldDesc, fieldInstance, $files, $preview) => {
|
|
32
|
+
const input = Input({
|
|
33
|
+
class: 'field-file-input',
|
|
34
|
+
type: 'file',
|
|
35
|
+
name: fieldDesc.name,
|
|
36
|
+
id: fieldDesc.id || fieldDesc.name,
|
|
37
|
+
accept: fieldDesc.accept || 'image/*',
|
|
38
|
+
disabled: fieldDesc.disabled,
|
|
39
|
+
style: {display: 'none'},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
fieldInstance.$input = input;
|
|
43
|
+
|
|
44
|
+
input.nd.onChange((e) => {
|
|
45
|
+
const file = e.target.files?.[0];
|
|
46
|
+
if(!file) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fieldInstance.reset();
|
|
51
|
+
fieldInstance.addFile(file);
|
|
52
|
+
$preview.set(URL.createObjectURL(file));
|
|
53
|
+
|
|
54
|
+
input.value = '';
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return input;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const buildShapeClass = (defaultClass, $desc) => ({
|
|
62
|
+
[defaultClass]: true,
|
|
63
|
+
'is-circle': ($desc.shape || 'circle') === 'circle',
|
|
64
|
+
'is-square': ($desc.shape || 'circle') === 'square',
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const buildAvatar = ($desc, $preview) => {
|
|
68
|
+
const size = $desc.size || 100;
|
|
69
|
+
const shape = $desc.shape || 'circle';
|
|
70
|
+
const radius = shape === 'circle' ? '50%' : '12px';
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
const previewImg = () => Img($preview, {
|
|
74
|
+
class: 'file-avatar-img',
|
|
75
|
+
alt: 'Avatar',
|
|
76
|
+
});
|
|
77
|
+
const placeholder = () => Div({class: 'file-avatar-placeholder'}, [
|
|
78
|
+
Span({class: 'file-avatar-placeholder-icon'}, $desc.placeholderIcon),
|
|
79
|
+
])
|
|
80
|
+
|
|
81
|
+
return Div({
|
|
82
|
+
class: buildShapeClass('file-avatar', $desc),
|
|
83
|
+
style: { width: size + 'px', height: size + 'px' },
|
|
84
|
+
}, Switch($preview, previewImg, placeholder));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const buildHoverOverlay = ($desc, avatar, input, $files, modeInstance) => {
|
|
88
|
+
let overlay = null;
|
|
89
|
+
if($desc.renderOverlay) {
|
|
90
|
+
overlay = $desc.renderOverlay(avatar, $desc, modeInstance);
|
|
91
|
+
} else {
|
|
92
|
+
overlay = Div({class: 'file-avatar-overlay'}, [
|
|
93
|
+
Span({class: 'file-avatar-overlay-icon'}, $desc.overlayIcon || $desc.editImageIcon),
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const wrapper = Div({
|
|
98
|
+
class: buildShapeClass('file-avatar-wrapper is-hover-overlay', $desc),
|
|
99
|
+
}, [avatar, overlay]);
|
|
100
|
+
|
|
101
|
+
wrapper.nd.onClick(() => input.click());
|
|
102
|
+
|
|
103
|
+
return Div({}, [input, wrapper]);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const buildCornerBadge = ($desc, avatar, input) => {
|
|
107
|
+
const badge = Div({class: 'file-avatar-badge'}, $desc.editImageIcon);
|
|
108
|
+
badge.nd.onClick(() => input.click());
|
|
109
|
+
|
|
110
|
+
return Div({}, [
|
|
111
|
+
input,
|
|
112
|
+
Div({
|
|
113
|
+
class: buildShapeClass('file-avatar-wrapper is-corner-badge', $desc),
|
|
114
|
+
}, [avatar, badge]),
|
|
115
|
+
]);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const buildActionButtons = ($desc, avatar, input, $files, modeInstance, fieldInstance) => {
|
|
119
|
+
if($desc.renderActions) {
|
|
120
|
+
return $desc.renderActions($desc, avatar, () => input.click(), () => removeAvatar($files, modeInstance, fieldInstance), modeInstance);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const changeBtn = Button({class: 'file-avatar-btn is-change'}, $desc.changeLabel);
|
|
124
|
+
changeBtn.nd.onClick(() => input.click());
|
|
125
|
+
|
|
126
|
+
const removeBtn = Button({class: 'file-avatar-btn is-remove'}, $desc.removeLabel);
|
|
127
|
+
removeBtn.nd.onClick(() => removeAvatar($files, modeInstance, fieldInstance));
|
|
128
|
+
|
|
129
|
+
return Div({class: 'file-avatar-action-wrapper'}, [
|
|
130
|
+
input,
|
|
131
|
+
avatar,
|
|
132
|
+
Div({class: 'file-avatar-actions'}, [changeBtn, removeBtn]),
|
|
133
|
+
]);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const removeAvatar = ($files, modeInstance, fieldInstance) => {
|
|
137
|
+
const item = $files.val()?.[0];
|
|
138
|
+
fieldInstance.reset();
|
|
139
|
+
if(item) {
|
|
140
|
+
modeInstance.emit('remove', item);
|
|
141
|
+
item.emit('remove', item);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {Div, Input, Img, Span, ForEachArray, ShowIf} from '../../../../../elements';
|
|
2
|
+
import { $ } from '../../../../../index';
|
|
3
|
+
import {buildProgress, formatSize, getFileThumbnail} from '../helpers';
|
|
4
|
+
|
|
5
|
+
import './file-dropzone-mode.css';
|
|
6
|
+
|
|
7
|
+
export default function FileDropzoneModeRender($desc, modeInstance) {
|
|
8
|
+
const { $files, fieldDesc, fieldInstance } = $desc.$context;
|
|
9
|
+
|
|
10
|
+
const input = buildInput(fieldDesc, fieldInstance, $files);
|
|
11
|
+
const zone = buildZone($desc, input, $files, fieldDesc, modeInstance, fieldInstance);
|
|
12
|
+
|
|
13
|
+
return Div({class: 'file-dropzone-wrapper'}, [zone, buildList($desc, $files, modeInstance, fieldInstance)]);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const buildInput = (fieldDesc, fieldInstance) => {
|
|
17
|
+
const input = Input({
|
|
18
|
+
class: 'field-file-input',
|
|
19
|
+
type: 'file',
|
|
20
|
+
name: fieldDesc.name,
|
|
21
|
+
id: fieldDesc.id || fieldDesc.name,
|
|
22
|
+
accept: fieldDesc.accept || null,
|
|
23
|
+
multiple: fieldDesc.multiple,
|
|
24
|
+
disabled: fieldDesc.disabled,
|
|
25
|
+
style: { display: 'none' },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
fieldInstance.$input = input;
|
|
29
|
+
|
|
30
|
+
input.nd.onChange((e) => {
|
|
31
|
+
const files = Array.from(e.target.files || []);
|
|
32
|
+
fieldInstance.addFiles(files);
|
|
33
|
+
input.value = '';
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return input;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const buildZone = ($desc, input, $files, fieldDesc, modeInstance, fieldInstance) => {
|
|
40
|
+
if($desc.renderZone) {
|
|
41
|
+
return $desc.renderZone($desc, modeInstance);
|
|
42
|
+
}
|
|
43
|
+
const $isDragOver = $(false);
|
|
44
|
+
const zone = Div({
|
|
45
|
+
class: { 'file-dropzone': true, 'is-drag-over': $isDragOver, 'is-disabled': fieldDesc.disabled },
|
|
46
|
+
style: $desc.height ? { minHeight: $desc.height + 'px' } : {},
|
|
47
|
+
}, [
|
|
48
|
+
input,
|
|
49
|
+
Div({class: 'file-dropzone-content'}, [
|
|
50
|
+
Span({class: 'file-dropzone-icon'}, $desc.icon),
|
|
51
|
+
Span({class: 'file-dropzone-text'}, $desc.text),
|
|
52
|
+
ShowIf($desc.hint, () => Span({class: 'file-dropzone-hint'}, $desc.hint)),
|
|
53
|
+
]),
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
zone.nd.onClick(() => input.click());
|
|
57
|
+
|
|
58
|
+
zone.nd
|
|
59
|
+
.onDragOver((e) => {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
$isDragOver.set(true);
|
|
62
|
+
})
|
|
63
|
+
.onDragLeave(() => $isDragOver.set(false))
|
|
64
|
+
.onDrop((e) => {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
$isDragOver.set(false);
|
|
67
|
+
|
|
68
|
+
const files = Array.from(e.dataTransfer.files || []);
|
|
69
|
+
fieldInstance.addFiles(files);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return zone;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const buildList = ($desc, $files, modeInstance, fieldInstance) => {
|
|
76
|
+
const builder = $desc.renderItem
|
|
77
|
+
? (item) => $desc.renderItem(item, () => removeItem(item, $files, modeInstance, fieldInstance))
|
|
78
|
+
: (item) => buildItem(item, $files, $desc, modeInstance, fieldInstance);
|
|
79
|
+
|
|
80
|
+
return ShowIf($files.is(f => f.length > 0),
|
|
81
|
+
() => Div({class: 'file-dropzone-list'},
|
|
82
|
+
ForEachArray($files, builder)
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const buildItem = (item, $files, $desc, modeInstance, fieldInstance) => {
|
|
88
|
+
const file = item.file();
|
|
89
|
+
|
|
90
|
+
const removeBtn = Span({class: 'file-item-remove'}, $desc.removeIcon || '×');
|
|
91
|
+
removeBtn.nd.onStopClick(() => removeItem(item, $files, modeInstance, fieldInstance));
|
|
92
|
+
|
|
93
|
+
return Div({class: 'file-dropzone-item'}, [
|
|
94
|
+
Div({class: 'file-item-thumbnail'}, getFileThumbnail(file, fieldInstance)),
|
|
95
|
+
Div({class: 'file-item-info'}, [
|
|
96
|
+
Span({class: 'file-item-name'}, file.name),
|
|
97
|
+
Span({class: 'file-item-size'}, formatSize(file.size)),
|
|
98
|
+
buildProgress(item),
|
|
99
|
+
]),
|
|
100
|
+
removeBtn,
|
|
101
|
+
]);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const removeItem = (item, $files, modeInstance, fieldInstance) => {
|
|
105
|
+
fieldInstance.removeFile(item);
|
|
106
|
+
modeInstance.emit('remove', item);
|
|
107
|
+
item.emit('remove', item);
|
|
108
|
+
};
|