dinocollab-core 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rollupPluginBabelHelpers.js +67 -10
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/dist/{src/api-context → api-context}/alert-global.js +49 -34
- package/dist/api-context/alert-global.js.map +1 -0
- package/dist/{src/api-context → api-context}/drawer-global.js +40 -33
- package/dist/api-context/drawer-global.js.map +1 -0
- package/dist/{src/api-context → api-context}/global-modal.js +40 -32
- package/dist/api-context/global-modal.js.map +1 -0
- package/dist/{src/api-context → api-context}/popover-global.js +44 -36
- package/dist/api-context/popover-global.js.map +1 -0
- package/dist/api-context/popover.js +94 -0
- package/dist/api-context/popover.js.map +1 -0
- package/dist/{src/api-context → api-context}/ui.units.js +12 -10
- package/dist/api-context/ui.units.js.map +1 -0
- package/dist/components/breadcrumbs.js +65 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/{src/components → components}/copy-to-clipboard.js +39 -32
- package/dist/components/copy-to-clipboard.js.map +1 -0
- package/dist/components/help-tooltip.js +104 -0
- package/dist/components/help-tooltip.js.map +1 -0
- package/dist/components/image-with-fallback.js +51 -0
- package/dist/components/image-with-fallback.js.map +1 -0
- package/dist/{src/components → components}/text-editor.js +24 -23
- package/dist/components/text-editor.js.map +1 -0
- package/dist/components/text-editor.preview.js +27 -0
- package/dist/components/text-editor.preview.js.map +1 -0
- package/dist/form/create.autocomplete.chips.js +228 -0
- package/dist/form/create.autocomplete.chips.js.map +1 -0
- package/dist/{src/form → form}/create.date-expired.js +71 -61
- package/dist/form/create.date-expired.js.map +1 -0
- package/dist/{src/form → form}/create.date-picker.js +40 -37
- package/dist/form/create.date-picker.js.map +1 -0
- package/dist/{src/form → form}/create.form-base.js +47 -41
- package/dist/form/create.form-base.js.map +1 -0
- package/dist/form/create.form-comfirm.js +131 -0
- package/dist/form/create.form-comfirm.js.map +1 -0
- package/dist/form/create.form-grid-layout.js +188 -0
- package/dist/form/create.form-grid-layout.js.map +1 -0
- package/dist/{src/form → form}/create.form-grid-layout.units.js +17 -14
- package/dist/form/create.form-grid-layout.units.js.map +1 -0
- package/dist/form/create.input.file.js +79 -0
- package/dist/form/create.input.file.js.map +1 -0
- package/dist/form/create.input.js +276 -0
- package/dist/form/create.input.js.map +1 -0
- package/dist/form/create.select-simple.js +114 -0
- package/dist/form/create.select-simple.js.map +1 -0
- package/dist/form/create.select-with-api.js +277 -0
- package/dist/form/create.select-with-api.js.map +1 -0
- package/dist/form/create.text-editor.js +181 -0
- package/dist/form/create.text-editor.js.map +1 -0
- package/dist/{src/form → form}/dino-form.js +17 -18
- package/dist/form/dino-form.js.map +1 -0
- package/dist/{src/form → form}/helper.js +14 -14
- package/dist/form/helper.js.map +1 -0
- package/dist/{src/form → form}/modal-wrapper.js +32 -25
- package/dist/form/modal-wrapper.js.map +1 -0
- package/dist/{src/form → form}/validator.js +47 -43
- package/dist/form/validator.js.map +1 -0
- package/dist/{src/hooks → hooks}/index.js +1 -1
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +928 -0
- package/dist/{src/index.js → index.js} +10 -3
- package/dist/{src/index.js.map → index.js.map} +1 -1
- package/dist/redux/create.hoc-lazy.js +71 -0
- package/dist/redux/create.hoc-lazy.js.map +1 -0
- package/dist/{src/redux → redux}/dino.js +2 -2
- package/dist/redux/dino.js.map +1 -0
- package/dist/redux/types.js.map +1 -0
- package/dist/redux/ui.error-page.js +89 -0
- package/dist/redux/ui.error-page.js.map +1 -0
- package/dist/redux/vector-404.webp.js.map +1 -0
- package/dist/{src/table → table}/context.js +5 -2
- package/dist/table/context.js.map +1 -0
- package/dist/table/create.action-row.js +144 -0
- package/dist/table/create.action-row.js.map +1 -0
- package/dist/table/create.table.js +246 -0
- package/dist/table/create.table.js.map +1 -0
- package/dist/{src/table → table}/custom.filter-operators.js +2 -2
- package/dist/table/custom.filter-operators.js.map +1 -0
- package/dist/table/dino.js +136 -0
- package/dist/table/dino.js.map +1 -0
- package/dist/{src/table → table}/helpers.js +31 -32
- package/dist/table/helpers.js.map +1 -0
- package/dist/table/model-filter.js.map +1 -0
- package/dist/table/toolbar-pannel.js +143 -0
- package/dist/table/toolbar-pannel.js.map +1 -0
- package/dist/table/ui.buttons.js +67 -0
- package/dist/table/ui.buttons.js.map +1 -0
- package/dist/table/ui.units.js +248 -0
- package/dist/table/ui.units.js.map +1 -0
- package/dist/types/api-context/alert-global.d.ts +29 -0
- package/dist/types/api-context/drawer-global.d.ts +32 -0
- package/dist/types/api-context/global-modal.d.ts +37 -0
- package/dist/types/api-context/index.d.ts +9 -0
- package/dist/types/api-context/popover-global.d.ts +37 -0
- package/dist/types/api-context/popover.d.ts +32 -0
- package/dist/types/api-context/ui.units.d.ts +2 -0
- package/dist/types/components/breadcrumbs.d.ts +13 -0
- package/dist/types/components/copy-to-clipboard.d.ts +26 -0
- package/dist/types/components/help-tooltip.d.ts +15 -0
- package/dist/types/components/image-with-fallback.d.ts +13 -0
- package/dist/types/components/index.d.ts +11 -0
- package/dist/types/components/input-debounce-timer.d.ts +9 -0
- package/dist/types/components/loading-buttons.d.ts +6 -0
- package/dist/types/components/text-editor.d.ts +26 -0
- package/dist/types/components/text-editor.preview.d.ts +5 -0
- package/dist/types/form/create.autocomplete.chips.d.ts +16 -0
- package/dist/types/form/create.date-expired.d.ts +19 -0
- package/dist/types/form/create.date-picker.d.ts +19 -0
- package/dist/types/form/create.form-base.d.ts +30 -0
- package/dist/types/form/create.form-comfirm.d.ts +20 -0
- package/dist/types/form/create.form-grid-layout.d.ts +44 -0
- package/dist/types/form/create.form-grid-layout.units.d.ts +8 -0
- package/dist/types/form/create.input.d.ts +29 -0
- package/dist/types/form/create.input.file.d.ts +16 -0
- package/dist/types/form/create.select-simple.d.ts +24 -0
- package/dist/types/form/create.select-with-api.d.ts +29 -0
- package/dist/types/form/create.text-editor.d.ts +42 -0
- package/dist/types/form/dino-form.d.ts +26 -0
- package/dist/types/form/helper.d.ts +14 -0
- package/dist/types/form/index.d.ts +7 -0
- package/dist/types/form/modal-wrapper.d.ts +14 -0
- package/dist/types/form/types.d.ts +15 -0
- package/dist/types/form/validator.d.ts +64 -0
- package/dist/types/hooks/index.d.ts +4 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/lab/create.autocomplete.simple.d.ts +19 -0
- package/dist/types/lab/create.dino-store.d.ts +1 -0
- package/dist/types/lab/create.multi-select-dropdown.d.ts +23 -0
- package/dist/types/lab/create.select-mul-with-api/index.d.ts +26 -0
- package/dist/types/lab/create.select-mul-with-api/table-custom.d.ts +43 -0
- package/dist/types/lab/create.select-mul-with-api/types.d.ts +21 -0
- package/dist/types/lab/create.select-mul-with-api/ui.units.d.ts +29 -0
- package/dist/types/lab/filter-bar/base.d.ts +34 -0
- package/dist/types/lab/filter-bar/create.filter-bar.d.ts +92 -0
- package/dist/types/lab/filter-bar/create.filter-menu.d.ts +66 -0
- package/dist/types/lab/filter-bar/create.filter-panel.d.ts +117 -0
- package/dist/types/lab/filter-bar/create.filtered.d.ts +59 -0
- package/dist/types/lab/filter-bar/create.sort-menu.d.ts +7 -0
- package/dist/types/lab/filter-bar/demo.d.ts +3 -0
- package/dist/types/lab/filter-bar/index.d.ts +4 -0
- package/dist/types/lab/filter-bar/types.d.ts +81 -0
- package/dist/types/lab/filter-bar/ui.units.d.ts +13 -0
- package/dist/types/lab/grafana-dashboard/configs.d.ts +4 -0
- package/dist/types/lab/grafana-dashboard/date-time-range/absolute-time-rage.d.ts +14 -0
- package/dist/types/lab/grafana-dashboard/date-time-range/helpers.d.ts +36 -0
- package/dist/types/lab/grafana-dashboard/date-time-range/index.d.ts +24 -0
- package/dist/types/lab/grafana-dashboard/date-time-range/menu-wrap.d.ts +19 -0
- package/dist/types/lab/grafana-dashboard/date-time-range/quick-ranges.d.ts +20 -0
- package/dist/types/lab/grafana-dashboard/date-time-range/types.d.ts +8 -0
- package/dist/types/lab/grafana-dashboard/date-time-range/units.d.ts +2 -0
- package/dist/types/lab/grafana-dashboard/helper.d.ts +7 -0
- package/dist/types/lab/grafana-dashboard/hooks.d.ts +10 -0
- package/dist/types/lab/grafana-dashboard/icons.d.ts +5 -0
- package/dist/types/lab/grafana-dashboard/index.d.ts +12 -0
- package/dist/types/lab/grafana-dashboard/top-bar.d.ts +19 -0
- package/dist/types/lab/grafana-dashboard/top-bar.types.d.ts +4 -0
- package/dist/types/lab/grafana-dashboard/types.d.ts +8 -0
- package/dist/types/lab/media-player.core1.d.ts +14 -0
- package/dist/types/lab/media-player.muted.d.ts +10 -0
- package/dist/types/lab/media-player.units.d.ts +36 -0
- package/dist/types/lab/table-grid/create.table-grid.d.ts +4 -0
- package/dist/types/lab/table-grid/demo.d.ts +3 -0
- package/dist/types/lab/table-grid/dino.d.ts +6 -0
- package/dist/types/lab/table-grid/helpers.d.ts +11 -0
- package/dist/types/lab/table-grid/index.d.ts +2 -0
- package/dist/types/lab/table-grid/item-actions.d.ts +93 -0
- package/dist/types/lab/table-grid/toolbar-pannel.d.ts +27 -0
- package/dist/types/lab/table-grid/types.d.ts +56 -0
- package/dist/types/redux/create.hoc-lazy.d.ts +19 -0
- package/dist/types/redux/dino.d.ts +6 -0
- package/dist/types/redux/index.d.ts +4 -0
- package/dist/types/redux/types.d.ts +22 -0
- package/dist/types/redux/ui.error-page.d.ts +3 -0
- package/dist/types/redux/ui.units.d.ts +9 -0
- package/dist/types/table/context.d.ts +8 -0
- package/dist/types/table/create.action-row.d.ts +16 -0
- package/dist/types/table/create.table.d.ts +33 -0
- package/dist/types/table/custom.filter-operators.d.ts +2 -0
- package/dist/types/table/dino.d.ts +41 -0
- package/dist/types/table/helpers.d.ts +23 -0
- package/dist/types/table/index.d.ts +7 -0
- package/dist/types/table/model-filter.d.ts +38 -0
- package/dist/types/table/toolbar-pannel.d.ts +18 -0
- package/dist/types/table/types.d.ts +40 -0
- package/dist/types/table/ui.buttons.d.ts +16 -0
- package/dist/types/table/ui.units.d.ts +62 -0
- package/dist/types/utils/dayjs-config.d.ts +2 -0
- package/dist/types/utils/helpers.d.ts +35 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/json-object.d.ts +9 -0
- package/dist/types/utils/mfe-events.d.ts +12 -0
- package/dist/types/utils/query-param.d.ts +25 -0
- package/dist/utils/dayjs-config.js.map +1 -0
- package/dist/{src/utils → utils}/helpers.js +11 -9
- package/dist/utils/helpers.js.map +1 -0
- package/dist/{src/utils → utils}/json-object.js +13 -13
- package/dist/utils/json-object.js.map +1 -0
- package/dist/{src/utils → utils}/query-param.js +17 -17
- package/dist/utils/query-param.js.map +1 -0
- package/package.json +18 -4
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@1_d0d2002d9033600b6738d939bd598bc6/node_modules/tslib/tslib.es6.js +0 -46
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@1_d0d2002d9033600b6738d939bd598bc6/node_modules/tslib/tslib.es6.js.map +0 -1
- package/dist/src/api-context/alert-global.js.map +0 -1
- package/dist/src/api-context/drawer-global.js.map +0 -1
- package/dist/src/api-context/global-modal.js.map +0 -1
- package/dist/src/api-context/popover-global.js.map +0 -1
- package/dist/src/api-context/popover.js +0 -86
- package/dist/src/api-context/popover.js.map +0 -1
- package/dist/src/api-context/ui.units.js.map +0 -1
- package/dist/src/components/copy-to-clipboard.js.map +0 -1
- package/dist/src/components/custom.breadcrumbs.js +0 -61
- package/dist/src/components/custom.breadcrumbs.js.map +0 -1
- package/dist/src/components/help-tooltip.js +0 -91
- package/dist/src/components/help-tooltip.js.map +0 -1
- package/dist/src/components/image-with-fallback.js +0 -48
- package/dist/src/components/image-with-fallback.js.map +0 -1
- package/dist/src/components/text-editor.js.map +0 -1
- package/dist/src/form/create.autocomplete.chips.js +0 -218
- package/dist/src/form/create.autocomplete.chips.js.map +0 -1
- package/dist/src/form/create.date-expired.js.map +0 -1
- package/dist/src/form/create.date-picker.js.map +0 -1
- package/dist/src/form/create.form-base.js.map +0 -1
- package/dist/src/form/create.form-comfirm.js +0 -119
- package/dist/src/form/create.form-comfirm.js.map +0 -1
- package/dist/src/form/create.form-grid-layout.js +0 -177
- package/dist/src/form/create.form-grid-layout.js.map +0 -1
- package/dist/src/form/create.form-grid-layout.units.js.map +0 -1
- package/dist/src/form/create.input-base.js +0 -260
- package/dist/src/form/create.input-base.js.map +0 -1
- package/dist/src/form/create.input.file.js +0 -74
- package/dist/src/form/create.input.file.js.map +0 -1
- package/dist/src/form/create.select-simple.js +0 -104
- package/dist/src/form/create.select-simple.js.map +0 -1
- package/dist/src/form/create.select-with-api.js +0 -271
- package/dist/src/form/create.select-with-api.js.map +0 -1
- package/dist/src/form/create.text-editor.js +0 -156
- package/dist/src/form/create.text-editor.js.map +0 -1
- package/dist/src/form/dino-form.js.map +0 -1
- package/dist/src/form/helper.js.map +0 -1
- package/dist/src/form/modal-wrapper.js.map +0 -1
- package/dist/src/form/validator.js.map +0 -1
- package/dist/src/hooks/index.js.map +0 -1
- package/dist/src/redux/create.hoc-lazy.js +0 -67
- package/dist/src/redux/create.hoc-lazy.js.map +0 -1
- package/dist/src/redux/dino.js.map +0 -1
- package/dist/src/redux/types.js.map +0 -1
- package/dist/src/redux/ui.error-page.js +0 -80
- package/dist/src/redux/ui.error-page.js.map +0 -1
- package/dist/src/redux/vector-404.webp.js.map +0 -1
- package/dist/src/table/context.js.map +0 -1
- package/dist/src/table/create.action-row.js +0 -135
- package/dist/src/table/create.action-row.js.map +0 -1
- package/dist/src/table/create.status-cell.js +0 -49
- package/dist/src/table/create.status-cell.js.map +0 -1
- package/dist/src/table/create.table.js +0 -233
- package/dist/src/table/create.table.js.map +0 -1
- package/dist/src/table/custom.filter-operators.js.map +0 -1
- package/dist/src/table/dino.js +0 -129
- package/dist/src/table/dino.js.map +0 -1
- package/dist/src/table/helpers.js.map +0 -1
- package/dist/src/table/model-filter.js.map +0 -1
- package/dist/src/table/toolbar-pannel.js +0 -134
- package/dist/src/table/toolbar-pannel.js.map +0 -1
- package/dist/src/table/ui.buttons.js +0 -60
- package/dist/src/table/ui.buttons.js.map +0 -1
- package/dist/src/table/ui.units.js +0 -201
- package/dist/src/table/ui.units.js.map +0 -1
- package/dist/src/utils/dayjs-config.js.map +0 -1
- package/dist/src/utils/helpers.js.map +0 -1
- package/dist/src/utils/json-object.js.map +0 -1
- package/dist/src/utils/query-param.js.map +0 -1
- package/rollup.config.js +0 -39
- package/src/@types/global.d.ts +0 -5
- package/src/api-context/alert-global.tsx +0 -174
- package/src/api-context/drawer-global.tsx +0 -116
- package/src/api-context/global-modal.tsx +0 -109
- package/src/api-context/index.ts +0 -13
- package/src/api-context/popover-global.tsx +0 -107
- package/src/api-context/popover.tsx +0 -89
- package/src/api-context/ui.units.tsx +0 -10
- package/src/components/copy-to-clipboard.tsx +0 -86
- package/src/components/custom.breadcrumbs.tsx +0 -67
- package/src/components/help-tooltip.tsx +0 -75
- package/src/components/image-with-fallback.tsx +0 -51
- package/src/components/index.tsx +0 -1
- package/src/components/input-debounce-timer.tsx +0 -138
- package/src/components/loading-buttons.tsx +0 -35
- package/src/components/text-editor.preview.tsx +0 -30
- package/src/components/text-editor.tsx +0 -125
- package/src/form/README.md +0 -55
- package/src/form/create.autocomplete.chips.tsx +0 -199
- package/src/form/create.date-expired.tsx +0 -195
- package/src/form/create.date-picker.tsx +0 -122
- package/src/form/create.form-base.tsx +0 -102
- package/src/form/create.form-comfirm.tsx +0 -83
- package/src/form/create.form-grid-layout.tsx +0 -170
- package/src/form/create.form-grid-layout.units.tsx +0 -37
- package/src/form/create.input-base.tsx +0 -222
- package/src/form/create.input.file.tsx +0 -76
- package/src/form/create.select-simple.tsx +0 -101
- package/src/form/create.select-with-api.tsx +0 -213
- package/src/form/create.text-editor.tsx +0 -161
- package/src/form/dino-form.tsx +0 -40
- package/src/form/helper.ts +0 -132
- package/src/form/index.ts +0 -12
- package/src/form/modal-wrapper.tsx +0 -75
- package/src/form/types.ts +0 -16
- package/src/form/validator.ts +0 -202
- package/src/hooks/index.ts +0 -44
- package/src/index.ts +0 -7
- package/src/lab/create.autocomplete.simple.tsx +0 -57
- package/src/lab/create.dino-store.ts +0 -59
- package/src/lab/create.multi-select-dropdown.tsx +0 -189
- package/src/lab/create.select-mul-with-api/index.tsx +0 -271
- package/src/lab/create.select-mul-with-api/table-custom.tsx +0 -194
- package/src/lab/create.select-mul-with-api/types.ts +0 -26
- package/src/lab/create.select-mul-with-api/ui.units.tsx +0 -163
- package/src/lab/filter-bar/base.tsx +0 -162
- package/src/lab/filter-bar/create.filter-bar.tsx +0 -190
- package/src/lab/filter-bar/create.filter-menu.tsx +0 -156
- package/src/lab/filter-bar/create.filter-panel.tsx +0 -95
- package/src/lab/filter-bar/create.filtered.tsx +0 -41
- package/src/lab/filter-bar/create.sort-menu.tsx +0 -43
- package/src/lab/filter-bar/demo.tsx +0 -50
- package/src/lab/filter-bar/index.ts +0 -6
- package/src/lab/filter-bar/types.ts +0 -105
- package/src/lab/filter-bar/ui.units.tsx +0 -70
- package/src/lab/grafana-dashboard/configs.ts +0 -43
- package/src/lab/grafana-dashboard/date-time-range/absolute-time-rage.tsx +0 -137
- package/src/lab/grafana-dashboard/date-time-range/helpers.ts +0 -126
- package/src/lab/grafana-dashboard/date-time-range/index.tsx +0 -62
- package/src/lab/grafana-dashboard/date-time-range/menu-wrap.tsx +0 -101
- package/src/lab/grafana-dashboard/date-time-range/quick-ranges.tsx +0 -161
- package/src/lab/grafana-dashboard/date-time-range/types.ts +0 -9
- package/src/lab/grafana-dashboard/date-time-range/units.tsx +0 -18
- package/src/lab/grafana-dashboard/helper.ts +0 -25
- package/src/lab/grafana-dashboard/hooks.tsx +0 -79
- package/src/lab/grafana-dashboard/icons.tsx +0 -67
- package/src/lab/grafana-dashboard/index.tsx +0 -120
- package/src/lab/grafana-dashboard/top-bar.tsx +0 -62
- package/src/lab/grafana-dashboard/top-bar.types.ts +0 -5
- package/src/lab/grafana-dashboard/types.ts +0 -8
- package/src/lab/media-player.core1.tsx +0 -273
- package/src/lab/media-player.muted.tsx +0 -62
- package/src/lab/media-player.units.ts +0 -80
- package/src/lab/table-grid/create.table-grid.tsx +0 -183
- package/src/lab/table-grid/demo.tsx +0 -53
- package/src/lab/table-grid/dino.tsx +0 -8
- package/src/lab/table-grid/helpers.tsx +0 -11
- package/src/lab/table-grid/index.ts +0 -3
- package/src/lab/table-grid/item-actions.tsx +0 -138
- package/src/lab/table-grid/toolbar-pannel.tsx +0 -98
- package/src/lab/table-grid/types.ts +0 -68
- package/src/redux/create.hoc-lazy.tsx +0 -80
- package/src/redux/dino.ts +0 -9
- package/src/redux/index.ts +0 -6
- package/src/redux/types.ts +0 -27
- package/src/redux/ui.error-page.tsx +0 -62
- package/src/redux/ui.units.tsx +0 -41
- package/src/redux/vector-404.webp +0 -0
- package/src/table/context.tsx +0 -16
- package/src/table/create.action-row.tsx +0 -91
- package/src/table/create.status-cell.tsx +0 -51
- package/src/table/create.table.tsx +0 -239
- package/src/table/custom.filter-operators.ts +0 -94
- package/src/table/dino.tsx +0 -120
- package/src/table/helpers.ts +0 -94
- package/src/table/index.ts +0 -13
- package/src/table/model-filter.ts +0 -43
- package/src/table/toolbar-pannel.tsx +0 -106
- package/src/table/types.ts +0 -50
- package/src/table/ui.buttons.tsx +0 -54
- package/src/table/ui.units.tsx +0 -189
- package/src/utils/dayjs-config.ts +0 -13
- package/src/utils/helpers.ts +0 -171
- package/src/utils/index.ts +0 -7
- package/src/utils/json-object.ts +0 -29
- package/src/utils/mfe-events.tsx +0 -34
- package/src/utils/query-param.ts +0 -129
- package/tsconfig.json +0 -20
- /package/dist/{src/redux → redux}/types.js +0 -0
- /package/dist/{src/redux → redux}/vector-404.webp.js +0 -0
- /package/dist/{src/table → table}/model-filter.js +0 -0
- /package/dist/{src/utils → utils}/dayjs-config.js +0 -0
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import React, { FC, useCallback, useEffect, useState } from 'react'
|
|
2
|
-
import { Box, Stack, styled, Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material'
|
|
3
|
-
import MuiAlert, { AlertProps, AlertColor } from '@mui/material/Alert'
|
|
4
|
-
|
|
5
|
-
const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(props, ref) {
|
|
6
|
-
return <MuiAlert elevation={6} ref={ref} variant='standard' {...props} style={{ minWidth: '300px' }} />
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
interface MessageData {
|
|
10
|
-
id: string
|
|
11
|
-
text: string
|
|
12
|
-
type: AlertColor
|
|
13
|
-
duration?: number
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface IOptions {
|
|
17
|
-
duration?: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface IApiAlert {
|
|
21
|
-
PushMessage: (data: MessageData) => void
|
|
22
|
-
PushInfo: (data: string) => void
|
|
23
|
-
PushError: (data: string) => void
|
|
24
|
-
PushWarning: (data: string) => void
|
|
25
|
-
PushSuccess: (data: string) => void
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface IApiContext {
|
|
29
|
-
ApiAlert?: IApiAlert
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const ApiAlertContext: IApiContext = {}
|
|
33
|
-
|
|
34
|
-
const RenderArea = (messages: MessageData[], onClose: (data: MessageData) => void) => {
|
|
35
|
-
return messages.map((x, i) => {
|
|
36
|
-
return <Message key={x.id + i} data={x} IsOpen={true} handleClose={onClose} autoDurationHide={x.duration} />
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function AlertGlobal() {
|
|
41
|
-
const [Messages, setMessages] = useState<MessageData[]>([])
|
|
42
|
-
const _PushMessage = useCallback((data: MessageData) => {
|
|
43
|
-
setMessages((st) => [...st, data])
|
|
44
|
-
}, [])
|
|
45
|
-
const _HandleClose = useCallback(
|
|
46
|
-
(data: MessageData) => {
|
|
47
|
-
const index = Messages.findIndex((x) => x.id === data.id)
|
|
48
|
-
Messages.splice(index, 1)
|
|
49
|
-
setMessages([...Messages])
|
|
50
|
-
},
|
|
51
|
-
[Messages]
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
ApiAlertContext.ApiAlert = {
|
|
56
|
-
...(ApiAlertContext.ApiAlert ? ApiAlertContext.ApiAlert : {}),
|
|
57
|
-
PushMessage: _PushMessage,
|
|
58
|
-
PushError: function (data: string, options?: IOptions) {
|
|
59
|
-
this.PushMessage({
|
|
60
|
-
id: new Date().getTime().toString(),
|
|
61
|
-
text: data,
|
|
62
|
-
type: 'error',
|
|
63
|
-
duration: options?.duration || 15000
|
|
64
|
-
})
|
|
65
|
-
},
|
|
66
|
-
PushInfo: function (data: string, options?: IOptions) {
|
|
67
|
-
this.PushMessage({
|
|
68
|
-
id: new Date().getTime().toString(),
|
|
69
|
-
text: data,
|
|
70
|
-
type: 'info',
|
|
71
|
-
duration: options?.duration || 6000
|
|
72
|
-
})
|
|
73
|
-
},
|
|
74
|
-
PushWarning: function (data: string, options?: IOptions) {
|
|
75
|
-
this.PushMessage({
|
|
76
|
-
id: new Date().getTime().toString(),
|
|
77
|
-
text: data,
|
|
78
|
-
type: 'warning',
|
|
79
|
-
duration: options?.duration || 6000
|
|
80
|
-
})
|
|
81
|
-
},
|
|
82
|
-
PushSuccess: function (data: string, options?: IOptions) {
|
|
83
|
-
this.PushMessage({
|
|
84
|
-
id: new Date().getTime().toString(),
|
|
85
|
-
text: data,
|
|
86
|
-
type: 'success',
|
|
87
|
-
duration: options?.duration || 3000
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}, [_PushMessage])
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<Wrap>
|
|
95
|
-
<Stack spacing={2} sx={{ maxWidth: '300px' }}>
|
|
96
|
-
{RenderArea(Messages, _HandleClose)}
|
|
97
|
-
</Stack>
|
|
98
|
-
</Wrap>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
export default AlertGlobal
|
|
102
|
-
|
|
103
|
-
interface MessageProps {
|
|
104
|
-
IsOpen: boolean
|
|
105
|
-
handleClose: (data: MessageData) => void
|
|
106
|
-
data: MessageData
|
|
107
|
-
autoDurationHide?: number
|
|
108
|
-
}
|
|
109
|
-
const Message: FC<MessageProps> = (props) => {
|
|
110
|
-
const _handleClose = useCallback(() => props.handleClose(props.data), [props])
|
|
111
|
-
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
let Timer: any = null
|
|
114
|
-
if (props.autoDurationHide) {
|
|
115
|
-
Timer = setTimeout(() => {
|
|
116
|
-
props.handleClose(props.data)
|
|
117
|
-
}, props.autoDurationHide)
|
|
118
|
-
}
|
|
119
|
-
return () => {
|
|
120
|
-
clearTimeout(Timer as any)
|
|
121
|
-
}
|
|
122
|
-
}, [props])
|
|
123
|
-
return (
|
|
124
|
-
<Alert onClose={_handleClose} severity={props.data.type}>
|
|
125
|
-
{props.data.text}
|
|
126
|
-
</Alert>
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const Wrap = styled(Box)({
|
|
131
|
-
position: 'fixed',
|
|
132
|
-
top: 'calc(var(--height-header) + 20px)',
|
|
133
|
-
right: '50px',
|
|
134
|
-
zIndex: 2000,
|
|
135
|
-
display: 'flex',
|
|
136
|
-
justifyContent: 'flex-start',
|
|
137
|
-
alignItems: 'center'
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
interface AlertDialogProps {
|
|
141
|
-
IsOpen: boolean
|
|
142
|
-
onClose?: () => void
|
|
143
|
-
onAccept?: () => void
|
|
144
|
-
Title: string
|
|
145
|
-
Message: string
|
|
146
|
-
}
|
|
147
|
-
export const AlertDialog: React.FC<AlertDialogProps> = (props) => {
|
|
148
|
-
const [Open, setOpen] = React.useState(props.IsOpen)
|
|
149
|
-
React.useEffect(() => {
|
|
150
|
-
setOpen(props.IsOpen)
|
|
151
|
-
}, [props.IsOpen])
|
|
152
|
-
const _handleClose = React.useCallback(() => {
|
|
153
|
-
setOpen(false)
|
|
154
|
-
props.onClose && props.onClose()
|
|
155
|
-
}, [props])
|
|
156
|
-
return (
|
|
157
|
-
<div>
|
|
158
|
-
<Dialog open={Open} onClose={_handleClose} aria-labelledby='alert-dialog-title' aria-describedby='alert-dialog-description'>
|
|
159
|
-
<DialogTitle id='alert-dialog-title'>{props.Title}</DialogTitle>
|
|
160
|
-
<DialogContent>
|
|
161
|
-
<DialogContentText id='alert-dialog-description'>{props.Message}</DialogContentText>
|
|
162
|
-
</DialogContent>
|
|
163
|
-
<DialogActions>
|
|
164
|
-
<Button onClick={props.onAccept} autoFocus color='info'>
|
|
165
|
-
Ok
|
|
166
|
-
</Button>
|
|
167
|
-
<Button onClick={_handleClose} color='error'>
|
|
168
|
-
Cancel
|
|
169
|
-
</Button>
|
|
170
|
-
</DialogActions>
|
|
171
|
-
</Dialog>
|
|
172
|
-
</div>
|
|
173
|
-
)
|
|
174
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import React, { Component, ReactNode } from 'react'
|
|
2
|
-
import { Box, Divider, Drawer, DrawerProps, IconButton, styled, Typography } from '@mui/material'
|
|
3
|
-
import CloseIcon from '@mui/icons-material/Close'
|
|
4
|
-
|
|
5
|
-
const drawerGlobalClasses = {
|
|
6
|
-
root: 'DrawerGlobal-root',
|
|
7
|
-
title: 'DrawerGlobal-title',
|
|
8
|
-
content: 'DrawerGlobal-content',
|
|
9
|
-
fullHeight: 'DrawerGlobal-fullHeight'
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface IProps {}
|
|
13
|
-
|
|
14
|
-
interface IState {
|
|
15
|
-
title?: ReactNode
|
|
16
|
-
icon?: ReactNode
|
|
17
|
-
fullHeight?: boolean
|
|
18
|
-
anchor?: DrawerProps['anchor']
|
|
19
|
-
/** @default true */
|
|
20
|
-
backdropClickeable?: boolean
|
|
21
|
-
renderContent?: () => ReactNode
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type TReason = 'backdropClick' | 'escapeKeyDown'
|
|
25
|
-
|
|
26
|
-
interface DrawerGlobalApiType {
|
|
27
|
-
open: (state: IState) => void
|
|
28
|
-
close: (reason?: TReason) => void
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const DrawerGlobalApi: DrawerGlobalApiType = {
|
|
32
|
-
close: () => {
|
|
33
|
-
console.warn('DrawerGlobal provider not found!')
|
|
34
|
-
},
|
|
35
|
-
open: () => {
|
|
36
|
-
console.warn('DrawerGlobal provider not found!')
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class DrawerGlobalProvider extends Component<IProps, IState> {
|
|
41
|
-
constructor(props: IProps) {
|
|
42
|
-
super(props)
|
|
43
|
-
this.state = {}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
close = (reason?: TReason) => {
|
|
47
|
-
if (this.state.backdropClickeable === false && reason === 'backdropClick') return
|
|
48
|
-
this.setState({ renderContent: undefined })
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
open = (state: IState) => this.setState(state)
|
|
52
|
-
|
|
53
|
-
componentDidMount() {
|
|
54
|
-
DrawerGlobalApi.open = this.open
|
|
55
|
-
DrawerGlobalApi.close = this.close
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
render() {
|
|
59
|
-
return (
|
|
60
|
-
<Drawer anchor={this.state.anchor} open={Boolean(this.state.renderContent)} onClose={(_, reason) => this.close(reason)}>
|
|
61
|
-
<Wrap className={this.getClasses()}>
|
|
62
|
-
<div className={drawerGlobalClasses.title}>
|
|
63
|
-
{this.state.icon}
|
|
64
|
-
{this.renderTitle()}
|
|
65
|
-
<Box sx={{ flex: 1 }} />
|
|
66
|
-
<IconButton onClick={() => this.close()}>
|
|
67
|
-
<CloseIcon />
|
|
68
|
-
</IconButton>
|
|
69
|
-
</div>
|
|
70
|
-
<Divider variant='middle' />
|
|
71
|
-
<div className={drawerGlobalClasses.content}>{this.state.renderContent && this.state.renderContent()}</div>
|
|
72
|
-
</Wrap>
|
|
73
|
-
</Drawer>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
renderTitle = () => {
|
|
78
|
-
if (typeof this.state.title === 'string') {
|
|
79
|
-
return (
|
|
80
|
-
<Typography variant='h6' noWrap>
|
|
81
|
-
{this.state.title}
|
|
82
|
-
</Typography>
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
return this.state.title
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
getClasses = () => {
|
|
89
|
-
const classes = [drawerGlobalClasses.root]
|
|
90
|
-
if (this.state.fullHeight) classes.push(drawerGlobalClasses.fullHeight)
|
|
91
|
-
return classes.join(' ')
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const DrawerGlobal = {
|
|
96
|
-
Provider: DrawerGlobalProvider,
|
|
97
|
-
Api: DrawerGlobalApi
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export default DrawerGlobal
|
|
101
|
-
|
|
102
|
-
const Wrap = styled(Box)({
|
|
103
|
-
'--height-title': '56px',
|
|
104
|
-
[`.${drawerGlobalClasses.title}`]: {
|
|
105
|
-
display: 'flex',
|
|
106
|
-
alignItems: 'center',
|
|
107
|
-
height: 'var(--height-title)',
|
|
108
|
-
padding: '0 12px',
|
|
109
|
-
gap: '6px'
|
|
110
|
-
},
|
|
111
|
-
[`&.${drawerGlobalClasses.fullHeight}`]: {
|
|
112
|
-
[`.${drawerGlobalClasses.content}`]: {
|
|
113
|
-
height: 'calc(100vh - var(--height-title) - 60px)'
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
})
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react'
|
|
2
|
-
import { Backdrop, Box, Modal, SxProps, styled } from '@mui/material'
|
|
3
|
-
|
|
4
|
-
export interface GlobalModalState {
|
|
5
|
-
sx?: SxProps
|
|
6
|
-
sxWrap?: SxProps
|
|
7
|
-
/** @default true */
|
|
8
|
-
backdropActivated?: boolean
|
|
9
|
-
onClose?: (reason?: TModalReason) => void
|
|
10
|
-
renderContent?: () => React.ReactNode
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type TModalReason = 'backdropClick' | 'escapeKeyDown'
|
|
14
|
-
|
|
15
|
-
interface GlobalModalProps {}
|
|
16
|
-
|
|
17
|
-
export type TShowModal = (value: GlobalModalState) => void
|
|
18
|
-
|
|
19
|
-
export type TCloseModal = (event?: {}, reason?: TModalReason) => void
|
|
20
|
-
|
|
21
|
-
export interface IGlobalModalContext {
|
|
22
|
-
show: TShowModal
|
|
23
|
-
close: TCloseModal
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const GlobalModalContext = React.createContext<IGlobalModalContext>({
|
|
27
|
-
close: () => {
|
|
28
|
-
console.warn('GlobalModal provider not found!')
|
|
29
|
-
},
|
|
30
|
-
show: () => {
|
|
31
|
-
console.warn('GlobalModal provider not found!')
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
export interface IMapGlobalModal {
|
|
36
|
-
context: IGlobalModalContext
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const MapGlobalModalContext = (context: (state: IGlobalModalContext) => React.ReactNode) => (
|
|
40
|
-
<GlobalModalContext.Consumer>{context}</GlobalModalContext.Consumer>
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
class GlobalModal extends Component<React.PropsWithChildren<GlobalModalProps>, GlobalModalState> implements IGlobalModalContext {
|
|
44
|
-
constructor(props: any) {
|
|
45
|
-
super(props)
|
|
46
|
-
this.state = {}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
show: TShowModal = (value) => {
|
|
50
|
-
this.setState(value)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
close: TCloseModal = (_, reason) => {
|
|
54
|
-
if (reason === 'backdropClick' && this.state.backdropActivated === false) return
|
|
55
|
-
this.setState({ renderContent: undefined })
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
render() {
|
|
59
|
-
return (
|
|
60
|
-
<GlobalModalContext.Provider value={this}>
|
|
61
|
-
{this.props.children}
|
|
62
|
-
<Modal
|
|
63
|
-
open={!!this.state.renderContent}
|
|
64
|
-
onClose={this.close}
|
|
65
|
-
slots={{ backdrop: Backdrop }}
|
|
66
|
-
slotProps={{ backdrop: { timeout: 300 } }}
|
|
67
|
-
sx={this.state.sx}
|
|
68
|
-
>
|
|
69
|
-
<Wrapper sx={this.state.sxWrap}>{this.renderContent()}</Wrapper>
|
|
70
|
-
</Modal>
|
|
71
|
-
</GlobalModalContext.Provider>
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
renderContent = (): React.ReactNode => {
|
|
76
|
-
return this.state.renderContent ? this.state.renderContent() : <></>
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
export default GlobalModal
|
|
80
|
-
|
|
81
|
-
const Wrapper = styled(Box)({
|
|
82
|
-
position: 'absolute',
|
|
83
|
-
top: '50%',
|
|
84
|
-
left: '50%',
|
|
85
|
-
transform: 'translate(-50%, -50%)',
|
|
86
|
-
outline: 'none'
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
export interface IApiGlobalModalContextProps {
|
|
90
|
-
contextGlobalModal: IGlobalModalContext
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export const withApiGlobalModalContext = <P extends IApiGlobalModalContextProps>(Component: React.ComponentType<P>) => {
|
|
94
|
-
return (props: Omit<P, keyof IApiGlobalModalContextProps>) => {
|
|
95
|
-
return (
|
|
96
|
-
<GlobalModal>
|
|
97
|
-
{MapGlobalModalContext((context) => (
|
|
98
|
-
<Component {...(props as P)} contextGlobalModal={context} />
|
|
99
|
-
))}
|
|
100
|
-
</GlobalModal>
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export const withApiGlobalModalConsumerContext = <P extends IApiGlobalModalContextProps>(Component: React.ComponentType<P>) => {
|
|
106
|
-
return (props: Omit<P, keyof IApiGlobalModalContextProps>) => {
|
|
107
|
-
return MapGlobalModalContext((context) => <Component {...(props as P)} contextGlobalModal={context} />)
|
|
108
|
-
}
|
|
109
|
-
}
|
package/src/api-context/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export { default as ApiPopover } from './popover'
|
|
2
|
-
export * from './popover'
|
|
3
|
-
|
|
4
|
-
export { default as AlertGlobal } from './alert-global'
|
|
5
|
-
export * from './alert-global'
|
|
6
|
-
|
|
7
|
-
export { default as DrawerGlobal } from './drawer-global'
|
|
8
|
-
|
|
9
|
-
export { default as GlobalModal } from './global-modal'
|
|
10
|
-
export * from './global-modal'
|
|
11
|
-
|
|
12
|
-
export { default as PopoverGlobal } from './popover-global'
|
|
13
|
-
export * from './popover-global'
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import React, { Component, PropsWithChildren } from 'react'
|
|
2
|
-
import { Popover, PopoverProps, PopoverVirtualElement } from '@mui/material'
|
|
3
|
-
import { ContentDefault } from './ui.units'
|
|
4
|
-
|
|
5
|
-
export interface PopoverGlobalState {
|
|
6
|
-
anchorEl?: Element | (() => Element) | PopoverVirtualElement | (() => PopoverVirtualElement) | null
|
|
7
|
-
popoverProps?: Omit<PopoverProps, 'open'>
|
|
8
|
-
content: React.ReactNode
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type OpenPopover = (value: PopoverGlobalState) => void
|
|
12
|
-
|
|
13
|
-
export type ClosePopover = (reason?: 'backdropClick' | 'escapeKeyDown') => void
|
|
14
|
-
|
|
15
|
-
export interface PopoverGlobalContext {
|
|
16
|
-
open: OpenPopover
|
|
17
|
-
close: ClosePopover
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const PopoverGlobalApi: PopoverGlobalContext = {
|
|
21
|
-
open: () => {
|
|
22
|
-
console.warn('PopoverGlobal provider not found!')
|
|
23
|
-
},
|
|
24
|
-
close: () => {
|
|
25
|
-
console.warn('PopoverGlobal provider not found!')
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const PopoverGlobalContext = React.createContext<PopoverGlobalContext>(PopoverGlobalApi)
|
|
30
|
-
|
|
31
|
-
export const MapPopoverGlobalContext = (context: (state: PopoverGlobalContext) => React.ReactNode) => (
|
|
32
|
-
<PopoverGlobalContext.Consumer>{context}</PopoverGlobalContext.Consumer>
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
interface IProps extends PropsWithChildren {}
|
|
36
|
-
|
|
37
|
-
export class PopoverGlobalProvider extends Component<IProps, PopoverGlobalState> {
|
|
38
|
-
constructor(props: any) {
|
|
39
|
-
super(props)
|
|
40
|
-
this.state = { anchorEl: null, content: <ContentDefault /> }
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
componentDidMount() {
|
|
44
|
-
PopoverGlobalApi.open = this.openPopover
|
|
45
|
-
PopoverGlobalApi.close = this.closePopover
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
render() {
|
|
49
|
-
return (
|
|
50
|
-
<PopoverGlobalContext.Provider value={{ open: this.openPopover, close: this.closePopover }}>
|
|
51
|
-
{this.props.children}
|
|
52
|
-
<Popover
|
|
53
|
-
sx={{ '& .MuiPaper-root.MuiPaper-elevation': { overflow: 'hidden' } }}
|
|
54
|
-
anchorEl={this.state.anchorEl}
|
|
55
|
-
open={Boolean(this.state.anchorEl)}
|
|
56
|
-
onClose={(_, reason) => this.closePopover(reason)}
|
|
57
|
-
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
|
|
58
|
-
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
|
|
59
|
-
disableScrollLock
|
|
60
|
-
{...this.state.popoverProps}
|
|
61
|
-
>
|
|
62
|
-
{this.state.content}
|
|
63
|
-
</Popover>
|
|
64
|
-
</PopoverGlobalContext.Provider>
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
openPopover: OpenPopover = (option) => {
|
|
69
|
-
clearTimeout(this.timer)
|
|
70
|
-
this.setState({ ...option })
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
timer: any
|
|
74
|
-
closePopover: ClosePopover = () => {
|
|
75
|
-
clearTimeout(this.timer)
|
|
76
|
-
this.setState({ anchorEl: null }, () => {
|
|
77
|
-
this.timer = setTimeout(() => {
|
|
78
|
-
this.setState({ content: <ContentDefault /> })
|
|
79
|
-
}, 500)
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface IPopoverGlobalContextProps {
|
|
85
|
-
contextPopover: PopoverGlobalContext
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export const withPopoverGlobalContext = <P extends IPopoverGlobalContextProps>(Component: React.ComponentType<P>) => {
|
|
89
|
-
return (props: Omit<P, keyof IPopoverGlobalContextProps>) => {
|
|
90
|
-
return (
|
|
91
|
-
<PopoverGlobalProvider>
|
|
92
|
-
{MapPopoverGlobalContext((context) => (
|
|
93
|
-
<Component {...(props as P)} contextPopover={context} />
|
|
94
|
-
))}
|
|
95
|
-
</PopoverGlobalProvider>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const PopoverGlobal = {
|
|
101
|
-
Provider: PopoverGlobalProvider,
|
|
102
|
-
Api: PopoverGlobalApi,
|
|
103
|
-
Context: PopoverGlobalContext,
|
|
104
|
-
mapContext: MapPopoverGlobalContext
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export default PopoverGlobal
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react'
|
|
2
|
-
import { Popover, PopoverProps, PopoverVirtualElement } from '@mui/material'
|
|
3
|
-
import { ContentDefault } from './ui.units'
|
|
4
|
-
|
|
5
|
-
export interface IPopoverOptions {
|
|
6
|
-
anchorEl?: Element | (() => Element) | PopoverVirtualElement | (() => PopoverVirtualElement) | null
|
|
7
|
-
popoverProps?: Omit<PopoverProps, 'open'>
|
|
8
|
-
content: React.ReactNode
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type TShowPopover = (option: IPopoverOptions) => void
|
|
12
|
-
|
|
13
|
-
export type TClosePopover = (reason?: 'backdropClick' | 'escapeKeyDown') => void
|
|
14
|
-
|
|
15
|
-
export interface IApiPopoverContext {
|
|
16
|
-
showPopover: TShowPopover
|
|
17
|
-
closePopover: TClosePopover
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const ApiPopoverContext = React.createContext<IApiPopoverContext>({
|
|
21
|
-
showPopover: () => {
|
|
22
|
-
console.warn('ApiPopover provider not found!')
|
|
23
|
-
},
|
|
24
|
-
closePopover: () => {
|
|
25
|
-
console.warn('ApiPopover provider not found!')
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
export const MapApiPopoverContext = (context: (state: IApiPopoverContext) => React.ReactNode) => (
|
|
30
|
-
<ApiPopoverContext.Consumer>{context}</ApiPopoverContext.Consumer>
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
interface IProps {}
|
|
34
|
-
interface IState extends IPopoverOptions {}
|
|
35
|
-
type TProps = React.PropsWithChildren<IProps>
|
|
36
|
-
class ApiPopover extends Component<TProps, IState> implements IApiPopoverContext {
|
|
37
|
-
constructor(props: any) {
|
|
38
|
-
super(props)
|
|
39
|
-
this.state = { anchorEl: null, content: <ContentDefault /> }
|
|
40
|
-
}
|
|
41
|
-
render() {
|
|
42
|
-
return (
|
|
43
|
-
<ApiPopoverContext.Provider value={this}>
|
|
44
|
-
{this.props.children}
|
|
45
|
-
<Popover
|
|
46
|
-
sx={{ '& .MuiPaper-root.MuiPaper-elevation': { overflow: 'hidden' } }}
|
|
47
|
-
anchorEl={this.state.anchorEl}
|
|
48
|
-
open={Boolean(this.state.anchorEl)}
|
|
49
|
-
onClose={(_, reason) => this.closePopover(reason)}
|
|
50
|
-
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
|
|
51
|
-
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
|
|
52
|
-
disableScrollLock
|
|
53
|
-
{...this.state.popoverProps}
|
|
54
|
-
>
|
|
55
|
-
{this.state.content}
|
|
56
|
-
</Popover>
|
|
57
|
-
</ApiPopoverContext.Provider>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
showPopover = (option: IPopoverOptions) => {
|
|
61
|
-
clearTimeout(this.timer)
|
|
62
|
-
this.setState({ ...option })
|
|
63
|
-
}
|
|
64
|
-
timer: any
|
|
65
|
-
closePopover: TClosePopover = () => {
|
|
66
|
-
clearTimeout(this.timer)
|
|
67
|
-
this.setState({ anchorEl: null }, () => {
|
|
68
|
-
this.timer = setTimeout(() => {
|
|
69
|
-
this.setState({ content: <ContentDefault /> })
|
|
70
|
-
}, 500)
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export default ApiPopover
|
|
75
|
-
|
|
76
|
-
export interface IApiPopoverContextProps {
|
|
77
|
-
contextPopover: IApiPopoverContext
|
|
78
|
-
}
|
|
79
|
-
export const withApiPopoverContext = <P extends IApiPopoverContextProps>(Component: React.ComponentType<P>) => {
|
|
80
|
-
return (props: Omit<P, keyof IApiPopoverContextProps>) => {
|
|
81
|
-
return (
|
|
82
|
-
<ApiPopover>
|
|
83
|
-
{MapApiPopoverContext((context) => (
|
|
84
|
-
<Component {...(props as P)} contextPopover={context} />
|
|
85
|
-
))}
|
|
86
|
-
</ApiPopover>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react'
|
|
2
|
-
import { Box, Typography } from '@mui/material'
|
|
3
|
-
|
|
4
|
-
export const ContentDefault: FC = () => (
|
|
5
|
-
<Box sx={{ p: '9px 12px', m: '12px', backgroundColor: 'rgba(0,0,0,0.1)' }}>
|
|
6
|
-
<Typography variant='caption' sx={{ fontWeight: 600, fontStyle: 'italic' }}>
|
|
7
|
-
Content
|
|
8
|
-
</Typography>
|
|
9
|
-
</Box>
|
|
10
|
-
)
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import React, { Component, ComponentType } from 'react'
|
|
2
|
-
import { Box, ButtonProps, IconButton, Tooltip, TooltipProps } from '@mui/material'
|
|
3
|
-
import copy from 'clipboard-copy'
|
|
4
|
-
import DoneIcon from '@mui/icons-material/Done'
|
|
5
|
-
import ContentCopyIcon from '@mui/icons-material/ContentCopy'
|
|
6
|
-
|
|
7
|
-
interface IProps {
|
|
8
|
-
value: string
|
|
9
|
-
slots?: {
|
|
10
|
-
tooltipProps?: Partial<TooltipProps>
|
|
11
|
-
button?: ComponentType<{ onClick: () => void; copied?: boolean }>
|
|
12
|
-
buttonProps?: ButtonProps
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface IState {
|
|
17
|
-
showTooltip: boolean
|
|
18
|
-
copied: boolean
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
class CopyToClipboard extends Component<IProps, IState> {
|
|
22
|
-
constructor(props: IProps) {
|
|
23
|
-
super(props)
|
|
24
|
-
this.state = { showTooltip: false, copied: false }
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
render() {
|
|
28
|
-
const leaveDelay = this.state.copied ? this.debounceTime.time - 200 : 0
|
|
29
|
-
const { title, ...tooltipProps } = this.props.slots?.tooltipProps ?? {}
|
|
30
|
-
const titleValue = this.state.copied ? 'Copied to clipboard!' : (title ?? 'Copy to clipboard')
|
|
31
|
-
return (
|
|
32
|
-
<Tooltip
|
|
33
|
-
arrow
|
|
34
|
-
title={titleValue}
|
|
35
|
-
leaveDelay={leaveDelay}
|
|
36
|
-
open={this.state.showTooltip}
|
|
37
|
-
onOpen={() => this.setState({ showTooltip: true })}
|
|
38
|
-
onClose={() => this.setState({ showTooltip: false })}
|
|
39
|
-
{...tooltipProps}
|
|
40
|
-
>
|
|
41
|
-
<Box sx={{ display: 'inline-block', flex: '0 0 auto' }}>{this.renderIcon()}</Box>
|
|
42
|
-
</Tooltip>
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
renderIcon = () => {
|
|
47
|
-
if (this.props.slots?.button) {
|
|
48
|
-
const ButtonComp = this.props.slots.button
|
|
49
|
-
return <ButtonComp onClick={this.handleClickCopy} copied={this.state.copied} />
|
|
50
|
-
}
|
|
51
|
-
const Icon = this.state.copied ? DoneIcon : ContentCopyIcon
|
|
52
|
-
return (
|
|
53
|
-
<IconButton onClick={this.handleClickCopy} {...this.props.slots?.buttonProps}>
|
|
54
|
-
<Icon fontSize='small' sx={{ color: '#606060' }} />
|
|
55
|
-
</IconButton>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
handleClickCopy = () => {
|
|
60
|
-
this.debounceTime.start()
|
|
61
|
-
this.onCopy()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private debounceTime = {
|
|
65
|
-
cache: 0 as any,
|
|
66
|
-
time: 1500,
|
|
67
|
-
start: () => {
|
|
68
|
-
this.debounceTime.clear()
|
|
69
|
-
this.setState({ copied: true }, () => {
|
|
70
|
-
this.debounceTime.cache = setTimeout(() => {
|
|
71
|
-
this.setState({ copied: false })
|
|
72
|
-
}, this.debounceTime.time)
|
|
73
|
-
})
|
|
74
|
-
},
|
|
75
|
-
clear: () => {
|
|
76
|
-
clearTimeout(this.debounceTime.cache)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private onCopy = () => {
|
|
81
|
-
copy(this.props.value)
|
|
82
|
-
this.setState({ showTooltip: true })
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export default CopyToClipboard
|