@vef-framework/components 1.0.101 → 1.0.103
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/es/index.js +1 -91
- package/es/internal/base.css.js +490 -4
- package/es/internal/chart.js +1 -19
- package/es/internal/index.js +1 -4
- package/es/internal/modern-normalize.css.js +213 -4
- package/es/internal/utils.js +1 -7
- package/es/vef-access-denied/access-denied-icon.js +1 -929
- package/es/vef-access-denied/index.js +3 -40
- package/es/vef-action-buttons/index.js +1 -76
- package/es/vef-approval-flow-editor/components/edge.js +2 -84
- package/es/vef-approval-flow-editor/components/label-value.js +2 -22
- package/es/vef-approval-flow-editor/components/node-content.js +4 -40
- package/es/vef-approval-flow-editor/components/node-selector.js +2 -32
- package/es/vef-approval-flow-editor/components/node-toolbar.js +1 -22
- package/es/vef-approval-flow-editor/components/nodes/approval.js +1 -25
- package/es/vef-approval-flow-editor/components/nodes/condition.js +1 -25
- package/es/vef-approval-flow-editor/components/nodes/end.js +1 -25
- package/es/vef-approval-flow-editor/components/nodes/handle.js +1 -25
- package/es/vef-approval-flow-editor/components/nodes/index.js +1 -18
- package/es/vef-approval-flow-editor/components/nodes/submit.js +1 -25
- package/es/vef-approval-flow-editor/components/selector-content.js +3 -43
- package/es/vef-approval-flow-editor/components/source-handle.js +1 -41
- package/es/vef-approval-flow-editor/components/target-handle.js +1 -10
- package/es/vef-approval-flow-editor/constants.js +1 -219
- package/es/vef-approval-flow-editor/helper.js +1 -84
- package/es/vef-approval-flow-editor/hooks/use-edges-interaction.js +1 -26
- package/es/vef-approval-flow-editor/hooks/use-element-selection.js +1 -25
- package/es/vef-approval-flow-editor/hooks/use-nodes-interaction.js +1 -52
- package/es/vef-approval-flow-editor/index.js +1 -76
- package/es/vef-approval-flow-editor/models/edge-node.js +1 -21
- package/es/vef-approval-flow-editor/models/flow-node.js +1 -106
- package/es/vef-approval-flow-editor/store.js +1 -17
- package/es/vef-approval-flow-editor/styles.js +3 -12
- package/es/vef-approval-flow-editor/types.js +1 -16
- package/es/vef-area-chart/index.js +1 -42
- package/es/vef-auto-sizer/index.js +1 -7
- package/es/vef-avatar/index.js +1 -21
- package/es/vef-avatar-group/index.js +1 -26
- package/es/vef-badge/index.js +1 -48
- package/es/vef-bar-chart/index.js +1 -42
- package/es/vef-bool/hooks/use-bool-instance.js +1 -35
- package/es/vef-bool/index.js +1 -61
- package/es/vef-breadcrumb/index.js +1 -49
- package/es/vef-button/components/base-button.js +1 -74
- package/es/vef-button/index.js +1 -152
- package/es/vef-card/index.js +1 -26
- package/es/vef-card-meta/index.js +1 -13
- package/es/vef-chart-container/hooks/use-chart-container-context.js +1 -13
- package/es/vef-chart-container/index.js +5 -72
- package/es/vef-chart-legend-content/index.js +4 -38
- package/es/vef-chart-tooltip-content/index.js +9 -73
- package/es/vef-checkbox/hooks/use-checkbox-instance.js +1 -21
- package/es/vef-checkbox/hooks/use-data-options.js +1 -41
- package/es/vef-checkbox/index.js +2 -88
- package/es/vef-col/index.js +1 -12
- package/es/vef-color-picker/index.js +1 -47
- package/es/vef-compact/index.js +1 -16
- package/es/vef-config-provider/global-style.js +3 -12
- package/es/vef-config-provider/hooks/use-ui-config.js +1 -127
- package/es/vef-config-provider/index.js +3 -122
- package/es/vef-config-provider/store.js +1 -22
- package/es/vef-container/index.js +1 -19
- package/es/vef-crud-page/components/crud-actions.js +1 -33
- package/es/vef-crud-page/components/crud-filter.js +1 -55
- package/es/vef-crud-page/components/crud-footer.js +2 -116
- package/es/vef-crud-page/components/crud-form-modal.js +1 -54
- package/es/vef-crud-page/components/crud-header.js +1 -30
- package/es/vef-crud-page/components/crud-table.js +1 -77
- package/es/vef-crud-page/hooks/use-action-buttons.js +1 -38
- package/es/vef-crud-page/hooks/use-crud-context.js +1 -21
- package/es/vef-crud-page/hooks/use-crud-schema.js +1 -117
- package/es/vef-crud-page/hooks/use-operation-buttons.js +1 -61
- package/es/vef-crud-page/index.js +1 -151
- package/es/vef-crud-page/store.js +1 -143
- package/es/vef-data-grid/index.js +1 -86
- package/es/vef-data-table/index.js +1 -10
- package/es/vef-divider/index.js +1 -25
- package/es/vef-drawer/components/action-button-wrapper.js +1 -50
- package/es/vef-drawer/components/button-props.js +1 -3
- package/es/vef-drawer/components/cancel-action-button.js +1 -22
- package/es/vef-drawer/components/ok-action-button.js +1 -21
- package/es/vef-drawer/context.js +1 -16
- package/es/vef-drawer/index.js +2 -154
- package/es/vef-dropdown/index.js +1 -93
- package/es/vef-dynamic-icon/index.js +1 -47
- package/es/vef-dynamic-icon/props.js +1 -7
- package/es/vef-empty/index.js +1 -38
- package/es/vef-empty-placeholder/index.js +2 -18
- package/es/vef-error/error-icon.js +1 -758
- package/es/vef-error/index.js +3 -43
- package/es/vef-filter/components/action-buttons.js +2 -117
- package/es/vef-filter/components/advanced-filter.js +3 -67
- package/es/vef-filter/components/basic-filter.js +2 -34
- package/es/vef-filter/components/fields/index.js +1 -20
- package/es/vef-filter/components/fields/input-number.js +1 -91
- package/es/vef-filter/components/fields/input.js +1 -68
- package/es/vef-filter/components/fields/radio.js +1 -110
- package/es/vef-filter/components/fields/select.js +1 -141
- package/es/vef-filter/components/fields/tree-select.js +1 -137
- package/es/vef-filter/components/filter-field.js +1 -20
- package/es/vef-filter/components/filter-item.js +1 -113
- package/es/vef-filter/event.js +1 -45
- package/es/vef-filter/helper.js +1 -16
- package/es/vef-filter/hooks/use-action-handlers.js +1 -71
- package/es/vef-filter/hooks/use-computed-values.js +1 -56
- package/es/vef-filter/hooks/use-filter-context.js +1 -19
- package/es/vef-filter/hooks/use-filter-initialization.js +1 -38
- package/es/vef-filter/hooks/use-filter-instance.js +1 -27
- package/es/vef-filter/hooks/use-filter-items.js +1 -24
- package/es/vef-filter/hooks/use-filter-values-change.js +1 -31
- package/es/vef-filter/hooks/use-label-config.js +1 -28
- package/es/vef-filter/index.js +2 -142
- package/es/vef-filter/store.js +1 -72
- package/es/vef-flex/index.js +1 -32
- package/es/vef-float-button/index.js +1 -50
- package/es/vef-float-button-group/index.js +1 -21
- package/es/vef-form/components/fields/icon-select.js +1 -66
- package/es/vef-form/components/fields/index.js +1 -26
- package/es/vef-form/components/fields/input-number.js +1 -124
- package/es/vef-form/components/fields/input.js +1 -133
- package/es/vef-form/components/fields/password.js +1 -116
- package/es/vef-form/components/fields/radio.js +1 -107
- package/es/vef-form/components/fields/select.js +1 -239
- package/es/vef-form/components/fields/textarea.js +1 -110
- package/es/vef-form/components/fields/tree-select.js +1 -235
- package/es/vef-form/components/form-actions.js +2 -58
- package/es/vef-form/components/form-content.js +2 -145
- package/es/vef-form/components/form-field.js +1 -23
- package/es/vef-form/components/form-group.js +2 -64
- package/es/vef-form/components/form-hidden-item.js +1 -37
- package/es/vef-form/components/form-item.js +1 -80
- package/es/vef-form/components/form-row.js +1 -99
- package/es/vef-form/event.js +1 -45
- package/es/vef-form/helper.js +1 -16
- package/es/vef-form/hooks/use-action-handlers.js +1 -131
- package/es/vef-form/hooks/use-columns-layout.js +1 -123
- package/es/vef-form/hooks/use-computed-values.js +1 -56
- package/es/vef-form/hooks/use-form-context.js +1 -15
- package/es/vef-form/hooks/use-form-initialization.js +1 -46
- package/es/vef-form/hooks/use-form-instance.js +1 -27
- package/es/vef-form/hooks/use-form-values-change.js +1 -31
- package/es/vef-form/hooks/use-label-width.js +1 -19
- package/es/vef-form/index.js +2 -174
- package/es/vef-form/store.js +1 -66
- package/es/vef-form/validation-rules.js +1 -287
- package/es/vef-form-drawer/index.js +1 -99
- package/es/vef-form-modal/index.js +1 -96
- package/es/vef-generic-select/index.js +1 -82
- package/es/vef-grid/index.js +9 -75
- package/es/vef-grid/props.js +1 -5
- package/es/vef-grid-item/index.js +1 -53
- package/es/vef-icon/index.js +1 -51
- package/es/vef-icon-select/index.js +4 -140
- package/es/vef-input/hooks/use-input-instance.js +1 -16
- package/es/vef-input/index.js +1 -65
- package/es/vef-input-number/hooks/use-input-number-instance.js +1 -14
- package/es/vef-input-number/index.js +1 -149
- package/es/vef-layout/common-styles.js +2 -9
- package/es/vef-layout/components/content.js +1 -14
- package/es/vef-layout/components/font-size.js +1 -69
- package/es/vef-layout/components/fullscreen.js +1 -24
- package/es/vef-layout/components/header-action-icons.js +2 -26
- package/es/vef-layout/components/header-content.js +1 -20
- package/es/vef-layout/components/header.js +2 -66
- package/es/vef-layout/components/icon-boy.js +1 -70
- package/es/vef-layout/components/icon-girl.js +1 -77
- package/es/vef-layout/components/icon-menu-fold-left.js +1 -24
- package/es/vef-layout/components/icon-menu-unfold-left.js +1 -24
- package/es/vef-layout/components/menu-groups.js +5 -114
- package/es/vef-layout/components/message.js +1 -12
- package/es/vef-layout/components/search.js +1 -12
- package/es/vef-layout/components/sider.js +2 -52
- package/es/vef-layout/components/title.js +2 -48
- package/es/vef-layout/components/user-avatar.js +4 -76
- package/es/vef-layout/hooks/use-layout-context.js +1 -11
- package/es/vef-layout/index.js +2 -34
- package/es/vef-layout/logo.svg.js +1 -5
- package/es/vef-layout/store.js +1 -17
- package/es/vef-line-chart/index.js +1 -39
- package/es/vef-loading-placeholder/index.js +2 -40
- package/es/vef-login/index.js +9 -141
- package/es/vef-login/login-icon.js +1 -669
- package/es/vef-menu/index.js +2 -76
- package/es/vef-modal/components/action-button-wrapper.js +1 -50
- package/es/vef-modal/components/button-props.js +1 -3
- package/es/vef-modal/components/cancel-action-button.js +1 -19
- package/es/vef-modal/components/ok-action-button.js +1 -21
- package/es/vef-modal/context.js +1 -16
- package/es/vef-modal/index.js +2 -240
- package/es/vef-not-found/index.js +3 -40
- package/es/vef-not-found/not-found-icon.js +1 -845
- package/es/vef-page/index.js +2 -80
- package/es/vef-pagination/index.js +1 -58
- package/es/vef-pagination/props.js +1 -14
- package/es/vef-paragraph/index.js +1 -90
- package/es/vef-password/hooks/use-password-instance.js +1 -14
- package/es/vef-password/index.js +1 -68
- package/es/vef-pie-chart/index.js +3 -66
- package/es/vef-popconfirm/index.js +1 -57
- package/es/vef-popover/index.js +1 -35
- package/es/vef-radio/hooks/use-data-options.js +1 -41
- package/es/vef-radio/hooks/use-radio-instance.js +1 -21
- package/es/vef-radio/index.js +2 -88
- package/es/vef-rate/hooks/use-rate-instance.js +1 -14
- package/es/vef-rate/index.js +1 -31
- package/es/vef-responsive-container/index.js +2 -55
- package/es/vef-responsive-item/index.js +2 -24
- package/es/vef-ribbon/index.js +1 -39
- package/es/vef-row/index.js +1 -13
- package/es/vef-scroll-area/components/scrollbar.js +5 -33
- package/es/vef-scroll-area/index.js +3 -70
- package/es/vef-select/components/option.js +2 -23
- package/es/vef-select/hooks/use-data-options.js +1 -48
- package/es/vef-select/hooks/use-field-names.js +1 -22
- package/es/vef-select/hooks/use-render-label.js +2 -24
- package/es/vef-select/hooks/use-render-option.js +1 -20
- package/es/vef-select/hooks/use-select-instance.js +1 -21
- package/es/vef-select/index.js +1 -101
- package/es/vef-slider/hooks/use-slider-instance.js +1 -14
- package/es/vef-slider/index.js +1 -35
- package/es/vef-sortable-list/components/overlay-item.js +2 -32
- package/es/vef-sortable-list/components/sortable-item.js +2 -76
- package/es/vef-sortable-list/hooks/use-merged-items.js +1 -22
- package/es/vef-sortable-list/index.js +1 -115
- package/es/vef-space/index.js +1 -26
- package/es/vef-spin/index.js +1 -13
- package/es/vef-splitter/index.js +1 -21
- package/es/vef-splitter-panel/index.js +1 -13
- package/es/vef-status/index.js +1 -38
- package/es/vef-table/components/columns/bool.js +1 -92
- package/es/vef-table/components/columns/code.js +1 -11
- package/es/vef-table/components/columns/data-dictionary.js +1 -93
- package/es/vef-table/components/columns/enum.js +1 -102
- package/es/vef-table/components/columns/file.js +1 -11
- package/es/vef-table/components/columns/icon.js +1 -11
- package/es/vef-table/components/columns/id.js +1 -83
- package/es/vef-table/components/columns/image.js +1 -12
- package/es/vef-table/components/columns/index.js +1 -34
- package/es/vef-table/components/columns/markdown.js +1 -11
- package/es/vef-table/components/columns/number.js +1 -84
- package/es/vef-table/components/columns/render.js +1 -29
- package/es/vef-table/components/columns/rich-text.js +1 -11
- package/es/vef-table/components/columns/text.js +1 -89
- package/es/vef-table/components/columns-settings.js +2 -188
- package/es/vef-table/components/operation-buttons.js +2 -231
- package/es/vef-table/components/settings-icon.js +2 -19
- package/es/vef-table/components/table-footer.js +2 -102
- package/es/vef-table/helper.js +1 -16
- package/es/vef-table/hooks/use-computed-batch-buttons.js +1 -34
- package/es/vef-table/hooks/use-computed-columns.js +1 -21
- package/es/vef-table/hooks/use-computed-values.js +1 -39
- package/es/vef-table/hooks/use-data.js +1 -58
- package/es/vef-table/hooks/use-default-column-configs.js +1 -28
- package/es/vef-table/hooks/use-display-value.js +1 -37
- package/es/vef-table/hooks/use-helper-columns.js +1 -68
- package/es/vef-table/hooks/use-operation-column-width.js +1 -51
- package/es/vef-table/hooks/use-pagination-props.js +1 -45
- package/es/vef-table/hooks/use-row-props.js +1 -40
- package/es/vef-table/hooks/use-row-selection-config.js +1 -113
- package/es/vef-table/hooks/use-selected-rows.js +1 -27
- package/es/vef-table/hooks/use-table-columns.js +1 -57
- package/es/vef-table/hooks/use-table-context.js +1 -22
- package/es/vef-table/hooks/use-table-instance.js +1 -16
- package/es/vef-table/hooks/use-table-summary.js +1 -43
- package/es/vef-table/hooks/use-table-width.js +1 -14
- package/es/vef-table/index.js +3 -226
- package/es/vef-table/store.js +1 -18
- package/es/vef-tabs/index.js +1 -26
- package/es/vef-tag/index.js +1 -29
- package/es/vef-temporal-picker/helper.js +1 -58
- package/es/vef-temporal-picker/hooks/use-dayjs-value.js +1 -19
- package/es/vef-temporal-picker/hooks/use-temporal-limit.js +1 -35
- package/es/vef-temporal-picker/hooks/use-temporal-picker-instance.js +1 -20
- package/es/vef-temporal-picker/index.js +1 -126
- package/es/vef-temporal-range-picker/helper.js +1 -58
- package/es/vef-temporal-range-picker/hooks/use-dayjs-values.js +1 -24
- package/es/vef-temporal-range-picker/hooks/use-temporal-limit.js +1 -35
- package/es/vef-temporal-range-picker/hooks/use-temporal-range-picker-instance.js +1 -20
- package/es/vef-temporal-range-picker/index.js +1 -129
- package/es/vef-temporal-range-picker/props.js +1 -5
- package/es/vef-text/index.js +1 -81
- package/es/vef-textarea/hooks/use-textarea-instance.js +1 -14
- package/es/vef-textarea/index.js +1 -68
- package/es/vef-title/index.js +3 -87
- package/es/vef-tooltip/index.js +1 -36
- package/es/vef-tree-select/hooks/use-change-handler.js +1 -34
- package/es/vef-tree-select/hooks/use-data-options.js +1 -46
- package/es/vef-tree-select/hooks/use-tree-select-instance.js +1 -21
- package/es/vef-tree-select/index.js +1 -90
- package/es/vef-virtual-grid/index.js +3 -108
- package/es/vef-virtual-list/index.js +4 -216
- package/lib/index.cjs +1 -187
- package/lib/internal/base.css.cjs +488 -6
- package/lib/internal/chart.cjs +1 -23
- package/lib/internal/index.cjs +1 -13
- package/lib/internal/modern-normalize.css.cjs +211 -6
- package/lib/internal/utils.cjs +1 -11
- package/lib/vef-access-denied/access-denied-icon.cjs +1 -933
- package/lib/vef-access-denied/index.cjs +3 -44
- package/lib/vef-access-denied/props.cjs +1 -5
- package/lib/vef-action-buttons/index.cjs +1 -80
- package/lib/vef-action-buttons/props.cjs +1 -5
- package/lib/vef-approval-flow-editor/components/edge.cjs +2 -88
- package/lib/vef-approval-flow-editor/components/label-value.cjs +2 -26
- package/lib/vef-approval-flow-editor/components/node-content.cjs +4 -44
- package/lib/vef-approval-flow-editor/components/node-selector.cjs +2 -36
- package/lib/vef-approval-flow-editor/components/node-toolbar.cjs +1 -26
- package/lib/vef-approval-flow-editor/components/nodes/approval.cjs +1 -29
- package/lib/vef-approval-flow-editor/components/nodes/condition.cjs +1 -29
- package/lib/vef-approval-flow-editor/components/nodes/end.cjs +1 -29
- package/lib/vef-approval-flow-editor/components/nodes/handle.cjs +1 -29
- package/lib/vef-approval-flow-editor/components/nodes/index.cjs +1 -22
- package/lib/vef-approval-flow-editor/components/nodes/submit.cjs +1 -29
- package/lib/vef-approval-flow-editor/components/selector-content.cjs +3 -47
- package/lib/vef-approval-flow-editor/components/source-handle.cjs +1 -45
- package/lib/vef-approval-flow-editor/components/target-handle.cjs +1 -14
- package/lib/vef-approval-flow-editor/constants.cjs +1 -228
- package/lib/vef-approval-flow-editor/helper.cjs +1 -91
- package/lib/vef-approval-flow-editor/hooks/use-edges-interaction.cjs +1 -30
- package/lib/vef-approval-flow-editor/hooks/use-element-selection.cjs +1 -29
- package/lib/vef-approval-flow-editor/hooks/use-nodes-interaction.cjs +1 -56
- package/lib/vef-approval-flow-editor/index.cjs +1 -80
- package/lib/vef-approval-flow-editor/models/edge-node.cjs +1 -26
- package/lib/vef-approval-flow-editor/models/flow-node.cjs +1 -115
- package/lib/vef-approval-flow-editor/props.cjs +1 -5
- package/lib/vef-approval-flow-editor/store.cjs +1 -23
- package/lib/vef-approval-flow-editor/styles.cjs +3 -17
- package/lib/vef-approval-flow-editor/types.cjs +1 -21
- package/lib/vef-area-chart/index.cjs +1 -46
- package/lib/vef-area-chart/props.cjs +1 -5
- package/lib/vef-auto-sizer/index.cjs +1 -11
- package/lib/vef-auto-sizer/props.cjs +1 -5
- package/lib/vef-avatar/index.cjs +1 -25
- package/lib/vef-avatar/props.cjs +1 -5
- package/lib/vef-avatar-group/index.cjs +1 -30
- package/lib/vef-avatar-group/props.cjs +1 -5
- package/lib/vef-badge/index.cjs +1 -52
- package/lib/vef-badge/props.cjs +1 -5
- package/lib/vef-bar-chart/index.cjs +1 -46
- package/lib/vef-bar-chart/props.cjs +1 -5
- package/lib/vef-bool/hooks/use-bool-instance.cjs +1 -39
- package/lib/vef-bool/index.cjs +1 -65
- package/lib/vef-bool/props.cjs +1 -5
- package/lib/vef-breadcrumb/index.cjs +1 -53
- package/lib/vef-breadcrumb/props.cjs +1 -5
- package/lib/vef-button/components/base-button.cjs +1 -78
- package/lib/vef-button/index.cjs +1 -156
- package/lib/vef-button/props.cjs +1 -5
- package/lib/vef-card/index.cjs +1 -30
- package/lib/vef-card/props.cjs +1 -5
- package/lib/vef-card-meta/index.cjs +1 -17
- package/lib/vef-card-meta/props.cjs +1 -5
- package/lib/vef-chart-container/hooks/use-chart-container-context.cjs +1 -19
- package/lib/vef-chart-container/index.cjs +5 -76
- package/lib/vef-chart-container/props.cjs +1 -5
- package/lib/vef-chart-legend-content/index.cjs +4 -43
- package/lib/vef-chart-legend-content/props.cjs +1 -5
- package/lib/vef-chart-tooltip-content/index.cjs +9 -77
- package/lib/vef-chart-tooltip-content/props.cjs +1 -5
- package/lib/vef-checkbox/hooks/use-checkbox-instance.cjs +1 -25
- package/lib/vef-checkbox/hooks/use-data-options.cjs +1 -45
- package/lib/vef-checkbox/index.cjs +2 -92
- package/lib/vef-checkbox/props.cjs +1 -5
- package/lib/vef-col/index.cjs +1 -16
- package/lib/vef-col/props.cjs +1 -5
- package/lib/vef-color-picker/index.cjs +1 -51
- package/lib/vef-color-picker/props.cjs +1 -5
- package/lib/vef-compact/index.cjs +1 -20
- package/lib/vef-compact/props.cjs +1 -5
- package/lib/vef-config-provider/global-style.cjs +3 -17
- package/lib/vef-config-provider/hooks/use-ui-config.cjs +1 -131
- package/lib/vef-config-provider/index.cjs +3 -126
- package/lib/vef-config-provider/props.cjs +1 -5
- package/lib/vef-config-provider/store.cjs +1 -28
- package/lib/vef-container/index.cjs +1 -23
- package/lib/vef-container/props.cjs +1 -5
- package/lib/vef-crud-page/components/crud-actions.cjs +1 -37
- package/lib/vef-crud-page/components/crud-filter.cjs +1 -59
- package/lib/vef-crud-page/components/crud-footer.cjs +2 -120
- package/lib/vef-crud-page/components/crud-form-modal.cjs +1 -58
- package/lib/vef-crud-page/components/crud-header.cjs +1 -34
- package/lib/vef-crud-page/components/crud-table.cjs +1 -81
- package/lib/vef-crud-page/hooks/use-action-buttons.cjs +1 -42
- package/lib/vef-crud-page/hooks/use-crud-context.cjs +1 -25
- package/lib/vef-crud-page/hooks/use-crud-schema.cjs +1 -121
- package/lib/vef-crud-page/hooks/use-operation-buttons.cjs +1 -65
- package/lib/vef-crud-page/index.cjs +1 -155
- package/lib/vef-crud-page/props.cjs +1 -5
- package/lib/vef-crud-page/store.cjs +1 -149
- package/lib/vef-crud-page/types.cjs +1 -5
- package/lib/vef-data-grid/index.cjs +1 -90
- package/lib/vef-data-grid/props.cjs +1 -5
- package/lib/vef-data-table/index.cjs +1 -14
- package/lib/vef-data-table/props.cjs +1 -5
- package/lib/vef-divider/index.cjs +1 -29
- package/lib/vef-divider/props.cjs +1 -5
- package/lib/vef-drawer/components/action-button-wrapper.cjs +1 -54
- package/lib/vef-drawer/components/button-props.cjs +1 -5
- package/lib/vef-drawer/components/cancel-action-button.cjs +1 -26
- package/lib/vef-drawer/components/ok-action-button.cjs +1 -25
- package/lib/vef-drawer/context.cjs +1 -22
- package/lib/vef-drawer/index.cjs +2 -159
- package/lib/vef-drawer/props.cjs +1 -5
- package/lib/vef-dropdown/index.cjs +1 -97
- package/lib/vef-dropdown/props.cjs +1 -5
- package/lib/vef-dynamic-icon/index.cjs +1 -51
- package/lib/vef-dynamic-icon/props.cjs +1 -11
- package/lib/vef-empty/index.cjs +1 -42
- package/lib/vef-empty/props.cjs +1 -5
- package/lib/vef-empty-placeholder/index.cjs +2 -22
- package/lib/vef-empty-placeholder/props.cjs +1 -5
- package/lib/vef-error/error-icon.cjs +1 -762
- package/lib/vef-error/index.cjs +3 -47
- package/lib/vef-error/props.cjs +1 -5
- package/lib/vef-filter/components/action-buttons.cjs +2 -121
- package/lib/vef-filter/components/advanced-filter.cjs +3 -71
- package/lib/vef-filter/components/basic-filter.cjs +2 -38
- package/lib/vef-filter/components/fields/index.cjs +1 -24
- package/lib/vef-filter/components/fields/input-number.cjs +1 -95
- package/lib/vef-filter/components/fields/input.cjs +1 -72
- package/lib/vef-filter/components/fields/props.cjs +1 -5
- package/lib/vef-filter/components/fields/radio.cjs +1 -114
- package/lib/vef-filter/components/fields/select.cjs +1 -145
- package/lib/vef-filter/components/fields/tree-select.cjs +1 -141
- package/lib/vef-filter/components/filter-field.cjs +1 -24
- package/lib/vef-filter/components/filter-item.cjs +1 -117
- package/lib/vef-filter/event.cjs +1 -49
- package/lib/vef-filter/helper.cjs +1 -20
- package/lib/vef-filter/hooks/use-action-handlers.cjs +1 -75
- package/lib/vef-filter/hooks/use-computed-values.cjs +1 -60
- package/lib/vef-filter/hooks/use-filter-context.cjs +1 -25
- package/lib/vef-filter/hooks/use-filter-initialization.cjs +1 -42
- package/lib/vef-filter/hooks/use-filter-instance.cjs +1 -31
- package/lib/vef-filter/hooks/use-filter-items.cjs +1 -28
- package/lib/vef-filter/hooks/use-filter-values-change.cjs +1 -35
- package/lib/vef-filter/hooks/use-label-config.cjs +1 -32
- package/lib/vef-filter/index.cjs +2 -146
- package/lib/vef-filter/props.cjs +1 -5
- package/lib/vef-filter/store.cjs +1 -78
- package/lib/vef-filter/types.cjs +1 -5
- package/lib/vef-flex/index.cjs +1 -36
- package/lib/vef-flex/props.cjs +1 -5
- package/lib/vef-float-button/index.cjs +1 -54
- package/lib/vef-float-button/props.cjs +1 -5
- package/lib/vef-float-button-group/index.cjs +1 -25
- package/lib/vef-float-button-group/props.cjs +1 -5
- package/lib/vef-form/components/fields/icon-select.cjs +1 -70
- package/lib/vef-form/components/fields/index.cjs +1 -30
- package/lib/vef-form/components/fields/input-number.cjs +1 -128
- package/lib/vef-form/components/fields/input.cjs +1 -137
- package/lib/vef-form/components/fields/password.cjs +1 -120
- package/lib/vef-form/components/fields/props.cjs +1 -5
- package/lib/vef-form/components/fields/radio.cjs +1 -111
- package/lib/vef-form/components/fields/select.cjs +1 -243
- package/lib/vef-form/components/fields/textarea.cjs +1 -114
- package/lib/vef-form/components/fields/tree-select.cjs +1 -239
- package/lib/vef-form/components/form-actions.cjs +2 -62
- package/lib/vef-form/components/form-content.cjs +2 -149
- package/lib/vef-form/components/form-field.cjs +1 -27
- package/lib/vef-form/components/form-group.cjs +2 -68
- package/lib/vef-form/components/form-hidden-item.cjs +1 -41
- package/lib/vef-form/components/form-item.cjs +1 -84
- package/lib/vef-form/components/form-row.cjs +1 -103
- package/lib/vef-form/event.cjs +1 -49
- package/lib/vef-form/helper.cjs +1 -20
- package/lib/vef-form/hooks/use-action-handlers.cjs +1 -135
- package/lib/vef-form/hooks/use-columns-layout.cjs +1 -127
- package/lib/vef-form/hooks/use-computed-values.cjs +1 -60
- package/lib/vef-form/hooks/use-form-context.cjs +1 -21
- package/lib/vef-form/hooks/use-form-initialization.cjs +1 -50
- package/lib/vef-form/hooks/use-form-instance.cjs +1 -31
- package/lib/vef-form/hooks/use-form-values-change.cjs +1 -35
- package/lib/vef-form/hooks/use-label-width.cjs +1 -23
- package/lib/vef-form/index.cjs +2 -178
- package/lib/vef-form/props.cjs +1 -5
- package/lib/vef-form/store.cjs +1 -72
- package/lib/vef-form/types.cjs +1 -5
- package/lib/vef-form/validation-rules.cjs +1 -313
- package/lib/vef-form-drawer/index.cjs +1 -103
- package/lib/vef-form-drawer/props.cjs +1 -5
- package/lib/vef-form-modal/index.cjs +1 -100
- package/lib/vef-form-modal/props.cjs +1 -5
- package/lib/vef-generic-select/index.cjs +1 -86
- package/lib/vef-generic-select/props.cjs +1 -5
- package/lib/vef-grid/index.cjs +9 -79
- package/lib/vef-grid/props.cjs +1 -9
- package/lib/vef-grid-item/index.cjs +1 -57
- package/lib/vef-grid-item/props.cjs +1 -5
- package/lib/vef-icon/index.cjs +1 -55
- package/lib/vef-icon/props.cjs +1 -5
- package/lib/vef-icon-select/index.cjs +4 -144
- package/lib/vef-icon-select/props.cjs +1 -5
- package/lib/vef-input/hooks/use-input-instance.cjs +1 -20
- package/lib/vef-input/index.cjs +1 -69
- package/lib/vef-input/props.cjs +1 -5
- package/lib/vef-input-number/hooks/use-input-number-instance.cjs +1 -18
- package/lib/vef-input-number/index.cjs +1 -153
- package/lib/vef-input-number/props.cjs +1 -5
- package/lib/vef-layout/common-styles.cjs +2 -13
- package/lib/vef-layout/components/content.cjs +1 -18
- package/lib/vef-layout/components/font-size.cjs +1 -73
- package/lib/vef-layout/components/fullscreen.cjs +1 -28
- package/lib/vef-layout/components/header-action-icons.cjs +2 -30
- package/lib/vef-layout/components/header-content.cjs +1 -24
- package/lib/vef-layout/components/header.cjs +2 -70
- package/lib/vef-layout/components/icon-boy.cjs +1 -74
- package/lib/vef-layout/components/icon-girl.cjs +1 -81
- package/lib/vef-layout/components/icon-menu-fold-left.cjs +1 -28
- package/lib/vef-layout/components/icon-menu-unfold-left.cjs +1 -28
- package/lib/vef-layout/components/menu-groups.cjs +5 -118
- package/lib/vef-layout/components/message.cjs +1 -16
- package/lib/vef-layout/components/search.cjs +1 -16
- package/lib/vef-layout/components/sider.cjs +2 -56
- package/lib/vef-layout/components/title.cjs +2 -52
- package/lib/vef-layout/components/user-avatar.cjs +4 -80
- package/lib/vef-layout/hooks/use-layout-context.cjs +1 -17
- package/lib/vef-layout/index.cjs +2 -38
- package/lib/vef-layout/logo.svg.cjs +1 -9
- package/lib/vef-layout/props.cjs +1 -5
- package/lib/vef-layout/store.cjs +1 -23
- package/lib/vef-line-chart/index.cjs +1 -43
- package/lib/vef-line-chart/props.cjs +1 -5
- package/lib/vef-loading-placeholder/index.cjs +2 -44
- package/lib/vef-loading-placeholder/props.cjs +1 -5
- package/lib/vef-login/index.cjs +9 -145
- package/lib/vef-login/login-icon.cjs +1 -673
- package/lib/vef-login/props.cjs +1 -5
- package/lib/vef-menu/index.cjs +2 -80
- package/lib/vef-menu/props.cjs +1 -5
- package/lib/vef-modal/components/action-button-wrapper.cjs +1 -54
- package/lib/vef-modal/components/button-props.cjs +1 -5
- package/lib/vef-modal/components/cancel-action-button.cjs +1 -23
- package/lib/vef-modal/components/ok-action-button.cjs +1 -25
- package/lib/vef-modal/context.cjs +1 -22
- package/lib/vef-modal/index.cjs +2 -245
- package/lib/vef-modal/props.cjs +1 -5
- package/lib/vef-not-found/index.cjs +3 -44
- package/lib/vef-not-found/not-found-icon.cjs +1 -849
- package/lib/vef-not-found/props.cjs +1 -5
- package/lib/vef-page/index.cjs +2 -84
- package/lib/vef-page/props.cjs +1 -5
- package/lib/vef-pagination/index.cjs +1 -62
- package/lib/vef-pagination/props.cjs +1 -18
- package/lib/vef-paragraph/index.cjs +1 -94
- package/lib/vef-paragraph/props.cjs +1 -5
- package/lib/vef-password/hooks/use-password-instance.cjs +1 -18
- package/lib/vef-password/index.cjs +1 -72
- package/lib/vef-password/props.cjs +1 -5
- package/lib/vef-pie-chart/index.cjs +3 -70
- package/lib/vef-pie-chart/props.cjs +1 -5
- package/lib/vef-popconfirm/index.cjs +1 -61
- package/lib/vef-popconfirm/props.cjs +1 -5
- package/lib/vef-popover/index.cjs +1 -39
- package/lib/vef-popover/props.cjs +1 -5
- package/lib/vef-radio/hooks/use-data-options.cjs +1 -45
- package/lib/vef-radio/hooks/use-radio-instance.cjs +1 -25
- package/lib/vef-radio/index.cjs +2 -92
- package/lib/vef-radio/props.cjs +1 -5
- package/lib/vef-rate/hooks/use-rate-instance.cjs +1 -18
- package/lib/vef-rate/index.cjs +1 -35
- package/lib/vef-rate/props.cjs +1 -5
- package/lib/vef-responsive-container/index.cjs +2 -59
- package/lib/vef-responsive-container/props.cjs +1 -5
- package/lib/vef-responsive-item/index.cjs +2 -28
- package/lib/vef-responsive-item/props.cjs +1 -5
- package/lib/vef-ribbon/index.cjs +1 -43
- package/lib/vef-ribbon/props.cjs +1 -5
- package/lib/vef-row/index.cjs +1 -17
- package/lib/vef-row/props.cjs +1 -5
- package/lib/vef-scroll-area/components/scrollbar.cjs +5 -37
- package/lib/vef-scroll-area/index.cjs +3 -74
- package/lib/vef-scroll-area/props.cjs +1 -5
- package/lib/vef-select/components/option.cjs +2 -27
- package/lib/vef-select/hooks/use-data-options.cjs +1 -52
- package/lib/vef-select/hooks/use-field-names.cjs +1 -26
- package/lib/vef-select/hooks/use-render-label.cjs +2 -28
- package/lib/vef-select/hooks/use-render-option.cjs +1 -24
- package/lib/vef-select/hooks/use-select-instance.cjs +1 -25
- package/lib/vef-select/index.cjs +1 -105
- package/lib/vef-select/props.cjs +1 -5
- package/lib/vef-slider/hooks/use-slider-instance.cjs +1 -18
- package/lib/vef-slider/index.cjs +1 -39
- package/lib/vef-slider/props.cjs +1 -5
- package/lib/vef-sortable-list/components/overlay-item.cjs +2 -36
- package/lib/vef-sortable-list/components/sortable-item.cjs +2 -80
- package/lib/vef-sortable-list/hooks/use-merged-items.cjs +1 -26
- package/lib/vef-sortable-list/index.cjs +1 -119
- package/lib/vef-sortable-list/props.cjs +1 -5
- package/lib/vef-space/index.cjs +1 -30
- package/lib/vef-space/props.cjs +1 -5
- package/lib/vef-spin/index.cjs +1 -17
- package/lib/vef-spin/props.cjs +1 -5
- package/lib/vef-splitter/index.cjs +1 -25
- package/lib/vef-splitter/props.cjs +1 -5
- package/lib/vef-splitter-panel/index.cjs +1 -17
- package/lib/vef-splitter-panel/props.cjs +1 -5
- package/lib/vef-status/index.cjs +1 -42
- package/lib/vef-status/props.cjs +1 -5
- package/lib/vef-table/components/columns/bool.cjs +1 -96
- package/lib/vef-table/components/columns/code.cjs +1 -15
- package/lib/vef-table/components/columns/data-dictionary.cjs +1 -97
- package/lib/vef-table/components/columns/enum.cjs +1 -106
- package/lib/vef-table/components/columns/file.cjs +1 -15
- package/lib/vef-table/components/columns/icon.cjs +1 -15
- package/lib/vef-table/components/columns/id.cjs +1 -87
- package/lib/vef-table/components/columns/image.cjs +1 -16
- package/lib/vef-table/components/columns/index.cjs +1 -38
- package/lib/vef-table/components/columns/markdown.cjs +1 -15
- package/lib/vef-table/components/columns/number.cjs +1 -88
- package/lib/vef-table/components/columns/props.cjs +1 -5
- package/lib/vef-table/components/columns/render.cjs +1 -33
- package/lib/vef-table/components/columns/rich-text.cjs +1 -15
- package/lib/vef-table/components/columns/text.cjs +1 -93
- package/lib/vef-table/components/columns-settings.cjs +2 -192
- package/lib/vef-table/components/operation-buttons.cjs +2 -235
- package/lib/vef-table/components/settings-icon.cjs +2 -23
- package/lib/vef-table/components/table-footer.cjs +2 -106
- package/lib/vef-table/helper.cjs +1 -20
- package/lib/vef-table/hooks/use-computed-batch-buttons.cjs +1 -38
- package/lib/vef-table/hooks/use-computed-columns.cjs +1 -25
- package/lib/vef-table/hooks/use-computed-values.cjs +1 -43
- package/lib/vef-table/hooks/use-data.cjs +1 -62
- package/lib/vef-table/hooks/use-default-column-configs.cjs +1 -32
- package/lib/vef-table/hooks/use-display-value.cjs +1 -41
- package/lib/vef-table/hooks/use-helper-columns.cjs +1 -72
- package/lib/vef-table/hooks/use-operation-column-width.cjs +1 -55
- package/lib/vef-table/hooks/use-pagination-props.cjs +1 -49
- package/lib/vef-table/hooks/use-row-props.cjs +1 -44
- package/lib/vef-table/hooks/use-row-selection-config.cjs +1 -117
- package/lib/vef-table/hooks/use-selected-rows.cjs +1 -31
- package/lib/vef-table/hooks/use-table-columns.cjs +1 -61
- package/lib/vef-table/hooks/use-table-context.cjs +1 -28
- package/lib/vef-table/hooks/use-table-instance.cjs +1 -20
- package/lib/vef-table/hooks/use-table-summary.cjs +1 -47
- package/lib/vef-table/hooks/use-table-width.cjs +1 -18
- package/lib/vef-table/index.cjs +3 -230
- package/lib/vef-table/props.cjs +1 -5
- package/lib/vef-table/store.cjs +1 -24
- package/lib/vef-table/types.cjs +1 -5
- package/lib/vef-tabs/index.cjs +1 -30
- package/lib/vef-tabs/props.cjs +1 -5
- package/lib/vef-tag/index.cjs +1 -33
- package/lib/vef-tag/props.cjs +1 -5
- package/lib/vef-temporal-picker/helper.cjs +1 -62
- package/lib/vef-temporal-picker/hooks/use-dayjs-value.cjs +1 -23
- package/lib/vef-temporal-picker/hooks/use-temporal-limit.cjs +1 -39
- package/lib/vef-temporal-picker/hooks/use-temporal-picker-instance.cjs +1 -24
- package/lib/vef-temporal-picker/index.cjs +1 -130
- package/lib/vef-temporal-picker/props.cjs +1 -5
- package/lib/vef-temporal-range-picker/helper.cjs +1 -62
- package/lib/vef-temporal-range-picker/hooks/use-dayjs-values.cjs +1 -28
- package/lib/vef-temporal-range-picker/hooks/use-temporal-limit.cjs +1 -39
- package/lib/vef-temporal-range-picker/hooks/use-temporal-range-picker-instance.cjs +1 -24
- package/lib/vef-temporal-range-picker/index.cjs +1 -133
- package/lib/vef-temporal-range-picker/props.cjs +1 -9
- package/lib/vef-text/index.cjs +1 -85
- package/lib/vef-text/props.cjs +1 -5
- package/lib/vef-textarea/hooks/use-textarea-instance.cjs +1 -18
- package/lib/vef-textarea/index.cjs +1 -72
- package/lib/vef-textarea/props.cjs +1 -5
- package/lib/vef-title/index.cjs +3 -91
- package/lib/vef-title/props.cjs +1 -5
- package/lib/vef-tooltip/index.cjs +1 -40
- package/lib/vef-tooltip/props.cjs +1 -5
- package/lib/vef-tree-select/hooks/use-change-handler.cjs +1 -38
- package/lib/vef-tree-select/hooks/use-data-options.cjs +1 -50
- package/lib/vef-tree-select/hooks/use-tree-select-instance.cjs +1 -25
- package/lib/vef-tree-select/index.cjs +1 -94
- package/lib/vef-tree-select/props.cjs +1 -5
- package/lib/vef-virtual-grid/index.cjs +3 -112
- package/lib/vef-virtual-grid/props.cjs +1 -5
- package/lib/vef-virtual-list/index.cjs +4 -220
- package/lib/vef-virtual-list/props.cjs +1 -5
- package/package.json +4 -4
|
@@ -1,131 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { useApiContext } from '@vef-framework/core';
|
|
3
|
-
import { isFunction, VefError, showLoadingMessage, omit, showSuccessMessage } from '@vef-framework/shared';
|
|
4
|
-
import { useCallback, useMemo } from 'react';
|
|
5
|
-
import { useFormStore } from '../store.js';
|
|
6
|
-
|
|
7
|
-
function useActionHandlers({
|
|
8
|
-
submitApi,
|
|
9
|
-
submitTip = "提交中...",
|
|
10
|
-
onBeforeSubmit,
|
|
11
|
-
onSubmit,
|
|
12
|
-
onSubmitSuccess,
|
|
13
|
-
onSubmitFailure,
|
|
14
|
-
onReset
|
|
15
|
-
}) {
|
|
16
|
-
const [
|
|
17
|
-
form,
|
|
18
|
-
scene,
|
|
19
|
-
eventBus,
|
|
20
|
-
setIsLoading,
|
|
21
|
-
virtualFieldNames,
|
|
22
|
-
getValues,
|
|
23
|
-
initialValues,
|
|
24
|
-
invokeValueChangeHandlers
|
|
25
|
-
] = useFormStore((state) => [
|
|
26
|
-
state.form,
|
|
27
|
-
state.scene,
|
|
28
|
-
state.eventBus,
|
|
29
|
-
state.setIsLoading,
|
|
30
|
-
state.virtualFieldNames,
|
|
31
|
-
state.getValues,
|
|
32
|
-
state.initialValues,
|
|
33
|
-
state.invokeValueChangeHandlers
|
|
34
|
-
]);
|
|
35
|
-
const { useApiMutation, stubMutationApi } = useApiContext();
|
|
36
|
-
const { mutate } = useApiMutation(submitApi ?? stubMutationApi);
|
|
37
|
-
if (!isFunction(onSubmit) && !submitApi) {
|
|
38
|
-
throw new VefError(-1, "'onSubmit' or 'submitApi' prop is required for VefForm component");
|
|
39
|
-
}
|
|
40
|
-
const handleReset = useCallback(() => {
|
|
41
|
-
const values = getValues();
|
|
42
|
-
form.resetFields();
|
|
43
|
-
invokeValueChangeHandlers();
|
|
44
|
-
eventBus.emitChange(initialValues);
|
|
45
|
-
onReset?.(values, scene);
|
|
46
|
-
}, [
|
|
47
|
-
form,
|
|
48
|
-
getValues,
|
|
49
|
-
onReset,
|
|
50
|
-
scene,
|
|
51
|
-
invokeValueChangeHandlers,
|
|
52
|
-
initialValues,
|
|
53
|
-
eventBus
|
|
54
|
-
]);
|
|
55
|
-
const handleSubmit = useMemo(() => {
|
|
56
|
-
if (isFunction(onSubmit)) {
|
|
57
|
-
if (submitApi) {
|
|
58
|
-
console.warn("'submitApi' prop is ignored when 'onSubmit' prop is provided in VefForm component");
|
|
59
|
-
}
|
|
60
|
-
return async (values) => {
|
|
61
|
-
setIsLoading(true);
|
|
62
|
-
let valuesToUse = values;
|
|
63
|
-
let closeLoading = null;
|
|
64
|
-
try {
|
|
65
|
-
const submitTipToUse = isFunction(submitTip) ? submitTip(values, scene) : submitTip;
|
|
66
|
-
closeLoading = showLoadingMessage(submitTipToUse);
|
|
67
|
-
if (isFunction(onBeforeSubmit)) {
|
|
68
|
-
valuesToUse = await onBeforeSubmit(valuesToUse, scene);
|
|
69
|
-
}
|
|
70
|
-
const valuesToSubmit = omit(valuesToUse, virtualFieldNames);
|
|
71
|
-
await onSubmit(valuesToSubmit, scene);
|
|
72
|
-
eventBus.emitSubmitResult(true);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
eventBus.emitSubmitResult(false);
|
|
75
|
-
throw error;
|
|
76
|
-
} finally {
|
|
77
|
-
setIsLoading(false);
|
|
78
|
-
closeLoading?.();
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return async (values) => {
|
|
83
|
-
setIsLoading(true);
|
|
84
|
-
let valuesToUse = values;
|
|
85
|
-
let closeLoading = null;
|
|
86
|
-
try {
|
|
87
|
-
const submitTipToUse = isFunction(submitTip) ? submitTip(values, scene) : submitTip;
|
|
88
|
-
closeLoading = showLoadingMessage(submitTipToUse);
|
|
89
|
-
if (isFunction(onBeforeSubmit)) {
|
|
90
|
-
valuesToUse = await onBeforeSubmit(values, scene);
|
|
91
|
-
}
|
|
92
|
-
const toSubmitValues = omit(valuesToUse, virtualFieldNames);
|
|
93
|
-
const apiResponse = await mutate(toSubmitValues);
|
|
94
|
-
(onSubmitSuccess ?? (({ message }) => {
|
|
95
|
-
showSuccessMessage(message);
|
|
96
|
-
}))(apiResponse, valuesToUse, scene);
|
|
97
|
-
eventBus.emitSubmitResult(true);
|
|
98
|
-
} catch (error) {
|
|
99
|
-
eventBus.emitSubmitResult(false);
|
|
100
|
-
onSubmitFailure?.(error, valuesToUse, scene);
|
|
101
|
-
} finally {
|
|
102
|
-
setIsLoading(false);
|
|
103
|
-
closeLoading?.();
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}, [
|
|
107
|
-
onSubmit,
|
|
108
|
-
submitApi,
|
|
109
|
-
setIsLoading,
|
|
110
|
-
submitTip,
|
|
111
|
-
scene,
|
|
112
|
-
onBeforeSubmit,
|
|
113
|
-
virtualFieldNames,
|
|
114
|
-
eventBus,
|
|
115
|
-
mutate,
|
|
116
|
-
onSubmitSuccess,
|
|
117
|
-
onSubmitFailure
|
|
118
|
-
]);
|
|
119
|
-
const handleSubmitFailed = useCallback(({ values, errorFields }) => {
|
|
120
|
-
eventBus.emitSubmitResult(false);
|
|
121
|
-
onSubmitFailure?.(new VefError(-1, errorFields.flatMap((field) => field.errors).join(", ")), values, scene);
|
|
122
|
-
}, [eventBus, onSubmitFailure, scene]);
|
|
123
|
-
return {
|
|
124
|
-
handleReset,
|
|
125
|
-
handleSubmit,
|
|
126
|
-
handleSubmitFailed
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export { useActionHandlers };
|
|
131
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.787Z, made by Venus. */import{useApiContext}from"@vef-framework/core";import{isFunction,VefError,showLoadingMessage,omit,showSuccessMessage}from"@vef-framework/shared";import{useCallback,useMemo}from"react";import{useFormStore}from"../store.js";function useActionHandlers({submitApi,submitTip="提交中...",onBeforeSubmit,onSubmit,onSubmitSuccess,onSubmitFailure,onReset}){const[form,scene,eventBus,setIsLoading,virtualFieldNames,getValues,initialValues,invokeValueChangeHandlers]=useFormStore(state=>[state.form,state.scene,state.eventBus,state.setIsLoading,state.virtualFieldNames,state.getValues,state.initialValues,state.invokeValueChangeHandlers]),{useApiMutation,stubMutationApi}=useApiContext(),{mutate}=useApiMutation(submitApi??stubMutationApi);if(!isFunction(onSubmit)&&!submitApi)throw new VefError(-1,"'onSubmit' or 'submitApi' prop is required for VefForm component");const handleReset=useCallback(()=>{const values=getValues();form.resetFields(),invokeValueChangeHandlers(),eventBus.emitChange(initialValues),onReset?.(values,scene)},[form,getValues,onReset,scene,invokeValueChangeHandlers,initialValues,eventBus]),handleSubmit=useMemo(()=>isFunction(onSubmit)?(submitApi&&console.warn("'submitApi' prop is ignored when 'onSubmit' prop is provided in VefForm component"),async values=>{setIsLoading(!0);let valuesToUse=values,closeLoading=null;try{const submitTipToUse=isFunction(submitTip)?submitTip(values,scene):submitTip;closeLoading=showLoadingMessage(submitTipToUse),isFunction(onBeforeSubmit)&&(valuesToUse=await onBeforeSubmit(valuesToUse,scene));const valuesToSubmit=omit(valuesToUse,virtualFieldNames);await onSubmit(valuesToSubmit,scene),eventBus.emitSubmitResult(!0)}catch(error){throw eventBus.emitSubmitResult(!1),error}finally{setIsLoading(!1),closeLoading?.()}}):async values=>{setIsLoading(!0);let valuesToUse=values,closeLoading=null;try{const submitTipToUse=isFunction(submitTip)?submitTip(values,scene):submitTip;closeLoading=showLoadingMessage(submitTipToUse),isFunction(onBeforeSubmit)&&(valuesToUse=await onBeforeSubmit(values,scene));const toSubmitValues=omit(valuesToUse,virtualFieldNames),apiResponse=await mutate(toSubmitValues);(onSubmitSuccess??(({message})=>{showSuccessMessage(message)}))(apiResponse,valuesToUse,scene),eventBus.emitSubmitResult(!0)}catch(error){eventBus.emitSubmitResult(!1),onSubmitFailure?.(error,valuesToUse,scene)}finally{setIsLoading(!1),closeLoading?.()}},[onSubmit,submitApi,setIsLoading,submitTip,scene,onBeforeSubmit,virtualFieldNames,eventBus,mutate,onSubmitSuccess,onSubmitFailure]),handleSubmitFailed=useCallback(({values,errorFields})=>{eventBus.emitSubmitResult(!1),onSubmitFailure?.(new VefError(-1,errorFields.flatMap(field=>field.errors).join(", ")),values,scene)},[eventBus,onSubmitFailure,scene]);return{handleReset,handleSubmit,handleSubmitFailed}}/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */export{useActionHandlers};
|
|
@@ -1,123 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { unique, VefError } from '@vef-framework/shared';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
const MAX_SPANS = 24;
|
|
6
|
-
const SPAN_BASES = [
|
|
7
|
-
{
|
|
8
|
-
breakpoint: "xs",
|
|
9
|
-
base: MAX_SPANS,
|
|
10
|
-
spans: 1
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
breakpoint: "sm",
|
|
14
|
-
base: MAX_SPANS / 2,
|
|
15
|
-
spans: 2
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
breakpoint: "md",
|
|
19
|
-
base: MAX_SPANS / 3,
|
|
20
|
-
spans: 3
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
breakpoint: "lg",
|
|
24
|
-
base: MAX_SPANS / 4,
|
|
25
|
-
spans: 4
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
breakpoint: "xl",
|
|
29
|
-
base: MAX_SPANS / 4,
|
|
30
|
-
spans: 4
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
breakpoint: "xxl",
|
|
34
|
-
base: MAX_SPANS / 6,
|
|
35
|
-
spans: 6
|
|
36
|
-
}
|
|
37
|
-
];
|
|
38
|
-
const ALLOWED_SPANS = unique(SPAN_BASES.map((item) => item.spans));
|
|
39
|
-
function calculateResponsiveLayout(rowKey, columns, autoExpand) {
|
|
40
|
-
const totalSpans = columns.reduce((acc, column) => acc + (column.span ?? 1), 0);
|
|
41
|
-
if (!ALLOWED_SPANS.includes(totalSpans)) {
|
|
42
|
-
throw new VefError(-3, `The total spans of the columns of the row [${rowKey}] must be one of the following: ${ALLOWED_SPANS.join(", ")}.`);
|
|
43
|
-
}
|
|
44
|
-
const requiredBase = 24 / totalSpans;
|
|
45
|
-
const layout = {};
|
|
46
|
-
for (const {
|
|
47
|
-
breakpoint,
|
|
48
|
-
base,
|
|
49
|
-
spans
|
|
50
|
-
} of SPAN_BASES) {
|
|
51
|
-
if (requiredBase >= base) {
|
|
52
|
-
layout[breakpoint] = columns.reduce((acc, column) => {
|
|
53
|
-
acc[column.key] = (column.span ?? 1) * requiredBase;
|
|
54
|
-
return acc;
|
|
55
|
-
}, {});
|
|
56
|
-
} else {
|
|
57
|
-
const map = {};
|
|
58
|
-
let remainingSpans = spans;
|
|
59
|
-
let lastColumnKey = null;
|
|
60
|
-
for (const column of columns) {
|
|
61
|
-
const requiredSpan = column.span ?? 1;
|
|
62
|
-
if (remainingSpans >= requiredSpan) {
|
|
63
|
-
map[column.key] = requiredSpan * base;
|
|
64
|
-
remainingSpans -= requiredSpan;
|
|
65
|
-
lastColumnKey = column.key;
|
|
66
|
-
} else {
|
|
67
|
-
if (lastColumnKey) {
|
|
68
|
-
if (autoExpand) {
|
|
69
|
-
map[lastColumnKey] += remainingSpans * base;
|
|
70
|
-
}
|
|
71
|
-
remainingSpans = spans;
|
|
72
|
-
lastColumnKey = null;
|
|
73
|
-
}
|
|
74
|
-
if (requiredSpan > spans) {
|
|
75
|
-
map[column.key] = 24;
|
|
76
|
-
} else {
|
|
77
|
-
map[column.key] = requiredSpan * base;
|
|
78
|
-
remainingSpans -= requiredSpan;
|
|
79
|
-
lastColumnKey = column.key;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (remainingSpans === 0) {
|
|
83
|
-
remainingSpans = spans;
|
|
84
|
-
lastColumnKey = null;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (remainingSpans > 0) {
|
|
88
|
-
if (autoExpand) {
|
|
89
|
-
map[lastColumnKey] += remainingSpans * base;
|
|
90
|
-
}
|
|
91
|
-
lastColumnKey = null;
|
|
92
|
-
}
|
|
93
|
-
layout[breakpoint] = map;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return layout;
|
|
97
|
-
}
|
|
98
|
-
function calculateFixedLayout(rowKey, columns) {
|
|
99
|
-
const totalSpans = columns.reduce((acc, column) => acc + (column.span ?? 1), 0);
|
|
100
|
-
if (totalSpans > MAX_SPANS || MAX_SPANS % totalSpans !== 0) {
|
|
101
|
-
throw new VefError(-3, `The total spans of the columns of the row [${rowKey}] must be less than or equal to ${MAX_SPANS} and a divisor of ${MAX_SPANS}.`);
|
|
102
|
-
}
|
|
103
|
-
const base = MAX_SPANS / totalSpans;
|
|
104
|
-
return columns.reduce((acc, column) => {
|
|
105
|
-
acc[column.key] = (column.span ?? 1) * base;
|
|
106
|
-
return acc;
|
|
107
|
-
}, {});
|
|
108
|
-
}
|
|
109
|
-
function useColumnsLayout(rowKey, columns, layoutMode, autoExpand) {
|
|
110
|
-
return useMemo(() => {
|
|
111
|
-
if (columns.length === 0) {
|
|
112
|
-
return {};
|
|
113
|
-
}
|
|
114
|
-
if (layoutMode === "responsive") {
|
|
115
|
-
return calculateResponsiveLayout(rowKey, columns, autoExpand);
|
|
116
|
-
} else {
|
|
117
|
-
return calculateFixedLayout(rowKey, columns);
|
|
118
|
-
}
|
|
119
|
-
}, []);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export { useColumnsLayout };
|
|
123
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.787Z, made by Venus. */import{unique,VefError}from"@vef-framework/shared";import{useMemo}from"react";const MAX_SPANS=24,SPAN_BASES=[{breakpoint:"xs",base:MAX_SPANS,spans:1},{breakpoint:"sm",base:MAX_SPANS/2,spans:2},{breakpoint:"md",base:MAX_SPANS/3,spans:3},{breakpoint:"lg",base:MAX_SPANS/4,spans:4},{breakpoint:"xl",base:MAX_SPANS/4,spans:4},{breakpoint:"xxl",base:MAX_SPANS/6,spans:6}],ALLOWED_SPANS=unique(SPAN_BASES.map(item=>item.spans));function calculateResponsiveLayout(rowKey,columns,autoExpand){const totalSpans=columns.reduce((acc,column)=>acc+(column.span??1),0);if(!ALLOWED_SPANS.includes(totalSpans))throw new VefError(-3,`The total spans of the columns of the row [${rowKey}] must be one of the following: ${ALLOWED_SPANS.join(", ")}.`);const requiredBase=24/totalSpans,layout={};for(const{breakpoint,base,spans}of SPAN_BASES)if(requiredBase>=base)layout[breakpoint]=columns.reduce((acc,column)=>(acc[column.key]=(column.span??1)*requiredBase,acc),{});else{const map={};let remainingSpans=spans,lastColumnKey=null;for(const column of columns){const requiredSpan=column.span??1;remainingSpans>=requiredSpan?(map[column.key]=requiredSpan*base,remainingSpans-=requiredSpan,lastColumnKey=column.key):(lastColumnKey&&(autoExpand&&(map[lastColumnKey]+=remainingSpans*base),remainingSpans=spans,lastColumnKey=null),requiredSpan>spans?map[column.key]=24:(map[column.key]=requiredSpan*base,remainingSpans-=requiredSpan,lastColumnKey=column.key)),remainingSpans===0&&(remainingSpans=spans,lastColumnKey=null)}remainingSpans>0&&(autoExpand&&(map[lastColumnKey]+=remainingSpans*base),lastColumnKey=null),layout[breakpoint]=map}return layout}function calculateFixedLayout(rowKey,columns){const totalSpans=columns.reduce((acc,column)=>acc+(column.span??1),0);if(totalSpans>MAX_SPANS||MAX_SPANS%totalSpans!==0)throw new VefError(-3,`The total spans of the columns of the row [${rowKey}] must be less than or equal to ${MAX_SPANS} and a divisor of ${MAX_SPANS}.`);const base=MAX_SPANS/totalSpans;return columns.reduce((acc,column)=>(acc[column.key]=(column.span??1)*base,acc),{})}function useColumnsLayout(rowKey,columns,layoutMode,autoExpand){return useMemo(()=>columns.length===0?{}:layoutMode==="responsive"?calculateResponsiveLayout(rowKey,columns,autoExpand):calculateFixedLayout(rowKey,columns),[])}/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */export{useColumnsLayout};
|
|
@@ -1,56 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { useUpdater, useDeepMemo, useDeepLayoutEffect } from '@vef-framework/hooks';
|
|
3
|
-
import { isFunctionOrExpression, isDeepEqual } from '@vef-framework/shared';
|
|
4
|
-
import { computeValue } from '../helper.js';
|
|
5
|
-
import { useFormStore } from '../store.js';
|
|
6
|
-
|
|
7
|
-
function useComputedValues(values, returnAsObject = false) {
|
|
8
|
-
const [scene, eventBus, getValues] = useFormStore((state) => [state.scene, state.eventBus, state.getValues]);
|
|
9
|
-
const forceUpdate = useUpdater();
|
|
10
|
-
const currentValues = getValues();
|
|
11
|
-
const computedValues = useDeepMemo(() => values.reduce((acc, it) => {
|
|
12
|
-
const {
|
|
13
|
-
key,
|
|
14
|
-
rawValue,
|
|
15
|
-
defaultValue
|
|
16
|
-
} = it;
|
|
17
|
-
const computedValue = computeValue(rawValue, currentValues, scene, defaultValue);
|
|
18
|
-
acc[key] = computedValue;
|
|
19
|
-
return acc;
|
|
20
|
-
}, {}), [currentValues, scene, values]);
|
|
21
|
-
useDeepLayoutEffect(() => {
|
|
22
|
-
const realComputedValues = values.filter(({ rawValue }) => isFunctionOrExpression(rawValue));
|
|
23
|
-
const shouldListenChangeEvent = realComputedValues.length > 0;
|
|
24
|
-
if (shouldListenChangeEvent) {
|
|
25
|
-
const handleChange = (newValues) => {
|
|
26
|
-
for (const value of realComputedValues) {
|
|
27
|
-
const {
|
|
28
|
-
key,
|
|
29
|
-
rawValue,
|
|
30
|
-
defaultValue
|
|
31
|
-
} = value;
|
|
32
|
-
const computedValue = computedValues[key];
|
|
33
|
-
const refreshedValue = computeValue(rawValue, newValues, scene, defaultValue);
|
|
34
|
-
if (!isDeepEqual(refreshedValue, computedValue)) {
|
|
35
|
-
forceUpdate();
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
eventBus.onChange(handleChange);
|
|
41
|
-
return () => {
|
|
42
|
-
eventBus.offChange(handleChange);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}, [computedValues, eventBus, forceUpdate, scene, values]);
|
|
46
|
-
if (returnAsObject) {
|
|
47
|
-
return values.reduce((acc, { key }) => {
|
|
48
|
-
acc[key] = computedValues[key];
|
|
49
|
-
return acc;
|
|
50
|
-
}, {});
|
|
51
|
-
}
|
|
52
|
-
return values.map(({ key }) => computedValues[key]);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export { useComputedValues };
|
|
56
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.787Z, made by Venus. */import{useUpdater,useDeepMemo,useDeepLayoutEffect}from"@vef-framework/hooks";import{isFunctionOrExpression,isDeepEqual}from"@vef-framework/shared";import{computeValue}from"../helper.js";import{useFormStore}from"../store.js";function useComputedValues(values,returnAsObject=!1){const[scene,eventBus,getValues]=useFormStore(state=>[state.scene,state.eventBus,state.getValues]),forceUpdate=useUpdater(),currentValues=getValues(),computedValues=useDeepMemo(()=>values.reduce((acc,it)=>{const{key,rawValue,defaultValue}=it,computedValue=computeValue(rawValue,currentValues,scene,defaultValue);return acc[key]=computedValue,acc},{}),[currentValues,scene,values]);return useDeepLayoutEffect(()=>{const realComputedValues=values.filter(({rawValue})=>isFunctionOrExpression(rawValue));if(realComputedValues.length>0){const handleChange=newValues=>{for(const value of realComputedValues){const{key,rawValue,defaultValue}=value,computedValue=computedValues[key],refreshedValue=computeValue(rawValue,newValues,scene,defaultValue);if(!isDeepEqual(refreshedValue,computedValue)){forceUpdate();break}}};return eventBus.onChange(handleChange),()=>{eventBus.offChange(handleChange)}}},[computedValues,eventBus,forceUpdate,scene,values]),returnAsObject?values.reduce((acc,{key})=>(acc[key]=computedValues[key],acc),{}):values.map(({key})=>computedValues[key])}/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */export{useComputedValues};
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { createSelectableContext } from '@vef-framework/shared';
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
useContextSelector: useFormContextSelector,
|
|
6
|
-
useContext: useFormContext,
|
|
7
|
-
ContextProvider: FormContextProvider
|
|
8
|
-
} = createSelectableContext({
|
|
9
|
-
autoExpand: true,
|
|
10
|
-
labelPosition: "top",
|
|
11
|
-
layoutMode: "responsive"
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export { FormContextProvider, useFormContext, useFormContextSelector };
|
|
15
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.787Z, made by Venus. */import{createSelectableContext}from"@vef-framework/shared";const{useContextSelector:useFormContextSelector,useContext:useFormContext,ContextProvider:FormContextProvider}=createSelectableContext({autoExpand:!0,labelPosition:"top",layoutMode:"responsive"});/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */export{FormContextProvider,useFormContext,useFormContextSelector};
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { isNullish, isFunction } from '@vef-framework/shared';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
function useFormInitialization(schema, initialValues) {
|
|
6
|
-
return useMemo(() => {
|
|
7
|
-
const mergedInitialValues = {
|
|
8
|
-
...initialValues
|
|
9
|
-
};
|
|
10
|
-
const valueChangeHandlers = {};
|
|
11
|
-
const virtualFieldNames = [];
|
|
12
|
-
for (const group of schema) {
|
|
13
|
-
const { rows } = group;
|
|
14
|
-
for (const row of rows) {
|
|
15
|
-
const { columns } = row;
|
|
16
|
-
for (const column of columns) {
|
|
17
|
-
const { items } = column;
|
|
18
|
-
for (const item of items) {
|
|
19
|
-
const {
|
|
20
|
-
name,
|
|
21
|
-
defaultValue,
|
|
22
|
-
virtual
|
|
23
|
-
} = item;
|
|
24
|
-
if (!isNullish(defaultValue) && isNullish(mergedInitialValues[name])) {
|
|
25
|
-
mergedInitialValues[name] = defaultValue;
|
|
26
|
-
}
|
|
27
|
-
if (item.type !== "Hidden" && isFunction(item.onChange)) {
|
|
28
|
-
valueChangeHandlers[name] = item.onChange;
|
|
29
|
-
}
|
|
30
|
-
if (virtual === true) {
|
|
31
|
-
virtualFieldNames.push(name);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
mergedInitialValues,
|
|
39
|
-
valueChangeHandlers,
|
|
40
|
-
virtualFieldNames
|
|
41
|
-
};
|
|
42
|
-
}, []);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { useFormInitialization };
|
|
46
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.787Z, made by Venus. */import{isNullish,isFunction}from"@vef-framework/shared";import{useMemo}from"react";function useFormInitialization(schema,initialValues){return useMemo(()=>{const mergedInitialValues={...initialValues},valueChangeHandlers={},virtualFieldNames=[];for(const group of schema){const{rows}=group;for(const row of rows){const{columns}=row;for(const column of columns){const{items}=column;for(const item of items){const{name,defaultValue,virtual}=item;!isNullish(defaultValue)&&isNullish(mergedInitialValues[name])&&(mergedInitialValues[name]=defaultValue),item.type!=="Hidden"&&isFunction(item.onChange)&&(valueChangeHandlers[name]=item.onChange),virtual===!0&&virtualFieldNames.push(name)}}}}return{mergedInitialValues,valueChangeHandlers,virtualFieldNames}},[])}/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */export{useFormInitialization};
|
|
@@ -1,27 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { useImperativeHandle } from 'react';
|
|
3
|
-
import { useFormStore } from '../store.js';
|
|
4
|
-
|
|
5
|
-
function useFormInstance(ref, reset) {
|
|
6
|
-
const [form, eventBus, getValues, setValues] = useFormStore((state) => [state.form, state.eventBus, state.getValues, state.setValues]);
|
|
7
|
-
useImperativeHandle(ref, () => ({
|
|
8
|
-
submit: () => new Promise((resolve, reject) => {
|
|
9
|
-
const handleResult = (result) => {
|
|
10
|
-
eventBus.offSubmitResult(handleResult);
|
|
11
|
-
if (result) {
|
|
12
|
-
resolve();
|
|
13
|
-
} else {
|
|
14
|
-
reject(result);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
eventBus.onSubmitResult(handleResult);
|
|
18
|
-
form.submit();
|
|
19
|
-
}),
|
|
20
|
-
reset,
|
|
21
|
-
getValues,
|
|
22
|
-
setValues
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { useFormInstance };
|
|
27
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.787Z, made by Venus. */import{useImperativeHandle}from"react";import{useFormStore}from"../store.js";function useFormInstance(ref,reset){const[form,eventBus,getValues,setValues]=useFormStore(state=>[state.form,state.eventBus,state.getValues,state.setValues]);useImperativeHandle(ref,()=>({submit:()=>new Promise((resolve,reject)=>{const handleResult=result=>{eventBus.offSubmitResult(handleResult),result?resolve():reject(result)};eventBus.onSubmitResult(handleResult),form.submit()}),reset,getValues,setValues}))}/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */export{useFormInstance};
|
|
@@ -1,31 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { isFunction } from '@vef-framework/shared';
|
|
3
|
-
import { useMemo, useEffect, useLayoutEffect } from 'react';
|
|
4
|
-
import { useFormStore } from '../store.js';
|
|
5
|
-
|
|
6
|
-
function useFormValuesChange(onChange) {
|
|
7
|
-
const [scene, eventBus, invokeValueChangeHandlers] = useFormStore((state) => [state.scene, state.eventBus, state.invokeValueChangeHandlers]);
|
|
8
|
-
const handleValuesChange = useMemo(() => (_, values) => {
|
|
9
|
-
eventBus.emitChange(values);
|
|
10
|
-
}, [eventBus]);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (isFunction(onChange)) {
|
|
13
|
-
const handleChange = (values) => {
|
|
14
|
-
onChange(values, scene);
|
|
15
|
-
};
|
|
16
|
-
eventBus.onChange(handleChange);
|
|
17
|
-
return () => {
|
|
18
|
-
eventBus.offChange(handleChange);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}, [eventBus, onChange, scene]);
|
|
22
|
-
useLayoutEffect(() => {
|
|
23
|
-
invokeValueChangeHandlers();
|
|
24
|
-
}, []);
|
|
25
|
-
return {
|
|
26
|
-
handleValuesChange
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { useFormValuesChange };
|
|
31
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.787Z, made by Venus. */import{isFunction}from"@vef-framework/shared";import{useMemo,useEffect,useLayoutEffect}from"react";import{useFormStore}from"../store.js";function useFormValuesChange(onChange){const[scene,eventBus,invokeValueChangeHandlers]=useFormStore(state=>[state.scene,state.eventBus,state.invokeValueChangeHandlers]),handleValuesChange=useMemo(()=>(_,values)=>{eventBus.emitChange(values)},[eventBus]);return useEffect(()=>{if(isFunction(onChange)){const handleChange=values=>{onChange(values,scene)};return eventBus.onChange(handleChange),()=>{eventBus.offChange(handleChange)}}},[eventBus,onChange,scene]),useLayoutEffect(()=>{invokeValueChangeHandlers()},[]),{handleValuesChange}}/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */export{useFormValuesChange};
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { showWarningMessage } from '@vef-framework/shared';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
function useLabelWidth(labelPosition, labelWidth) {
|
|
6
|
-
const labelWidthToUse = useMemo(() => {
|
|
7
|
-
if (labelPosition === "top" || !labelWidth) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
if (labelWidth < 60 || labelWidth > 120) {
|
|
11
|
-
showWarningMessage("The labelWidth of VefForm component must be between 60 and 120, otherwise it will be 60 or 120.");
|
|
12
|
-
}
|
|
13
|
-
return Math.min(Math.max(labelWidth, 60), 120);
|
|
14
|
-
}, [labelPosition, labelWidth]);
|
|
15
|
-
return labelWidthToUse;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { useLabelWidth };
|
|
19
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.787Z, made by Venus. */import{showWarningMessage}from"@vef-framework/shared";import{useMemo}from"react";function useLabelWidth(labelPosition,labelWidth){return useMemo(()=>{if(!(labelPosition==="top"||!labelWidth))return(labelWidth<60||labelWidth>120)&&showWarningMessage("The labelWidth of VefForm component must be between 60 and 120, otherwise it will be 60 or 120."),Math.min(Math.max(labelWidth,60),120)},[labelPosition,labelWidth])}/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */export{useLabelWidth};
|
package/es/vef-form/index.js
CHANGED
|
@@ -1,175 +1,3 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
-
import { useContextDisabled, useSingleton, useUnmount } from '@vef-framework/hooks';
|
|
5
|
-
import { isNumber, isDeepEqual, omit } from '@vef-framework/shared';
|
|
6
|
-
import { Form } from 'antd';
|
|
7
|
-
import { useMemo, forwardRef, memo } from 'react';
|
|
8
|
-
import '../internal/index.js';
|
|
9
|
-
import VefFormActions from './components/form-actions.js';
|
|
10
|
-
import VefFormContent from './components/form-content.js';
|
|
11
|
-
import { FormEventBus } from './event.js';
|
|
12
|
-
import { useActionHandlers } from './hooks/use-action-handlers.js';
|
|
13
|
-
import { useFormContextSelector, FormContextProvider } from './hooks/use-form-context.js';
|
|
14
|
-
import { useFormInitialization } from './hooks/use-form-initialization.js';
|
|
15
|
-
import { useFormInstance } from './hooks/use-form-instance.js';
|
|
16
|
-
import { useFormValuesChange } from './hooks/use-form-values-change.js';
|
|
17
|
-
import { useLabelWidth } from './hooks/use-label-width.js';
|
|
18
|
-
import { useFormStore, FormStoreProvider } from './store.js';
|
|
19
|
-
import { convertBasicSizeToUiSize } from '../internal/utils.js';
|
|
20
|
-
|
|
21
|
-
const { useForm } = Form;
|
|
22
|
-
const scrollToFirstErrorOptions = {
|
|
23
|
-
scrollMode: "if-needed",
|
|
24
|
-
behavior: "smooth"
|
|
25
|
-
};
|
|
26
|
-
function VefFormBase({
|
|
27
|
-
schema,
|
|
28
|
-
labelAlign = "right",
|
|
29
|
-
variant,
|
|
30
|
-
showTabs = false,
|
|
31
|
-
height = "auto",
|
|
32
|
-
size,
|
|
33
|
-
disabled = false,
|
|
34
|
-
onChange,
|
|
35
|
-
submissionButton,
|
|
36
|
-
resetButton,
|
|
37
|
-
submitApi,
|
|
38
|
-
submitTip,
|
|
39
|
-
onBeforeSubmit,
|
|
40
|
-
onSubmit,
|
|
41
|
-
onSubmitSuccess,
|
|
42
|
-
onSubmitFailure,
|
|
43
|
-
onReset
|
|
44
|
-
}, ref) {
|
|
45
|
-
const [labelPosition, labelWidth] = useFormContextSelector((ctx) => [ctx.labelPosition, ctx.labelWidth]);
|
|
46
|
-
const [form, initialValues, isLoading] = useFormStore((state) => [state.form, state.initialValues, state.isLoading]);
|
|
47
|
-
const { handleValuesChange } = useFormValuesChange(onChange);
|
|
48
|
-
const {
|
|
49
|
-
handleReset,
|
|
50
|
-
handleSubmit,
|
|
51
|
-
handleSubmitFailed
|
|
52
|
-
} = useActionHandlers({
|
|
53
|
-
submitApi,
|
|
54
|
-
submitTip,
|
|
55
|
-
onBeforeSubmit,
|
|
56
|
-
onSubmit,
|
|
57
|
-
onSubmitSuccess,
|
|
58
|
-
onSubmitFailure,
|
|
59
|
-
onReset
|
|
60
|
-
});
|
|
61
|
-
useFormInstance(ref, handleReset);
|
|
62
|
-
const labelCol = useMemo(() => {
|
|
63
|
-
if (!labelWidth) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
return { flex: `0 0 ${labelWidth}px` };
|
|
67
|
-
}, [labelWidth]);
|
|
68
|
-
const formStyle = useMemo(() => {
|
|
69
|
-
let heightValue = height;
|
|
70
|
-
if (height === "full") {
|
|
71
|
-
heightValue = "100%";
|
|
72
|
-
} else if (isNumber(height)) {
|
|
73
|
-
heightValue = `${height}px`;
|
|
74
|
-
}
|
|
75
|
-
return css`
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.787Z, made by Venus. */import{jsxs,jsx}from"@emotion/react/jsx-runtime";import{css}from"@emotion/react";import{useContextDisabled,useSingleton,useUnmount}from"@vef-framework/hooks";import{isNumber,isDeepEqual,omit}from"@vef-framework/shared";import{Form}from"antd";import{useMemo,forwardRef,memo}from"react";import"../internal/index.js";import VefFormActions from"./components/form-actions.js";import VefFormContent from"./components/form-content.js";import{FormEventBus}from"./event.js";import{useActionHandlers}from"./hooks/use-action-handlers.js";import{useFormContextSelector,FormContextProvider}from"./hooks/use-form-context.js";import{useFormInitialization}from"./hooks/use-form-initialization.js";import{useFormInstance}from"./hooks/use-form-instance.js";import{useFormValuesChange}from"./hooks/use-form-values-change.js";import{useLabelWidth}from"./hooks/use-label-width.js";import{useFormStore,FormStoreProvider}from"./store.js";import{convertBasicSizeToUiSize}from"../internal/utils.js";const{useForm}=Form,scrollToFirstErrorOptions={scrollMode:"if-needed",behavior:"smooth"};function VefFormBase({schema,labelAlign="right",variant,showTabs=!1,height="auto",size,disabled=!1,onChange,submissionButton,resetButton,submitApi,submitTip,onBeforeSubmit,onSubmit,onSubmitSuccess,onSubmitFailure,onReset},ref){const[labelPosition,labelWidth]=useFormContextSelector(ctx=>[ctx.labelPosition,ctx.labelWidth]),[form,initialValues,isLoading]=useFormStore(state=>[state.form,state.initialValues,state.isLoading]),{handleValuesChange}=useFormValuesChange(onChange),{handleReset,handleSubmit,handleSubmitFailed}=useActionHandlers({submitApi,submitTip,onBeforeSubmit,onSubmit,onSubmitSuccess,onSubmitFailure,onReset});useFormInstance(ref,handleReset);const labelCol=useMemo(()=>{if(labelWidth)return{flex:`0 0 ${labelWidth}px`}},[labelWidth]),formStyle=useMemo(()=>{let heightValue=height;return height==="full"?heightValue="100%":isNumber(height)&&(heightValue=`${height}px`),css`
|
|
76
2
|
height: ${heightValue};
|
|
77
|
-
|
|
78
|
-
}, [height]);
|
|
79
|
-
const contextDisabled = useContextDisabled();
|
|
80
|
-
const formDisabled = contextDisabled || disabled || isLoading;
|
|
81
|
-
return /* @__PURE__ */ jsxs(
|
|
82
|
-
Form,
|
|
83
|
-
{
|
|
84
|
-
labelWrap: true,
|
|
85
|
-
colon: false,
|
|
86
|
-
css: formStyle,
|
|
87
|
-
disabled: formDisabled,
|
|
88
|
-
form,
|
|
89
|
-
initialValues,
|
|
90
|
-
labelAlign,
|
|
91
|
-
labelCol,
|
|
92
|
-
layout: labelPosition === "top" ? "vertical" : "horizontal",
|
|
93
|
-
scrollToFirstError: scrollToFirstErrorOptions,
|
|
94
|
-
size: convertBasicSizeToUiSize(size),
|
|
95
|
-
variant,
|
|
96
|
-
onFinish: handleSubmit,
|
|
97
|
-
onFinishFailed: handleSubmitFailed,
|
|
98
|
-
onValuesChange: handleValuesChange,
|
|
99
|
-
children: [
|
|
100
|
-
/* @__PURE__ */ jsx(
|
|
101
|
-
VefFormContent,
|
|
102
|
-
{
|
|
103
|
-
height,
|
|
104
|
-
schema,
|
|
105
|
-
showTabs: showTabs === true ? "switch" : showTabs
|
|
106
|
-
}
|
|
107
|
-
),
|
|
108
|
-
/* @__PURE__ */ jsx(
|
|
109
|
-
VefFormActions,
|
|
110
|
-
{
|
|
111
|
-
handleReset,
|
|
112
|
-
resetButton,
|
|
113
|
-
submissionButton
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
const VefFormBaseForwarded = forwardRef(VefFormBase);
|
|
121
|
-
VefFormBaseForwarded.displayName = "VefFormBase";
|
|
122
|
-
function VefFormWrapper({
|
|
123
|
-
initialValues,
|
|
124
|
-
scene,
|
|
125
|
-
layoutMode = "responsive",
|
|
126
|
-
autoExpand = false,
|
|
127
|
-
labelPosition = "top",
|
|
128
|
-
labelWidth,
|
|
129
|
-
...restProps
|
|
130
|
-
}, ref) {
|
|
131
|
-
const { schema } = restProps;
|
|
132
|
-
const [form] = useForm();
|
|
133
|
-
const eventBus = useSingleton(() => new FormEventBus());
|
|
134
|
-
useUnmount(() => {
|
|
135
|
-
eventBus.clear();
|
|
136
|
-
});
|
|
137
|
-
const labelWidthToUse = useLabelWidth(labelPosition, labelWidth);
|
|
138
|
-
const formContext = useMemo(() => ({
|
|
139
|
-
labelPosition,
|
|
140
|
-
labelWidth: labelWidthToUse,
|
|
141
|
-
autoExpand,
|
|
142
|
-
layoutMode
|
|
143
|
-
}), [layoutMode, autoExpand, labelPosition, labelWidthToUse]);
|
|
144
|
-
const {
|
|
145
|
-
mergedInitialValues,
|
|
146
|
-
valueChangeHandlers,
|
|
147
|
-
virtualFieldNames
|
|
148
|
-
} = useFormInitialization(schema, initialValues);
|
|
149
|
-
const initialState = useMemo(() => ({
|
|
150
|
-
eventBus,
|
|
151
|
-
form,
|
|
152
|
-
initialValues: mergedInitialValues,
|
|
153
|
-
scene,
|
|
154
|
-
valueChangeHandlers,
|
|
155
|
-
virtualFieldNames
|
|
156
|
-
}), [eventBus, form, mergedInitialValues, scene, valueChangeHandlers, virtualFieldNames]);
|
|
157
|
-
return /* @__PURE__ */ jsx(FormStoreProvider, { initialState, children: /* @__PURE__ */ jsx(FormContextProvider, { value: formContext, children: /* @__PURE__ */ jsx(
|
|
158
|
-
VefFormBaseForwarded,
|
|
159
|
-
{
|
|
160
|
-
ref,
|
|
161
|
-
...restProps
|
|
162
|
-
}
|
|
163
|
-
) }) });
|
|
164
|
-
}
|
|
165
|
-
const VefForm = memo(
|
|
166
|
-
forwardRef(VefFormWrapper),
|
|
167
|
-
(prevProps, nextProps) => isDeepEqual(
|
|
168
|
-
omit(prevProps, ["initialValues", "schema"]),
|
|
169
|
-
omit(nextProps, ["initialValues", "schema"])
|
|
170
|
-
)
|
|
171
|
-
);
|
|
172
|
-
VefForm.displayName = "VefForm";
|
|
173
|
-
|
|
174
|
-
export { VefForm as default };
|
|
175
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
3
|
+
`},[height]),formDisabled=useContextDisabled()||disabled||isLoading;return jsxs(Form,{labelWrap:!0,colon:!1,css:formStyle,disabled:formDisabled,form,initialValues,labelAlign,labelCol,layout:labelPosition==="top"?"vertical":"horizontal",scrollToFirstError:scrollToFirstErrorOptions,size:convertBasicSizeToUiSize(size),variant,onFinish:handleSubmit,onFinishFailed:handleSubmitFailed,onValuesChange:handleValuesChange,children:[jsx(VefFormContent,{height,schema,showTabs:showTabs===!0?"switch":showTabs}),jsx(VefFormActions,{handleReset,resetButton,submissionButton})]})}const VefFormBaseForwarded=forwardRef(VefFormBase);VefFormBaseForwarded.displayName="VefFormBase";function VefFormWrapper({initialValues,scene,layoutMode="responsive",autoExpand=!1,labelPosition="top",labelWidth,...restProps},ref){const{schema}=restProps,[form]=useForm(),eventBus=useSingleton(()=>new FormEventBus);useUnmount(()=>{eventBus.clear()});const labelWidthToUse=useLabelWidth(labelPosition,labelWidth),formContext=useMemo(()=>({labelPosition,labelWidth:labelWidthToUse,autoExpand,layoutMode}),[layoutMode,autoExpand,labelPosition,labelWidthToUse]),{mergedInitialValues,valueChangeHandlers,virtualFieldNames}=useFormInitialization(schema,initialValues),initialState=useMemo(()=>({eventBus,form,initialValues:mergedInitialValues,scene,valueChangeHandlers,virtualFieldNames}),[eventBus,form,mergedInitialValues,scene,valueChangeHandlers,virtualFieldNames]);return jsx(FormStoreProvider,{initialState,children:jsx(FormContextProvider,{value:formContext,children:jsx(VefFormBaseForwarded,{ref,...restProps})})})}const VefForm=memo(forwardRef(VefFormWrapper),(prevProps,nextProps)=>isDeepEqual(omit(prevProps,["initialValues","schema"]),omit(nextProps,["initialValues","schema"])));VefForm.displayName="VefForm";/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */export{VefForm as default};
|