@ticatec/uniface-element 5.0.4 → 5.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/README.md +14 -13
- package/README_CN.md +17 -15
- package/dist/app_layout/ColumnsLayout.svelte +14 -10
- package/dist/app_layout/ColumnsLayout.svelte.d.ts +8 -4
- package/dist/app_layout/README.md +14 -12
- package/dist/app_layout/README_CN.md +14 -12
- package/dist/app_layout/RowsLayout.svelte +14 -10
- package/dist/app_layout/RowsLayout.svelte.d.ts +8 -4
- package/dist/base-calendar/CalendarBase.svelte +4 -10
- package/dist/base-calendar/CalendarBase.svelte.d.ts +0 -4
- package/dist/base-calendar/DateContext.d.ts +1 -0
- package/dist/base-calendar/DateContext.js +5 -8
- package/dist/base-calendar/MonthlyCalendar.svelte +11 -3
- package/dist/base-calendar/MonthlyCalendar.svelte.d.ts +1 -2
- package/dist/base-calendar/YearPickupPanel.svelte +5 -5
- package/dist/base-calendar/YearPickupPanel.svelte.d.ts +2 -2
- package/dist/base-calendar/dateUtils.js +9 -5
- package/dist/composite/pagination_panel/PaginationPanel.svelte +19 -13
- package/dist/composite/pagination_panel/PaginationPanel.svelte.d.ts +8 -5
- package/dist/composite/pagination_panel/README.md +3 -1
- package/dist/composite/pagination_panel/README_CN.md +3 -1
- package/dist/composite/transfer/Transfer.svelte +30 -16
- package/dist/composite/transfer/Transfer.svelte.d.ts +11 -4
- package/dist/composite/transfer/index.d.ts +2 -2
- package/dist/data_display/accordion/Accordion.svelte +10 -9
- package/dist/data_display/accordion/Accordion.svelte.d.ts +2 -1
- package/dist/data_display/accordion/AccordionItemView.svelte +6 -6
- package/dist/data_display/accordion/AccordionItemView.svelte.d.ts +1 -1
- package/dist/data_display/accordion/README.md +6 -4
- package/dist/data_display/accordion/README_CN.md +6 -4
- package/dist/data_display/card/Card.svelte +13 -11
- package/dist/data_display/card/Card.svelte.d.ts +5 -3
- package/dist/data_display/card/CardAction.d.ts +7 -2
- package/dist/data_display/card/CommonCardActionBar.svelte +2 -2
- package/dist/data_display/card/README.md +11 -9
- package/dist/data_display/card/README_CN.md +11 -9
- package/dist/data_display/card/index.d.ts +2 -1
- package/dist/data_display/concise_data_table/Column.d.ts +0 -6
- package/dist/data_display/concise_data_table/ConciseListTable.svelte +6 -5
- package/dist/data_display/concise_data_table/ConciseListTable.svelte.d.ts +4 -3
- package/dist/data_display/concise_data_table/DataCell.svelte +1 -1
- package/dist/data_display/concise_data_table/README.md +7 -5
- package/dist/data_display/concise_data_table/README_CN.md +7 -5
- package/dist/data_display/concise_data_table/TableOptions.d.ts +1 -1
- package/dist/data_display/list_box/ListBox.svelte +11 -15
- package/dist/data_display/list_box/ListBox.svelte.d.ts +6 -9
- package/dist/data_display/list_box/README.md +10 -8
- package/dist/data_display/list_box/README_CN.md +10 -8
- package/dist/data_display/list_box/index.d.ts +2 -3
- package/dist/data_display/tree_view/README.md +4 -2
- package/dist/data_display/tree_view/README_CN.md +4 -2
- package/dist/data_display/tree_view/TreeNodeView.svelte +15 -16
- package/dist/data_display/tree_view/TreeNodeView.svelte.d.ts +4 -5
- package/dist/data_display/tree_view/TreeView.svelte +27 -19
- package/dist/data_display/tree_view/TreeView.svelte.d.ts +12 -4
- package/dist/data_display/tree_view/index.d.ts +2 -3
- package/dist/data_table/DataTable.svelte +46 -15
- package/dist/data_table/DataTable.svelte.d.ts +9 -1
- package/dist/data_table/README.md +10 -8
- package/dist/data_table/README_CN.md +10 -8
- package/dist/data_table/UniDataTable.d.ts +4 -4
- package/dist/data_table/UniDataTable.js +2 -2
- package/dist/data_table/index.d.ts +5 -5
- package/dist/data_table/lib/CellAction.d.ts +9 -0
- package/dist/data_table/lib/CommonHeaderCell.d.ts +2 -2
- package/dist/data_table/lib/CompareFn.d.ts +3 -0
- package/dist/data_table/lib/DataColumn.d.ts +7 -12
- package/dist/data_table/lib/FormatCellFn.d.ts +2 -0
- package/dist/data_table/lib/HrefLink.d.ts +3 -3
- package/dist/data_table/lib/IndicatorColumn.d.ts +2 -1
- package/dist/data_table/lib/RowAction.d.ts +14 -20
- package/dist/data_table/lib/virtualWindow.d.ts +37 -0
- package/dist/data_table/lib/virtualWindow.js +41 -0
- package/dist/data_table/parts/ActionCell.svelte +3 -3
- package/dist/data_table/parts/ActionCell.svelte.d.ts +1 -1
- package/dist/data_table/parts/ActionsPanel.svelte +17 -2
- package/dist/data_table/parts/ActionsPanel.svelte.d.ts +3 -0
- package/dist/data_table/parts/ActionsRow.svelte +7 -5
- package/dist/data_table/parts/ContentPanel.svelte +40 -15
- package/dist/data_table/parts/ContentPanel.svelte.d.ts +11 -6
- package/dist/data_table/parts/FixedColumnsPanel.svelte +32 -16
- package/dist/data_table/parts/FixedColumnsPanel.svelte.d.ts +8 -5
- package/dist/data_table/parts/FixedHeaderPanel.svelte +14 -15
- package/dist/data_table/parts/FixedHeaderPanel.svelte.d.ts +4 -4
- package/dist/data_table/parts/FixedRow.svelte +9 -9
- package/dist/data_table/parts/FixedRow.svelte.d.ts +3 -3
- package/dist/data_table/parts/HrefCell.svelte +1 -1
- package/dist/data_table/parts/PopupMenu.svelte +3 -3
- package/dist/data_table/parts/PopupMenu.svelte.d.ts +1 -1
- package/dist/data_table/parts/TableHeaderPanel.svelte +14 -14
- package/dist/data_table/parts/TableHeaderPanel.svelte.d.ts +4 -4
- package/dist/data_table/parts/TextCell.svelte +1 -1
- package/dist/feedback/progress-bar/ProgressBar.svelte +13 -10
- package/dist/feedback/progress-bar/ProgressBar.svelte.d.ts +6 -3
- package/dist/form/FormEditor.svelte +2 -2
- package/dist/form/FormEditor.svelte.d.ts +1 -1
- package/dist/form/attachment_files/AttachmentEditor.svelte +407 -92
- package/dist/form/attachment_files/AttachmentEditor.svelte.d.ts +71 -15
- package/dist/form/attachment_files/AttachmentFile.d.ts +35 -8
- package/dist/form/attachment_files/AttachmentFile.js +54 -29
- package/dist/form/attachment_files/AttachmentListItem.svelte +208 -0
- package/dist/form/attachment_files/AttachmentListItem.svelte.d.ts +25 -0
- package/dist/form/attachment_files/AttachmentTile.svelte +296 -0
- package/dist/form/attachment_files/AttachmentTile.svelte.d.ts +25 -0
- package/dist/form/attachment_files/FileUpload.d.ts +2 -2
- package/dist/form/attachment_files/README.md +71 -452
- package/dist/form/attachment_files/README_CN.md +68 -449
- package/dist/form/attachment_files/UploadTask.d.ts +27 -0
- package/dist/form/attachment_files/index.d.ts +8 -5
- package/dist/form/attachment_files/index.js +4 -2
- package/dist/form/cascade_options_select/CascadeOptionSelect.svelte +16 -15
- package/dist/form/cascade_options_select/CascadeOptionSelect.svelte.d.ts +6 -5
- package/dist/form/cascade_options_select/IsLeaf.d.ts +4 -0
- package/dist/form/cascade_options_select/IsLeaf.js +1 -0
- package/dist/form/cascade_options_select/OptionsBox.svelte +4 -4
- package/dist/form/cascade_options_select/OptionsBox.svelte.d.ts +2 -2
- package/dist/form/color_picker/ColorPicker.svelte +3 -3
- package/dist/form/color_picker/ColorPickerPanel.svelte +1 -1
- package/dist/form/common_editor/BasePicker.svelte +7 -7
- package/dist/form/common_editor/BasePicker.svelte.d.ts +3 -3
- package/dist/form/common_editor/CommonEditor.svelte +8 -8
- package/dist/form/common_editor/CommonEditor.svelte.d.ts +2 -2
- package/dist/form/common_editor/CommonPicker.svelte +43 -31
- package/dist/form/common_editor/CommonPicker.svelte.d.ts +6 -6
- package/dist/form/common_editor/CommonPickerProps.d.ts +2 -2
- package/dist/form/common_editor/CommonPopupEditor.svelte +13 -13
- package/dist/form/common_editor/CommonPopupEditor.svelte.d.ts +3 -4
- package/dist/form/common_editor/NumberInput.svelte +10 -2
- package/dist/form/common_editor/NumberInput.svelte.d.ts +1 -1
- package/dist/form/common_range_editor/CommonRangeEditor.svelte +17 -17
- package/dist/form/common_range_editor/CommonRangeEditor.svelte.d.ts +5 -5
- package/dist/form/date_picker/DatePicker.svelte +5 -5
- package/dist/form/date_picker/DatePicker.svelte.d.ts +1 -1
- package/dist/form/date_picker/DateTimePicker.svelte +16 -6
- package/dist/form/date_picker/README.md +7 -5
- package/dist/form/date_picker/README_CN.md +7 -5
- package/dist/form/date_picker/ScrollBar.svelte +21 -20
- package/dist/form/date_picker/ScrollBar.svelte.d.ts +3 -3
- package/dist/form/date_range/DateRangeEditor.svelte +6 -6
- package/dist/form/events.d.ts +70 -0
- package/dist/form/events.js +6 -0
- package/dist/form/group_box/group-check-box/GroupCheckBox.svelte +9 -7
- package/dist/form/group_box/group-check-box/GroupCheckBox.svelte.d.ts +4 -3
- package/dist/form/group_box/group-check-box/README.md +5 -3
- package/dist/form/group_box/group-check-box/README_CN.md +5 -3
- package/dist/form/group_box/group-radio-box/GroupRadioBox.svelte +9 -7
- package/dist/form/group_box/group-radio-box/GroupRadioBox.svelte.d.ts +4 -3
- package/dist/form/group_box/group-radio-box/README.md +3 -1
- package/dist/form/group_box/group-radio-box/README_CN.md +3 -1
- package/dist/form/image_editor/ImageEditor.svelte +118 -0
- package/dist/form/image_editor/ImageEditor.svelte.d.ts +52 -0
- package/dist/form/image_editor/ImageFile.d.ts +11 -0
- package/dist/form/image_editor/ImageFile.js +1 -0
- package/dist/form/{image-files → image_editor}/ImagePreview.svelte +10 -2
- package/dist/form/image_editor/README.md +89 -0
- package/dist/form/image_editor/README_CN.md +89 -0
- package/dist/form/image_editor/index.d.ts +11 -0
- package/dist/form/image_editor/index.js +4 -0
- package/dist/form/input_options_select/InputOptionsSelect.svelte +11 -8
- package/dist/form/input_options_select/InputOptionsSelect.svelte.d.ts +2 -1
- package/dist/form/input_options_select/README.md +44 -218
- package/dist/form/input_options_select/README_CN.md +38 -211
- package/dist/form/lookup_editor/LookupEditor.svelte +7 -10
- package/dist/form/lookup_editor/LookupEditor.svelte.d.ts +2 -1
- package/dist/form/memo_editor/MemoEditor.svelte +2 -2
- package/dist/form/memo_editor/MemoEditor.svelte.d.ts +1 -1
- package/dist/form/number_editor/NumberEditor.svelte +13 -1
- package/dist/form/number_editor/NumberEditor.svelte.d.ts +1 -1
- package/dist/form/number_range/NumberRange.svelte +5 -5
- package/dist/form/options_multi_select/OptionsMultiSelect.svelte +13 -13
- package/dist/form/options_multi_select/OptionsMultiSelect.svelte.d.ts +3 -2
- package/dist/form/options_multi_select/README.md +5 -3
- package/dist/form/options_multi_select/README_CN.md +5 -3
- package/dist/form/options_select/OptionsSelect.svelte +19 -15
- package/dist/form/options_select/OptionsSelect.svelte.d.ts +2 -1
- package/dist/form/options_select/README.md +9 -7
- package/dist/form/options_select/README_CN.md +8 -6
- package/dist/form/prompts_text_editor/PromptsTextEditor.svelte +6 -5
- package/dist/form/prompts_text_editor/PromptsTextEditor.svelte.d.ts +2 -1
- package/dist/form/prompts_text_editor/README.md +16 -14
- package/dist/form/prompts_text_editor/README_CN.md +16 -14
- package/dist/form/search_box/SearchBox.svelte +3 -2
- package/dist/form/search_box/SearchBox.svelte.d.ts +1 -1
- package/dist/form/switch/README.md +7 -5
- package/dist/form/switch/README_CN.md +7 -5
- package/dist/form/switch/Switch.svelte +7 -5
- package/dist/form/switch/Switch.svelte.d.ts +4 -2
- package/dist/form/text_editor/PasswordEditor.svelte +2 -2
- package/dist/form/text_editor/PasswordEditor.svelte.d.ts +1 -1
- package/dist/form/text_editor/TextEditor.svelte +6 -4
- package/dist/form/text_editor/TextEditor.svelte.d.ts +1 -1
- package/dist/form/time_editor/README.md +4 -2
- package/dist/form/time_editor/README_CN.md +4 -2
- package/dist/form/time_editor/TimeEditor.svelte +10 -7
- package/dist/form/time_editor/TimeEditor.svelte.d.ts +2 -1
- package/dist/form/types.d.ts +5 -42
- package/dist/form/unit-number-editor/README.md +21 -19
- package/dist/form/unit-number-editor/README_CN.md +21 -19
- package/dist/form/unit-number-editor/UnitNumberEditor.svelte +12 -11
- package/dist/form/unit-number-editor/UnitNumberEditor.svelte.d.ts +4 -3
- package/dist/general/button/Button.svelte +4 -1
- package/dist/general/button/Button.svelte.d.ts +3 -1
- package/dist/general/button/IconButton.svelte +11 -5
- package/dist/general/button/IconButton.svelte.d.ts +5 -2
- package/dist/general/button/IconButton_README.md +9 -6
- package/dist/general/button/IconButton_README_CN.md +9 -6
- package/dist/general/button/TextButton.svelte +15 -5
- package/dist/general/button/TextButton.svelte.d.ts +6 -2
- package/dist/general/button/TextButton_README.md +10 -6
- package/dist/general/button/TextButton_README_CN.md +10 -6
- package/dist/general/icon/Icon.svelte +6 -4
- package/dist/general/icon/Icon.svelte.d.ts +3 -2
- package/dist/general/tag/Tag.svelte +8 -4
- package/dist/general/tag/Tag.svelte.d.ts +3 -1
- package/dist/i18nRes/i18nRes.d.ts +45 -2
- package/dist/i18nRes/i18nRes.js +7 -2
- package/dist/layouts/action_bar/ActionBar.svelte +5 -4
- package/dist/layouts/action_bar/ActionBar.svelte.d.ts +2 -1
- package/dist/layouts/action_bar/ButtonAction.d.ts +1 -23
- package/dist/layouts/action_bar/README.md +20 -18
- package/dist/layouts/action_bar/README_CN.md +19 -17
- package/dist/layouts/box/Box.svelte +4 -3
- package/dist/layouts/box/Box.svelte.d.ts +2 -1
- package/dist/layouts/box/README.md +13 -11
- package/dist/layouts/box/README_CN.md +13 -11
- package/dist/layouts/form_field/FormField.svelte +5 -4
- package/dist/layouts/form_field/FormField.svelte.d.ts +3 -2
- package/dist/layouts/form_field/README.md +11 -9
- package/dist/layouts/form_field/README_CN.md +9 -7
- package/dist/layouts/form_panel/flex_row_form/Cell.svelte +3 -1
- package/dist/layouts/form_panel/flex_row_form/Cell.svelte.d.ts +3 -1
- package/dist/layouts/form_panel/flex_row_form/Row.svelte +3 -1
- package/dist/layouts/form_panel/flex_row_form/Row.svelte.d.ts +3 -1
- package/dist/layouts/form_panel/grid_form/GridField.svelte +8 -4
- package/dist/layouts/form_panel/grid_form/GridField.svelte.d.ts +6 -2
- package/dist/layouts/form_panel/grid_form/GridForm.svelte +3 -1
- package/dist/layouts/form_panel/grid_form/GridForm.svelte.d.ts +3 -1
- package/dist/layouts/form_panel/grid_form/README.md +6 -4
- package/dist/layouts/form_panel/grid_form/README_CN.md +6 -4
- package/dist/layouts/page/Page.svelte +7 -7
- package/dist/layouts/page/Page.svelte.d.ts +2 -2
- package/dist/layouts/page/PageHeader.svelte +4 -4
- package/dist/layouts/page/PageHeader.svelte.d.ts +1 -1
- package/dist/layouts/page/README.md +18 -18
- package/dist/layouts/page/README_CN.md +18 -18
- package/dist/navigation/nav_menu/MenuItem.d.ts +1 -1
- package/dist/navigation/nav_menu/NavigatorMenu.svelte +16 -14
- package/dist/navigation/nav_menu/NavigatorMenu.svelte.d.ts +7 -5
- package/dist/navigation/nav_menu/NavigatorMenuItem.svelte +2 -2
- package/dist/navigation/nav_menu/NavigatorMenuItem.svelte.d.ts +2 -2
- package/dist/navigation/nav_menu/README.md +8 -6
- package/dist/navigation/nav_menu/README_CN.md +8 -6
- package/dist/navigation/nav_menu/index.d.ts +2 -2
- package/dist/navigation/navigator/Navigator.svelte +5 -4
- package/dist/navigation/navigator/Navigator.svelte.d.ts +3 -2
- package/dist/navigation/navigator/README.md +12 -10
- package/dist/navigation/navigator/README_CN.md +12 -10
- package/dist/navigation/pagination/Pagination.svelte +23 -15
- package/dist/navigation/pagination/Pagination.svelte.d.ts +6 -4
- package/dist/navigation/progress_step_bar/ProgressStep.d.ts +2 -1
- package/dist/navigation/progress_step_bar/ProgressStepBar.svelte +5 -4
- package/dist/navigation/progress_step_bar/ProgressStepBar.svelte.d.ts +2 -1
- package/dist/navigation/progress_step_bar/ProgressStepBlock.svelte +3 -3
- package/dist/navigation/progress_step_bar/ProgressStepBlock.svelte.d.ts +1 -1
- package/dist/navigation/progress_step_bar/README.md +37 -35
- package/dist/navigation/progress_step_bar/README_CN.md +36 -34
- package/dist/navigation/tabs/Tabs.svelte +14 -5
- package/dist/navigation/tabs/Tabs.svelte.d.ts +11 -4
- package/dist/navigation/tabs/index.d.ts +2 -2
- package/dist/overlay/common/ModalPopover.svelte +5 -4
- package/dist/overlay/common/ModalPopover.svelte.d.ts +2 -1
- package/dist/overlay/common/Popover.svelte +4 -3
- package/dist/overlay/common/Popover.svelte.d.ts +2 -1
- package/dist/overlay/context-menu/ContextMenuItem.d.ts +3 -3
- package/dist/overlay/context-menu/ContextMenuPanel.svelte +4 -4
- package/dist/overlay/context-menu/index.d.ts +2 -2
- package/dist/overlay/dialog/CommonDialog.svelte +17 -13
- package/dist/overlay/dialog/CommonDialog.svelte.d.ts +9 -5
- package/dist/overlay/dialog/Dialog.svelte +25 -19
- package/dist/overlay/dialog/Dialog.svelte.d.ts +11 -5
- package/dist/overlay/dialog/DialogActions.d.ts +1 -1
- package/dist/overlay/dialog/DialogCloseConfirm.d.ts +4 -1
- package/dist/overlay/dialog/DialogCloseConfirm.js +1 -1
- package/dist/overlay/dialog/DialogManager.svelte.js +2 -1
- package/dist/overlay/dialog/README.md +19 -17
- package/dist/overlay/dialog/README_CN.md +19 -17
- package/dist/overlay/dialog/index.d.ts +2 -2
- package/dist/overlay/message-box/IMessageBox.d.ts +4 -4
- package/dist/overlay/message-box/MessageBox.svelte.js +3 -3
- package/dist/ticatec-uniface-web.css +38 -12
- package/dist/types.d.ts +38 -46
- package/dist/unifaceContext.d.ts +2 -2
- package/dist/utils/prefixFilter.js +0 -1
- package/docs/NAMING.md +362 -0
- package/docs/NAMING_CN.md +362 -0
- package/docs/components/README.md +16 -14
- package/docs/components/accordion/README.md +13 -2
- package/docs/components/accordion/example.svelte +1 -0
- package/docs/components/action-bar/README.md +4 -4
- package/docs/components/attachment-editor/README.md +224 -0
- package/docs/components/attachment-editor/example.svelte +22 -0
- package/docs/components/box/README.md +1 -1
- package/docs/components/button/README.md +8 -1
- package/docs/components/button/example.svelte +1 -0
- package/docs/components/card/README.md +19 -5
- package/docs/components/cascade-options-select/README.md +11 -5
- package/docs/components/columns-layout/README.md +8 -4
- package/docs/components/columns-layout/example.svelte +4 -0
- package/docs/components/common-dialog/README.md +19 -10
- package/docs/components/common-dialog/example.svelte +2 -1
- package/docs/components/concise-data-table/README.md +18 -29
- package/docs/components/concise-data-table/example.svelte +1 -1
- package/docs/components/context-menu/README.md +5 -5
- package/docs/components/context-menu/example.svelte +1 -1
- package/docs/components/criteria-field/README.md +1 -0
- package/docs/components/criteria-field/example.svelte +1 -0
- package/docs/components/data-table/README.md +63 -40
- package/docs/components/data-table/example.svelte +2 -2
- package/docs/components/date-picker/README.md +1 -1
- package/docs/components/date-time-picker/README.md +1 -1
- package/docs/components/dialog/README.md +21 -14
- package/docs/components/dialog/example.svelte +1 -1
- package/docs/components/form-field/README.md +3 -3
- package/docs/components/grid-form/README.md +15 -5
- package/docs/components/grid-form/example.svelte +1 -1
- package/docs/components/group-check-box/README.md +3 -3
- package/docs/components/group-radio-box/README.md +3 -3
- package/docs/components/icon/README.md +6 -5
- package/docs/components/icon-button/README.md +10 -1
- package/docs/components/icon-button/example.svelte +1 -0
- package/docs/components/image-editor/README.md +262 -0
- package/docs/components/{image-files → image-editor}/example.svelte +5 -3
- package/docs/components/input-options-select/README.md +2 -2
- package/docs/components/list-box/README.md +12 -13
- package/docs/components/list-box/example.svelte +3 -3
- package/docs/components/lookup-editor/README.md +1 -1
- package/docs/components/navigator/README.md +2 -1
- package/docs/components/navigator/example.svelte +1 -0
- package/docs/components/navigator-menu/README.md +24 -21
- package/docs/components/navigator-menu/example.svelte +4 -2
- package/docs/components/options-multi-select/README.md +2 -2
- package/docs/components/options-select/README.md +4 -4
- package/docs/components/page/README.md +2 -2
- package/docs/components/page-stack/README.md +67 -0
- package/docs/components/page-stack/example.svelte +7 -0
- package/docs/components/pagination/README.md +24 -7
- package/docs/components/pagination/example.svelte +5 -2
- package/docs/components/pagination-panel/README.md +25 -10
- package/docs/components/pagination-panel/example.svelte +5 -4
- package/docs/components/password-editor/README.md +128 -0
- package/docs/components/{attachment-files → password-editor}/example.svelte +5 -5
- package/docs/components/progress-bar/README.md +14 -4
- package/docs/components/progress-bar/example.svelte +1 -1
- package/docs/components/progress-step-bar/README.md +16 -7
- package/docs/components/progress-step-bar/example.svelte +5 -1
- package/docs/components/prompts-text-editor/README.md +8 -6
- package/docs/components/prompts-text-editor/example.svelte +0 -1
- package/docs/components/rows-layout/README.md +8 -4
- package/docs/components/rows-layout/example.svelte +4 -0
- package/docs/components/switch/README.md +2 -2
- package/docs/components/tabs/README.md +24 -9
- package/docs/components/tag/README.md +13 -2
- package/docs/components/tag/example.svelte +1 -0
- package/docs/components/text-button/README.md +20 -1
- package/docs/components/text-button/example.svelte +2 -0
- package/docs/components/time-editor/README.md +1 -1
- package/docs/components/transfer/README.md +16 -9
- package/docs/components/tree-view/README.md +29 -13
- package/docs/components/tree-view/example.svelte +2 -1
- package/docs/components/unit-number-editor/README.md +11 -8
- package/docs/components/unit-number-editor/example.svelte +0 -1
- package/package.json +13 -7
- package/dist/data_table/lib/CompareFunction.d.ts +0 -3
- package/dist/data_table/lib/FormatCell.d.ts +0 -2
- package/dist/form/attachment_files/FileRender.svelte +0 -125
- package/dist/form/attachment_files/FileRender.svelte.d.ts +0 -9
- package/dist/form/attachment_files/FileUploadBar.svelte +0 -66
- package/dist/form/attachment_files/FileUploadBar.svelte.d.ts +0 -8
- package/dist/form/attachment_files/FileUploadPanel.svelte +0 -161
- package/dist/form/attachment_files/FileUploadPanel.svelte.d.ts +0 -14
- package/dist/form/attachment_files/UploadFile.d.ts +0 -43
- package/dist/form/attachment_files/UploadFile.js +0 -80
- package/dist/form/cascade_options_select/CascadePanel.svelte +0 -52
- package/dist/form/cascade_options_select/CascadePanel.svelte.d.ts +0 -26
- package/dist/form/cascade_options_select/isLeafDetermine.d.ts +0 -4
- package/dist/form/common_editor/EditorEvents.d.ts +0 -14
- package/dist/form/common_editor/EditorEvents.js +0 -2
- package/dist/form/image-files/ImageFile.d.ts +0 -12
- package/dist/form/image-files/ImageFilesField.svelte +0 -128
- package/dist/form/image-files/ImageFilesField.svelte.d.ts +0 -18
- package/dist/form/image-files/ImageRender.svelte +0 -95
- package/dist/form/image-files/ImageRender.svelte.d.ts +0 -10
- package/dist/form/image-files/README.md +0 -468
- package/dist/form/image-files/README_CN.md +0 -468
- package/dist/form/image-files/index.d.ts +0 -10
- package/dist/form/image-files/index.js +0 -2
- package/dist/layout/flex/FlexBlock.svelte +0 -17
- package/dist/layout/flex/FlexBlock.svelte.d.ts +0 -38
- package/dist/layout/flex/README.md +0 -148
- package/dist/layout/flex/README_CN.md +0 -148
- package/dist/layout/flex/index.d.ts +0 -2
- package/dist/layout/flex/index.js +0 -2
- package/dist/layout/index.d.ts +0 -0
- package/dist/layout/index.js +0 -1
- package/docs/components/attachment-files/README.md +0 -332
- package/docs/components/image-files/README.md +0 -174
- /package/dist/data_table/lib/{FormatCell.js → CellAction.js} +0 -0
- /package/dist/data_table/lib/{CompareFunction.js → CompareFn.js} +0 -0
- /package/dist/{form/cascade_options_select/isLeafDetermine.js → data_table/lib/FormatCellFn.js} +0 -0
- /package/dist/form/{image-files/ImageFile.js → attachment_files/UploadTask.js} +0 -0
- /package/dist/form/{image-files → image_editor}/ImagePreview.svelte.d.ts +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { UploadedFile, FileType } from "./AttachmentFile";
|
|
2
|
+
import type { UploadTask } from "./UploadTask";
|
|
3
|
+
/** 列表项:已上传文件;没有 type 时按文件名推断 */
|
|
4
|
+
type Item = UploadedFile & {
|
|
5
|
+
type?: FileType;
|
|
6
|
+
};
|
|
7
|
+
interface Props {
|
|
8
|
+
/** 已上传的附件(与 task 二选一) */
|
|
9
|
+
file?: Item;
|
|
10
|
+
/** 上传中的任务(与 file 二选一) */
|
|
11
|
+
task?: UploadTask;
|
|
12
|
+
readonly?: boolean;
|
|
13
|
+
/** 缩略图地址;有则代替类型图标显示 */
|
|
14
|
+
thumbnail?: string | null;
|
|
15
|
+
/** 预览:有则显示预览按钮 */
|
|
16
|
+
onPreview?: (file: Item) => void;
|
|
17
|
+
ondownload?: (file: Item) => void;
|
|
18
|
+
onremove?: (file: Item) => void;
|
|
19
|
+
/** 取消上传中的任务,或移除失败的任务 */
|
|
20
|
+
oncancel?: (task: UploadTask) => void;
|
|
21
|
+
onretry?: (task: UploadTask) => void;
|
|
22
|
+
}
|
|
23
|
+
declare const AttachmentTile: import("svelte").Component<Props, {}, "">;
|
|
24
|
+
type AttachmentTile = ReturnType<typeof AttachmentTile>;
|
|
25
|
+
export default AttachmentTile;
|
|
@@ -9,7 +9,7 @@ export type OnUploaded = (url: string, thumbnail?: string) => void;
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
|
-
export type
|
|
12
|
+
export type OnError = (e: Error) => void;
|
|
13
13
|
/**
|
|
14
14
|
* 返回可以取消的接口
|
|
15
15
|
*/
|
|
@@ -19,4 +19,4 @@ export interface UploadProgress {
|
|
|
19
19
|
/**
|
|
20
20
|
* 上传文件的方法
|
|
21
21
|
*/
|
|
22
|
-
export type FileUpload = (file: File, progressUpdate: ProgressUpdate, onUploaded: OnUploaded, errorHandler:
|
|
22
|
+
export type FileUpload = (file: File, progressUpdate: ProgressUpdate, onUploaded: OnUploaded, errorHandler: OnError) => UploadProgress;
|
|
@@ -1,492 +1,111 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AttachmentEditor
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A form field for uploading and managing attachments (documents, spreadsheets, PDFs, media, anything). The whole field is a drop zone; the upload entry is a placeholder that sits at the end of the content (a dashed row in `list` layout, a "+" tile in `icon` layout) and expands to fill the field while it is empty. Uploads run inline with a progress indicator and a cancel button; failed uploads can be retried or discarded.
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> Rewritten in 5.1.0. Names follow the [API Naming Guide](../../../docs/NAMING.md); the old `onUpload` prop and the modal `FileUploadPanel` are gone (no compatibility aliases).
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
-
|
|
9
|
+
- **Drag & drop** anywhere inside the field, or click the placeholder to open the file dialog.
|
|
10
|
+
- **Two layouts** — `list` (one row per file, download + delete at the end of the row) and `icon` (tiles that wrap automatically).
|
|
11
|
+
- **Fixed height** via `height`; the content scrolls inside.
|
|
12
|
+
- **Inline upload progress** — list rows show a bar, percentage and a cancel button; tiles overlay a progress ring with the cancel button in the middle.
|
|
13
|
+
- **Retry / discard** failed uploads.
|
|
14
|
+
- **Limits** — `accept`, `maxSize`, `maxFiles`, `multiple`; rejected files are reported through `onFileRejected`.
|
|
15
|
+
- **Veto hook** `beforeRemove` and notifications `onremove`, `onchange`, `onFileUploaded`, `onUploadError`.
|
|
16
|
+
- **Readonly / disabled** — download stays available, delete and the upload entry disappear, drops are ignored.
|
|
17
|
+
- Inherits the shared field props (`variant`, `compact`, `theme`, `tooltip`, `error`, `style`, `onfocus`, `onblur`).
|
|
18
18
|
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install @ticatec/uniface-element
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## 引入
|
|
19
|
+
## Import
|
|
26
20
|
|
|
27
21
|
```typescript
|
|
28
|
-
import
|
|
29
|
-
import type {
|
|
22
|
+
import AttachmentEditor from "@ticatec/uniface-element/AttachmentEditor";
|
|
23
|
+
import type {AttachmentFile, AttachmentLayout, FileUpload, RejectReason} from "@ticatec/uniface-element/AttachmentEditor";
|
|
30
24
|
```
|
|
31
25
|
|
|
32
|
-
## Basic
|
|
26
|
+
## Basic usage
|
|
33
27
|
|
|
34
28
|
```svelte
|
|
35
29
|
<script lang="ts">
|
|
36
|
-
import
|
|
37
|
-
import type {
|
|
30
|
+
import AttachmentEditor from "@ticatec/uniface-element/AttachmentEditor";
|
|
31
|
+
import type {AttachmentFile, FileUpload} from "@ticatec/uniface-element/AttachmentEditor";
|
|
38
32
|
|
|
39
33
|
let files = $state<AttachmentFile[]>([]);
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Simulate successful upload
|
|
52
|
-
const fakeUrl = `/uploads/${file.name}`;
|
|
53
|
-
onUploaded(fakeUrl);
|
|
54
|
-
}
|
|
55
|
-
}, 100);
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
cancel: async () => {
|
|
59
|
-
clearInterval(interval);
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
35
|
+
const uploadFile: FileUpload = (file, progressUpdate, onUploaded, onError) => {
|
|
36
|
+
const xhr = new XMLHttpRequest();
|
|
37
|
+
xhr.upload.onprogress = (e) => progressUpdate(e.loaded);
|
|
38
|
+
xhr.onload = () => xhr.status < 300 ? onUploaded(JSON.parse(xhr.responseText).url) : onError(new Error(xhr.statusText));
|
|
39
|
+
xhr.onerror = () => onError(new Error('Network error'));
|
|
40
|
+
const body = new FormData();
|
|
41
|
+
body.append('file', file);
|
|
42
|
+
xhr.open('POST', '/api/upload');
|
|
43
|
+
xhr.send(body);
|
|
44
|
+
return {cancel: async () => { xhr.abort(); return true; }};
|
|
63
45
|
};
|
|
64
|
-
|
|
65
|
-
function handleFilesChange(updatedFiles: AttachmentFile[]) {
|
|
66
|
-
console.log("Files updated:", updatedFiles);
|
|
67
|
-
// ... save to backend
|
|
68
|
-
}
|
|
69
46
|
</script>
|
|
70
47
|
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
uploadFile={uploadFile}
|
|
74
|
-
onchange={handleFilesChange}
|
|
75
|
-
maxFiles={5}
|
|
76
|
-
/>
|
|
48
|
+
<AttachmentEditor bind:files {uploadFile} layout="icon" height={160} maxFiles={5}
|
|
49
|
+
onchange={(list) => console.log('files', list)}/>
|
|
77
50
|
```
|
|
78
51
|
|
|
79
52
|
## Props
|
|
80
53
|
|
|
81
|
-
|
|
54
|
+
Props inherited from `CommonFieldProps` (`variant`, `compact`, `disabled`, `readonly`, `theme`, `tooltip`, `error`, `style`, `onfocus`, `onblur`) are not repeated.
|
|
82
55
|
|
|
83
56
|
| Prop | Type | Default | Description |
|
|
84
57
|
|------|------|---------|-------------|
|
|
85
|
-
| `files` | `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
|
104
|
-
|-------|-----------|-------------|
|
|
105
|
-
| `onchange` | `(files: Array<AttachmentFile>) => void` | Fires when the files array changes (upload or delete). Receives the updated files array. |
|
|
106
|
-
| `onfocus` | `(event: FocusEvent) => void` | Editor focus. |
|
|
107
|
-
| `onblur` | `(event: FocusEvent) => void` | Editor blur. |
|
|
58
|
+
| `files` | `AttachmentFile[]` (bindable) | `[]` | Uploaded files. Each has `name`, `type`, `uri` and optional `size` / `thumbnail`. |
|
|
59
|
+
| `layout` | `'list' \| 'icon'` | `'list'` | `list`: one row per file; `icon`: tiles that wrap. |
|
|
60
|
+
| `height` | `number \| string` | — | Height of the content area (number = px). Content scrolls inside; omit for auto height. |
|
|
61
|
+
| `uploadFile` | `FileUpload` | — | Upload function (see below). Without it the field only displays files and shows no upload entry. |
|
|
62
|
+
| `accept` | `string` | `"*/*"` | Allowed types, same syntax as `<input accept>`. |
|
|
63
|
+
| `maxSize` | `number` | `10 MB` | Per-file size limit in bytes. |
|
|
64
|
+
| `maxFiles` | `number` | `10` | Maximum number of files, uploads in progress included. The upload entry disappears when reached. |
|
|
65
|
+
| `multiple` | `boolean` | `true` | Allow picking / dropping several files at once. |
|
|
66
|
+
| `uploadText` | `string` | i18n `upload.dropHint` | Text of the upload entry; also the empty-state hint. |
|
|
67
|
+
| `emptyText` | `string` | i18n `upload.emptyText` | Shown when there are no files and uploading is not possible. |
|
|
68
|
+
| `showThumbnail` | `boolean` | `false` | Show image files as thumbnails (`thumbnail ?? uri`) and a local preview while an image is uploading. A file that carries `thumbnail` is always shown as one. |
|
|
69
|
+
| `onPreview` | `(file: AttachmentFile) => void` | — | When set, every file gets a preview button. |
|
|
70
|
+
| `beforeRemove` | `BeforeRemove<AttachmentFile>` | — | Veto hook; return `false` (or a promise of it) to keep the file. |
|
|
71
|
+
| `onremove` | `(file: AttachmentFile) => void` | — | A file was removed. |
|
|
72
|
+
| `ondownload` | `(file: AttachmentFile) => void` | — | Custom download. Without it the download icon is a plain link to `file.uri`. |
|
|
73
|
+
| `onFileUploaded` | `(file: AttachmentFile, source: File) => void` | — | One upload finished and was appended to `files`. |
|
|
74
|
+
| `onFileRejected` | `(file: File, reason: 'accept' \| 'size' \| 'count') => void` | — | A picked / dropped file was refused. |
|
|
75
|
+
| `onUploadError` | `(file: File, error: Error) => void` | — | An upload failed; the task stays in the list with retry / remove. |
|
|
76
|
+
| `onchange` | `(files: AttachmentFile[]) => void` | — | `files` changed (upload completed or file removed). |
|
|
108
77
|
|
|
109
78
|
## Methods
|
|
110
79
|
|
|
111
|
-
| Method |
|
|
112
|
-
|
|
113
|
-
| `
|
|
114
|
-
|
|
115
|
-
```svelte
|
|
116
|
-
<script lang="ts">
|
|
117
|
-
import AttachmentFilesField from "@ticatec/uniface-element/AttachmentFilesField";
|
|
118
|
-
|
|
119
|
-
let editorRef;
|
|
120
|
-
|
|
121
|
-
function focusEditor() {
|
|
122
|
-
editorRef.focus();
|
|
123
|
-
}
|
|
124
|
-
</script>
|
|
125
|
-
|
|
126
|
-
<AttachmentFilesField bind:this={editorRef} bind:files={files} uploadFile={uploadFile} />
|
|
127
|
-
<button onclick={focusEditor}>Focus</button>
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
## `FileUpload` — upload function
|
|
80
|
+
| Method | Description |
|
|
81
|
+
|--------|-------------|
|
|
82
|
+
| `openFileDialog()` | Opens the system file dialog (same as clicking the upload entry). No-op when uploading is not possible. |
|
|
83
|
+
| `focus()` | Moves focus to the first control inside the field. |
|
|
131
84
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
| Parameter | Type | Description |
|
|
135
|
-
|-----------|------|-------------|
|
|
136
|
-
| `file` | `File` | The file to upload. |
|
|
137
|
-
| `progressUpdate` | `(bytesUploaded: number) => void` | Call this to report upload progress. |
|
|
138
|
-
| `onUploaded` | `(url: string) => void` | Call this when upload is complete. Pass the file URL. |
|
|
139
|
-
| `errorHandler` | `(error: Error) => void` | Call this if upload fails. Pass an Error object. |
|
|
140
|
-
|
|
141
|
-
It must return an `UploadProgress` object:
|
|
85
|
+
## `FileUpload`
|
|
142
86
|
|
|
143
87
|
```typescript
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
88
|
+
type FileUpload = (
|
|
89
|
+
file: File,
|
|
90
|
+
progressUpdate: (uploadedBytes: number) => void,
|
|
91
|
+
onUploaded: (url: string, thumbnail?: string) => void,
|
|
92
|
+
onError: (error: Error) => void
|
|
93
|
+
) => {cancel: () => Promise<boolean>};
|
|
147
94
|
```
|
|
148
95
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
```svelte
|
|
152
|
-
<script lang="ts">
|
|
153
|
-
import AttachmentFilesField from "@ticatec/uniface-element/AttachmentFilesField";
|
|
154
|
-
import type { FileUpload } from "@ticatec/uniface-element/AttachmentFilesField";
|
|
155
|
-
|
|
156
|
-
let files = $state([]);
|
|
157
|
-
|
|
158
|
-
const uploadFile: FileUpload = (file, progressUpdate, onUploaded, errorHandler) => {
|
|
159
|
-
// Simulate upload with progress
|
|
160
|
-
let bytesUploaded = 0;
|
|
161
|
-
const totalBytes = file.size;
|
|
162
|
-
const interval = setInterval(() => {
|
|
163
|
-
bytesUploaded += 1024; // 1KB per tick
|
|
164
|
-
if (bytesUploaded >= totalBytes) {
|
|
165
|
-
clearInterval(interval);
|
|
166
|
-
onUploaded(`/uploads/${file.name}`);
|
|
167
|
-
} else {
|
|
168
|
-
progressUpdate(bytesUploaded);
|
|
169
|
-
}
|
|
170
|
-
}, 100);
|
|
171
|
-
|
|
172
|
-
return {
|
|
173
|
-
cancel: async () => {
|
|
174
|
-
clearInterval(interval);
|
|
175
|
-
return true; // upload was cancelled
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
</script>
|
|
180
|
-
|
|
181
|
-
<AttachmentFilesField bind:files={files} uploadFile={uploadFile} />
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## `AttachmentFile` — file object
|
|
185
|
-
|
|
186
|
-
Each file in the `files` array is an `AttachmentFile` object:
|
|
187
|
-
|
|
188
|
-
```typescript
|
|
189
|
-
interface AttachmentFile {
|
|
190
|
-
name: string; // File name
|
|
191
|
-
uri: string; // File URL (after upload)
|
|
192
|
-
type: FileType; // File type (IMAGE, PDF, DOC, XLS, PPT, AUDIO, VIDEO, OTHER)
|
|
193
|
-
}
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
## `FileType` — file type enum
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
enum FileType {
|
|
200
|
-
IMAGE = 'img',
|
|
201
|
-
PDF = 'pdf',
|
|
202
|
-
DOC = 'doc',
|
|
203
|
-
XLS = 'xml',
|
|
204
|
-
PPT = 'ppt',
|
|
205
|
-
AUDIO = 'wav',
|
|
206
|
-
VIDEO = 'mov',
|
|
207
|
-
OTHER = 'dat'
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## Examples
|
|
212
|
-
|
|
213
|
-
### File upload with confirmation
|
|
214
|
-
|
|
215
|
-
```svelte
|
|
216
|
-
<script lang="ts">
|
|
217
|
-
import AttachmentFilesField from "@ticatec/uniface-element/AttachmentFilesField";
|
|
218
|
-
import type { AttachmentFile, FileUpload, RemoveConfirm } from "@ticatec/uniface-element/AttachmentFilesField";
|
|
219
|
-
|
|
220
|
-
let files = $state<AttachmentFile[]>([]);
|
|
221
|
-
|
|
222
|
-
const uploadFile: FileUpload = (file, progressUpdate, onUploaded, errorHandler) => {
|
|
223
|
-
let bytesUploaded = 0;
|
|
224
|
-
const totalBytes = file.size;
|
|
225
|
-
const interval = setInterval(() => {
|
|
226
|
-
bytesUploaded += 1024;
|
|
227
|
-
if (bytesUploaded >= totalBytes) {
|
|
228
|
-
clearInterval(interval);
|
|
229
|
-
onUploaded(`/uploads/${file.name}`);
|
|
230
|
-
} else {
|
|
231
|
-
progressUpdate(bytesUploaded);
|
|
232
|
-
}
|
|
233
|
-
}, 100);
|
|
234
|
-
|
|
235
|
-
return {
|
|
236
|
-
cancel: async () => {
|
|
237
|
-
clearInterval(interval);
|
|
238
|
-
return true;
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
const removeFileConfirm: RemoveConfirm = async (file) => {
|
|
244
|
-
return confirm(`Are you sure you want to delete ${file.name}?`);
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
function handleFilesChange(updatedFiles: AttachmentFile[]) {
|
|
248
|
-
console.log("Files updated:", updatedFiles);
|
|
249
|
-
// ... save to backend
|
|
250
|
-
}
|
|
251
|
-
</script>
|
|
252
|
-
|
|
253
|
-
<AttachmentFilesField
|
|
254
|
-
bind:files={files}
|
|
255
|
-
uploadFile={uploadFile}
|
|
256
|
-
removeFileConfirm={removeFileConfirm}
|
|
257
|
-
onchange={handleFilesChange}
|
|
258
|
-
maxFiles={5}
|
|
259
|
-
/>
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### Multiple file types
|
|
263
|
-
|
|
264
|
-
```svelte
|
|
265
|
-
<script lang="ts">
|
|
266
|
-
import AttachmentFilesField from "@ticatec/uniface-element/AttachmentFilesField";
|
|
267
|
-
import type { AttachmentFile, FileUpload } from "@ticatec/uniface-element/AttachmentFilesField";
|
|
268
|
-
|
|
269
|
-
let files = $state<AttachmentFile[]>([]);
|
|
270
|
-
|
|
271
|
-
const uploadFile: FileUpload = (file, progressUpdate, onUploaded, errorHandler) => {
|
|
272
|
-
// Simulate upload
|
|
273
|
-
let progress = 0;
|
|
274
|
-
const interval = setInterval(() => {
|
|
275
|
-
progress += 10;
|
|
276
|
-
progressUpdate(Math.floor(file.size * (progress / 100)));
|
|
277
|
-
|
|
278
|
-
if (progress >= 100) {
|
|
279
|
-
clearInterval(interval);
|
|
280
|
-
onUploaded(`/uploads/${file.name}`);
|
|
281
|
-
}
|
|
282
|
-
}, 100);
|
|
283
|
-
|
|
284
|
-
return {
|
|
285
|
-
cancel: async () => {
|
|
286
|
-
clearInterval(interval);
|
|
287
|
-
return true;
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
|
-
</script>
|
|
292
|
-
|
|
293
|
-
<div class="file-upload-section">
|
|
294
|
-
<h3>Upload Files</h3>
|
|
295
|
-
<AttachmentFilesField
|
|
296
|
-
bind:files={files}
|
|
297
|
-
uploadFile={uploadFile}
|
|
298
|
-
maxFiles={10}
|
|
299
|
-
/>
|
|
300
|
-
<div class="file-list">
|
|
301
|
-
{#each files as file}
|
|
302
|
-
<div class="file-item">
|
|
303
|
-
<span class="file-icon">📄</span>
|
|
304
|
-
<span class="file-name">{file.name}</span>
|
|
305
|
-
<span class="file-type">{file.type}</span>
|
|
306
|
-
</div>
|
|
307
|
-
{/each}
|
|
308
|
-
</div>
|
|
309
|
-
</div>
|
|
310
|
-
|
|
311
|
-
<style>
|
|
312
|
-
.file-upload-section {
|
|
313
|
-
max-width: 600px;
|
|
314
|
-
margin: 20px;
|
|
315
|
-
padding: 20px;
|
|
316
|
-
border: 1px solid #e5e7eb;
|
|
317
|
-
border-radius: 8px;
|
|
318
|
-
}
|
|
319
|
-
.file-list {
|
|
320
|
-
margin-top: 16px;
|
|
321
|
-
}
|
|
322
|
-
.file-item {
|
|
323
|
-
display: flex;
|
|
324
|
-
align-items: center;
|
|
325
|
-
gap: 8px;
|
|
326
|
-
padding: 8px;
|
|
327
|
-
border-bottom: 1px solid #f3f4f6;
|
|
328
|
-
}
|
|
329
|
-
.file-icon {
|
|
330
|
-
font-size: 20px;
|
|
331
|
-
}
|
|
332
|
-
.file-name {
|
|
333
|
-
flex: 1;
|
|
334
|
-
}
|
|
335
|
-
.file-type {
|
|
336
|
-
color: #6b7280;
|
|
337
|
-
}
|
|
338
|
-
</style>
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
### Disabled and readonly modes
|
|
342
|
-
|
|
343
|
-
```svelte
|
|
344
|
-
<script lang="ts">
|
|
345
|
-
import AttachmentFilesField from "@ticatec/uniface-element/AttachmentFilesField";
|
|
346
|
-
import type { AttachmentFile, FileUpload } from "@ticatec/uniface-element/AttachmentFilesField";
|
|
347
|
-
|
|
348
|
-
let disabledFiles: AttachmentFile[] = [
|
|
349
|
-
{ name: "disabled-file.pdf", uri: "/uploads/disabled-file.pdf", type: "pdf" }
|
|
350
|
-
];
|
|
351
|
-
let readonlyFiles: AttachmentFile[] = [
|
|
352
|
-
{ name: "readonly-file.docx", uri: "/uploads/readonly-file.docx", type: "doc" }
|
|
353
|
-
];
|
|
354
|
-
let normalFiles: AttachmentFile[] = [];
|
|
355
|
-
|
|
356
|
-
const uploadFile: FileUpload = (file, progressUpdate, onUploaded, errorHandler) => {
|
|
357
|
-
let progress = 0;
|
|
358
|
-
const interval = setInterval(() => {
|
|
359
|
-
progress += 10;
|
|
360
|
-
progressUpdate(Math.floor(file.size * (progress / 100)));
|
|
361
|
-
|
|
362
|
-
if (progress >= 100) {
|
|
363
|
-
clearInterval(interval);
|
|
364
|
-
onUploaded(`/uploads/${file.name}`);
|
|
365
|
-
}
|
|
366
|
-
}, 100);
|
|
367
|
-
|
|
368
|
-
return {
|
|
369
|
-
cancel: async () => {
|
|
370
|
-
clearInterval(interval);
|
|
371
|
-
return true;
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
};
|
|
375
|
-
</script>
|
|
376
|
-
|
|
377
|
-
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
378
|
-
<AttachmentFilesField
|
|
379
|
-
bind:files={disabledFiles}
|
|
380
|
-
uploadFile={uploadFile}
|
|
381
|
-
disabled
|
|
382
|
-
/>
|
|
383
|
-
<AttachmentFilesField
|
|
384
|
-
bind:files={readonlyFiles}
|
|
385
|
-
uploadFile={uploadFile}
|
|
386
|
-
readonly
|
|
387
|
-
/>
|
|
388
|
-
<AttachmentFilesField
|
|
389
|
-
bind:files={normalFiles}
|
|
390
|
-
uploadFile={uploadFile}
|
|
391
|
-
/>
|
|
392
|
-
</div>
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
### Compact mode
|
|
396
|
-
|
|
397
|
-
```svelte
|
|
398
|
-
<script lang="ts">
|
|
399
|
-
import AttachmentFilesField from "@ticatec/uniface-element/AttachmentFilesField";
|
|
400
|
-
import type { AttachmentFile, FileUpload } from "@ticatec/uniface-element/AttachmentFilesField";
|
|
401
|
-
|
|
402
|
-
let files = $state<AttachmentFile[]>([]);
|
|
403
|
-
|
|
404
|
-
const uploadFile: FileUpload = (file, progressUpdate, onUploaded, errorHandler) => {
|
|
405
|
-
let progress = 0;
|
|
406
|
-
const interval = setInterval(() => {
|
|
407
|
-
progress += 10;
|
|
408
|
-
progressUpdate(Math.floor(file.size * (progress / 100)));
|
|
409
|
-
|
|
410
|
-
if (progress >= 100) {
|
|
411
|
-
clearInterval(interval);
|
|
412
|
-
onUploaded(`/uploads/${file.name}`);
|
|
413
|
-
}
|
|
414
|
-
}, 100);
|
|
415
|
-
|
|
416
|
-
return {
|
|
417
|
-
cancel: async () => {
|
|
418
|
-
clearInterval(interval);
|
|
419
|
-
return true;
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
};
|
|
423
|
-
</script>
|
|
424
|
-
|
|
425
|
-
<table>
|
|
426
|
-
<thead>
|
|
427
|
-
<tr>
|
|
428
|
-
<th>Name</th>
|
|
429
|
-
<th>Files</th>
|
|
430
|
-
</tr>
|
|
431
|
-
</thead>
|
|
432
|
-
<tbody>
|
|
433
|
-
<tr>
|
|
434
|
-
<td>Row 1</td>
|
|
435
|
-
<td>
|
|
436
|
-
<AttachmentFilesField
|
|
437
|
-
bind:files={files}
|
|
438
|
-
uploadFile={uploadFile}
|
|
439
|
-
compact
|
|
440
|
-
/>
|
|
441
|
-
</td>
|
|
442
|
-
</tr>
|
|
443
|
-
</tbody>
|
|
444
|
-
</table>
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
## Behavior Notes
|
|
448
|
-
|
|
449
|
-
### Upload flow
|
|
450
|
-
|
|
451
|
-
1. User clicks the upload icon or drags and drops files.
|
|
452
|
-
2. The `FileUploadPanel` opens, showing a file picker.
|
|
453
|
-
3. When a file is selected, `uploadFile` is called with the file and progress callbacks.
|
|
454
|
-
4. `uploadFile` calls `progressUpdate(bytesUploaded)` to report progress.
|
|
455
|
-
5. When upload is complete, `uploadFile` calls `onUploaded(url)` with the file URL.
|
|
456
|
-
6. The file is added to the `files` array and displayed in the file list.
|
|
457
|
-
|
|
458
|
-
### Delete flow
|
|
459
|
-
|
|
460
|
-
1. User clicks the delete icon on a file.
|
|
461
|
-
2. If `removeFileConfirm` is provided, the callback is called with the file.
|
|
462
|
-
3. If the callback returns `true`, the file is removed from the `files` array.
|
|
463
|
-
4. The `onchange` event fires with the updated files array.
|
|
464
|
-
|
|
465
|
-
### File type detection
|
|
466
|
-
|
|
467
|
-
File types are detected based on file extensions:
|
|
468
|
-
|
|
469
|
-
- **IMAGE**: jpg, jpeg, png, gif, bmp, tiff, webp, svg, ico, heif, heic
|
|
470
|
-
- **PDF**: pdf
|
|
471
|
-
- **DOC**: doc, docx, dot, dotx, docm, dotm
|
|
472
|
-
- **XLS**: xls, xlsx, xlsm, xlsb, csv, ods, xlt, xltx, xltm
|
|
473
|
-
- **PPT**: ppt, pptx, pptm, pps, ppsx, ppsm, pot, potx, potm
|
|
474
|
-
- **AUDIO**: mp3, wav, aac, flac, ogg, wma, m4a, aiff, alac
|
|
475
|
-
- **VIDEO**: mp4, avi, mkv, mov, wmv, flv, webm, mpeg, mpg, 3gp, m4v, vob
|
|
476
|
-
- **OTHER**: anything else
|
|
96
|
+
Call `progressUpdate` with the number of bytes sent so far (the component converts it to a percentage), `onUploaded` with the stored URL when done, or `onError` on failure. `cancel()` resolving `false` keeps the task in the list.
|
|
477
97
|
|
|
478
|
-
|
|
98
|
+
## Behavior notes
|
|
479
99
|
|
|
480
|
-
|
|
100
|
+
- Files that fail `accept` / `maxSize` / the remaining `maxFiles` quota never start uploading; each is reported once through `onFileRejected`.
|
|
101
|
+
- An upload that succeeds appends `{name, type, uri, size, thumbnail}` to `files` (type derived from the extension, `thumbnail` from the uploader's second `onUploaded` argument), then fires `onFileUploaded` and `onchange`.
|
|
102
|
+
- `readonly` and `disabled` both hide delete and the upload entry and ignore drops; download links remain in `readonly`.
|
|
103
|
+
- The drag highlight only reacts to drags that carry files.
|
|
481
104
|
|
|
482
|
-
##
|
|
105
|
+
## Styling
|
|
483
106
|
|
|
484
|
-
-
|
|
485
|
-
- File names are displayed as plain text.
|
|
486
|
-
- For full ARIA, wrap with `<label>` or use `aria-label`.
|
|
107
|
+
Component-level CSS variables (all have fallbacks): `--uniface-attachment-item-height`, `--uniface-attachment-tile-size`, `--uniface-attachment-icon-color`, `--uniface-attachment-add-border-color`, `--uniface-attachment-add-color`, `--uniface-attachment-drag-bg`, `--uniface-attachment-error-color`, `--uniface-attachment-overlay-bg`. `compact` switches to 26 px rows / 64 px tiles.
|
|
487
108
|
|
|
488
|
-
## Related
|
|
109
|
+
## Related components
|
|
489
110
|
|
|
490
|
-
- [
|
|
491
|
-
- [TextEditor](../text_editor/README.md) — multi-line text area.
|
|
492
|
-
- [NumberEditor](../number_editor/README.md) — numeric input.
|
|
111
|
+
- [ImageEditor](../image_editor/README.md) — same implementation for images: thumbnail tiles and a built-in preview.
|