@antv/infographic 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -2
- package/README.zh-CN.md +26 -3
- package/dist/infographic.min.js +484 -79
- package/dist/infographic.min.js.map +1 -1
- package/esm/constants/components.d.ts +1 -0
- package/esm/constants/components.js +1 -0
- package/esm/constants/element.d.ts +17 -6
- package/esm/constants/index.d.ts +2 -0
- package/esm/constants/index.js +2 -0
- package/esm/constants/shape.d.ts +16 -0
- package/esm/designs/components/Btn.js +2 -2
- package/esm/designs/components/BtnsGroup.js +1 -1
- package/esm/designs/components/Illus.js +2 -2
- package/esm/designs/components/ItemDesc.js +1 -2
- package/esm/designs/components/ItemIcon.js +1 -1
- package/esm/designs/components/ItemLabel.js +1 -2
- package/esm/designs/components/ItemValue.js +1 -2
- package/esm/designs/components/ItemsGroup.js +1 -1
- package/esm/designs/components/Title.js +2 -5
- package/esm/designs/items/CandyCardLite.js +1 -1
- package/esm/designs/items/CircularProgress.js +2 -1
- package/esm/designs/items/HorizontalIconArrow.js +1 -2
- package/esm/designs/items/HorizontalIconLine.js +1 -1
- package/esm/designs/items/IconBadge.js +1 -1
- package/esm/designs/items/LinedText.d.ts +12 -0
- package/esm/designs/items/LinedText.js +57 -0
- package/esm/designs/items/PlainText.d.ts +1 -0
- package/esm/designs/items/PlainText.js +16 -3
- package/esm/designs/items/QuarterCircular.js +1 -31
- package/esm/designs/items/index.d.ts +1 -0
- package/esm/designs/items/index.js +1 -0
- package/esm/designs/layouts/Align.js +31 -45
- package/esm/designs/layouts/Flex.js +33 -29
- package/esm/designs/structures/chart-bar.d.ts +15 -0
- package/esm/designs/structures/chart-bar.js +99 -0
- package/esm/designs/structures/chart-line.d.ts +12 -0
- package/esm/designs/structures/chart-line.js +164 -0
- package/esm/designs/structures/chart-pie.d.ts +9 -0
- package/esm/designs/structures/chart-pie.js +127 -0
- package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
- package/esm/designs/structures/hierarchy-mindmap.d.ts +24 -0
- package/esm/designs/structures/hierarchy-mindmap.js +199 -0
- package/esm/designs/structures/index.d.ts +4 -0
- package/esm/designs/structures/index.js +4 -0
- package/esm/designs/structures/list-sector.js +1 -1
- package/esm/designs/structures/sequence-circular.js +1 -1
- package/esm/designs/structures/sequence-cylinders-3d.js +4 -4
- package/esm/designs/structures/sequence-roadmap-vertical.js +1 -1
- package/esm/designs/structures/sequence-zigzag-pucks-3d.js +5 -5
- package/esm/editor/commands/Batch.d.ts +11 -0
- package/esm/editor/commands/Batch.js +21 -0
- package/esm/editor/commands/UpdateElement.d.ts +16 -0
- package/esm/editor/commands/UpdateElement.js +83 -0
- package/esm/editor/commands/UpdateOptions.d.ts +14 -0
- package/esm/editor/commands/UpdateOptions.js +25 -0
- package/esm/editor/commands/UpdateText.d.ts +16 -0
- package/esm/editor/commands/UpdateText.js +40 -0
- package/esm/editor/commands/index.d.ts +4 -0
- package/esm/editor/commands/index.js +4 -0
- package/esm/editor/editor.d.ts +16 -0
- package/esm/editor/editor.js +50 -0
- package/esm/editor/index.d.ts +4 -0
- package/esm/editor/index.js +3 -0
- package/esm/editor/interactions/base.d.ts +12 -0
- package/esm/editor/interactions/base.js +5 -0
- package/esm/editor/interactions/brush-select.d.ts +23 -0
- package/esm/editor/interactions/brush-select.js +167 -0
- package/esm/editor/interactions/click-select.d.ts +12 -0
- package/esm/editor/interactions/click-select.js +67 -0
- package/esm/editor/interactions/dblclick-edit-text.d.ts +10 -0
- package/esm/editor/interactions/dblclick-edit-text.js +204 -0
- package/esm/editor/interactions/drag-element.d.ts +41 -0
- package/esm/editor/interactions/drag-element.js +391 -0
- package/esm/editor/interactions/hotkey-history.d.ts +10 -0
- package/esm/editor/interactions/hotkey-history.js +27 -0
- package/esm/editor/interactions/index.d.ts +8 -0
- package/esm/editor/interactions/index.js +8 -0
- package/esm/editor/interactions/select-highlight.d.ts +16 -0
- package/esm/editor/interactions/select-highlight.js +99 -0
- package/esm/editor/interactions/zoom-wheel.d.ts +8 -0
- package/esm/editor/interactions/zoom-wheel.js +46 -0
- package/esm/editor/managers/command.d.ts +19 -0
- package/esm/editor/managers/command.js +63 -0
- package/esm/editor/managers/index.d.ts +4 -0
- package/esm/editor/managers/index.js +4 -0
- package/esm/editor/managers/interaction.d.ts +33 -0
- package/esm/editor/managers/interaction.js +196 -0
- package/esm/editor/managers/plugin.d.ts +14 -0
- package/esm/editor/managers/plugin.js +45 -0
- package/esm/editor/managers/state.d.ts +22 -0
- package/esm/editor/managers/state.js +141 -0
- package/esm/editor/plugins/base.d.ts +12 -0
- package/esm/editor/plugins/base.js +5 -0
- package/esm/editor/plugins/edit-bar/components/button.d.ts +12 -0
- package/esm/editor/plugins/edit-bar/components/button.js +53 -0
- package/esm/editor/plugins/edit-bar/components/color-picker.d.ts +10 -0
- package/esm/editor/plugins/edit-bar/components/color-picker.js +351 -0
- package/esm/editor/plugins/edit-bar/components/icons.d.ts +26 -0
- package/esm/editor/plugins/edit-bar/components/icons.js +30 -0
- package/esm/editor/plugins/edit-bar/components/index.d.ts +5 -0
- package/esm/editor/plugins/edit-bar/components/index.js +5 -0
- package/esm/editor/plugins/edit-bar/components/popover.d.ts +23 -0
- package/esm/editor/plugins/edit-bar/components/popover.js +378 -0
- package/esm/editor/plugins/edit-bar/components/select.d.ts +22 -0
- package/esm/editor/plugins/edit-bar/components/select.js +201 -0
- package/esm/editor/plugins/edit-bar/edit-bar.d.ts +32 -0
- package/esm/editor/plugins/edit-bar/edit-bar.js +211 -0
- package/esm/editor/plugins/edit-bar/edit-items/align-elements.d.ts +2 -0
- package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +312 -0
- package/esm/editor/plugins/edit-bar/edit-items/font-align.d.ts +3 -0
- package/esm/editor/plugins/edit-bar/edit-items/font-align.js +81 -0
- package/esm/editor/plugins/edit-bar/edit-items/font-color.d.ts +3 -0
- package/esm/editor/plugins/edit-bar/edit-items/font-color.js +77 -0
- package/esm/editor/plugins/edit-bar/edit-items/font-family.d.ts +3 -0
- package/esm/editor/plugins/edit-bar/edit-items/font-family.js +115 -0
- package/esm/editor/plugins/edit-bar/edit-items/font-size.d.ts +3 -0
- package/esm/editor/plugins/edit-bar/edit-items/font-size.js +88 -0
- package/esm/editor/plugins/edit-bar/edit-items/icon-color.d.ts +3 -0
- package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +77 -0
- package/esm/editor/plugins/edit-bar/edit-items/index.d.ts +7 -0
- package/esm/editor/plugins/edit-bar/edit-items/index.js +6 -0
- package/esm/editor/plugins/edit-bar/edit-items/types.d.ts +3 -0
- package/esm/editor/plugins/edit-bar/edit-items/types.js +1 -0
- package/esm/editor/plugins/edit-bar/index.d.ts +4 -0
- package/esm/editor/plugins/edit-bar/index.js +2 -0
- package/esm/editor/plugins/edit-bar/utils.d.ts +4 -0
- package/esm/editor/plugins/edit-bar/utils.js +14 -0
- package/esm/editor/plugins/index.d.ts +3 -0
- package/esm/editor/plugins/index.js +3 -0
- package/esm/editor/plugins/resize-element.d.ts +45 -0
- package/esm/editor/plugins/resize-element.js +393 -0
- package/esm/editor/types/command.d.ts +28 -0
- package/esm/editor/types/command.js +1 -0
- package/esm/editor/types/editor.d.ts +4 -0
- package/esm/editor/types/editor.js +1 -0
- package/esm/editor/types/index.d.ts +7 -0
- package/esm/editor/types/index.js +1 -0
- package/esm/editor/types/interaction.d.ts +44 -0
- package/esm/editor/types/interaction.js +1 -0
- package/esm/editor/types/plugin.d.ts +30 -0
- package/esm/editor/types/plugin.js +1 -0
- package/esm/editor/types/selection.d.ts +2 -0
- package/esm/editor/types/selection.js +1 -0
- package/esm/editor/types/shape.d.ts +16 -0
- package/esm/editor/types/shape.js +1 -0
- package/esm/editor/types/state.d.ts +57 -0
- package/esm/editor/types/state.js +1 -0
- package/esm/editor/utils/click-handler.d.ts +28 -0
- package/esm/editor/utils/click-handler.js +97 -0
- package/esm/editor/utils/coordinate.d.ts +6 -0
- package/esm/editor/utils/coordinate.js +31 -0
- package/esm/editor/utils/data.d.ts +10 -0
- package/esm/editor/utils/data.js +18 -0
- package/esm/editor/utils/element.d.ts +2 -0
- package/esm/editor/utils/element.js +9 -0
- package/esm/editor/utils/event.d.ts +3 -0
- package/esm/editor/utils/event.js +63 -0
- package/esm/editor/utils/extension.d.ts +13 -0
- package/esm/editor/utils/extension.js +39 -0
- package/esm/editor/utils/hotkey.d.ts +20 -0
- package/esm/editor/utils/hotkey.js +109 -0
- package/esm/editor/utils/index.d.ts +7 -0
- package/esm/editor/utils/index.js +7 -0
- package/esm/exporter/svg.js +7 -5
- package/esm/index.d.ts +5 -2
- package/esm/index.js +2 -0
- package/esm/jsx/components/Polygon.js +2 -1
- package/esm/jsx/components/Text.js +66 -68
- package/esm/options/types.d.ts +15 -2
- package/esm/renderer/composites/background.js +2 -2
- package/esm/renderer/composites/button.js +4 -3
- package/esm/renderer/composites/icon.d.ts +1 -1
- package/esm/renderer/composites/icon.js +2 -0
- package/esm/renderer/composites/text.js +2 -1
- package/esm/renderer/renderer.js +3 -2
- package/esm/renderer/stylize/rough.js +3 -7
- package/esm/renderer/types/index.d.ts +0 -1
- package/esm/resource/utils/index.d.ts +0 -1
- package/esm/resource/utils/index.js +0 -1
- package/esm/resource/utils/ref.js +1 -1
- package/esm/runtime/Infographic.d.ts +8 -2
- package/esm/runtime/Infographic.js +31 -2
- package/esm/runtime/options.d.ts +2 -0
- package/esm/runtime/options.js +24 -0
- package/esm/runtime/utils.d.ts +2 -0
- package/esm/runtime/utils.js +18 -0
- package/esm/templates/built-in.js +112 -1
- package/esm/templates/hierarchy-mindmap.d.ts +2 -0
- package/esm/templates/hierarchy-mindmap.js +61 -0
- package/esm/types/attrs.d.ts +15 -13
- package/esm/types/data.d.ts +2 -0
- package/esm/types/element.d.ts +1 -1
- package/esm/types/event.d.ts +6 -0
- package/esm/types/event.js +1 -0
- package/esm/types/index.d.ts +2 -0
- package/esm/{renderer/types → types}/text.d.ts +0 -1
- package/esm/types/text.js +1 -0
- package/esm/utils/attrs.d.ts +1 -0
- package/esm/utils/attrs.js +9 -0
- package/esm/utils/element.d.ts +4 -0
- package/esm/utils/element.js +13 -0
- package/esm/utils/icon.d.ts +5 -3
- package/esm/utils/icon.js +38 -19
- package/esm/utils/index.d.ts +5 -0
- package/esm/utils/index.js +5 -0
- package/esm/utils/measure-text.d.ts +5 -0
- package/esm/utils/measure-text.js +22 -0
- package/esm/utils/recognizer.d.ts +15 -0
- package/esm/utils/recognizer.js +61 -1
- package/esm/utils/style.d.ts +1 -0
- package/esm/utils/style.js +8 -0
- package/esm/utils/text.d.ts +7 -0
- package/esm/utils/text.js +110 -35
- package/lib/constants/components.d.ts +1 -0
- package/lib/constants/components.js +4 -0
- package/lib/constants/element.d.ts +17 -6
- package/lib/constants/index.d.ts +2 -0
- package/lib/constants/index.js +2 -0
- package/lib/constants/shape.d.ts +16 -0
- package/lib/designs/components/Btn.js +2 -2
- package/lib/designs/components/BtnsGroup.js +1 -1
- package/lib/designs/components/Illus.js +2 -2
- package/lib/designs/components/ItemDesc.js +1 -2
- package/lib/designs/components/ItemIcon.js +1 -1
- package/lib/designs/components/ItemLabel.js +1 -2
- package/lib/designs/components/ItemValue.js +1 -2
- package/lib/designs/components/ItemsGroup.js +1 -1
- package/lib/designs/components/Title.js +2 -5
- package/lib/designs/items/CandyCardLite.js +1 -1
- package/lib/designs/items/CircularProgress.js +2 -1
- package/lib/designs/items/HorizontalIconArrow.js +1 -2
- package/lib/designs/items/HorizontalIconLine.js +1 -1
- package/lib/designs/items/IconBadge.js +1 -1
- package/lib/designs/items/LinedText.d.ts +12 -0
- package/lib/designs/items/LinedText.js +61 -0
- package/lib/designs/items/PlainText.d.ts +1 -0
- package/lib/designs/items/PlainText.js +16 -3
- package/lib/designs/items/QuarterCircular.js +1 -31
- package/lib/designs/items/index.d.ts +1 -0
- package/lib/designs/items/index.js +1 -0
- package/lib/designs/layouts/Align.js +31 -45
- package/lib/designs/layouts/Flex.js +33 -29
- package/lib/designs/structures/chart-bar.d.ts +15 -0
- package/lib/designs/structures/chart-bar.js +103 -0
- package/lib/designs/structures/chart-line.d.ts +12 -0
- package/lib/designs/structures/chart-line.js +168 -0
- package/lib/designs/structures/chart-pie.d.ts +9 -0
- package/lib/designs/structures/chart-pie.js +131 -0
- package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
- package/lib/designs/structures/hierarchy-mindmap.d.ts +24 -0
- package/lib/designs/structures/hierarchy-mindmap.js +203 -0
- package/lib/designs/structures/index.d.ts +4 -0
- package/lib/designs/structures/index.js +4 -0
- package/lib/designs/structures/list-sector.js +1 -1
- package/lib/designs/structures/sequence-circular.js +1 -1
- package/lib/designs/structures/sequence-cylinders-3d.js +4 -4
- package/lib/designs/structures/sequence-roadmap-vertical.js +1 -1
- package/lib/designs/structures/sequence-zigzag-pucks-3d.js +5 -5
- package/lib/editor/commands/Batch.d.ts +11 -0
- package/lib/editor/commands/Batch.js +25 -0
- package/lib/editor/commands/UpdateElement.d.ts +16 -0
- package/lib/editor/commands/UpdateElement.js +87 -0
- package/lib/editor/commands/UpdateOptions.d.ts +14 -0
- package/lib/editor/commands/UpdateOptions.js +29 -0
- package/lib/editor/commands/UpdateText.d.ts +16 -0
- package/lib/editor/commands/UpdateText.js +44 -0
- package/lib/editor/commands/index.d.ts +4 -0
- package/lib/editor/commands/index.js +20 -0
- package/lib/editor/editor.d.ts +16 -0
- package/lib/editor/editor.js +54 -0
- package/lib/editor/index.d.ts +4 -0
- package/lib/editor/index.js +21 -0
- package/lib/editor/interactions/base.d.ts +12 -0
- package/lib/editor/interactions/base.js +9 -0
- package/lib/editor/interactions/brush-select.d.ts +23 -0
- package/lib/editor/interactions/brush-select.js +171 -0
- package/lib/editor/interactions/click-select.d.ts +12 -0
- package/lib/editor/interactions/click-select.js +71 -0
- package/lib/editor/interactions/dblclick-edit-text.d.ts +10 -0
- package/lib/editor/interactions/dblclick-edit-text.js +208 -0
- package/lib/editor/interactions/drag-element.d.ts +41 -0
- package/lib/editor/interactions/drag-element.js +395 -0
- package/lib/editor/interactions/hotkey-history.d.ts +10 -0
- package/lib/editor/interactions/hotkey-history.js +31 -0
- package/lib/editor/interactions/index.d.ts +8 -0
- package/lib/editor/interactions/index.js +19 -0
- package/lib/editor/interactions/select-highlight.d.ts +16 -0
- package/lib/editor/interactions/select-highlight.js +103 -0
- package/lib/editor/interactions/zoom-wheel.d.ts +8 -0
- package/lib/editor/interactions/zoom-wheel.js +50 -0
- package/lib/editor/managers/command.d.ts +19 -0
- package/lib/editor/managers/command.js +67 -0
- package/lib/editor/managers/index.d.ts +4 -0
- package/lib/editor/managers/index.js +20 -0
- package/lib/editor/managers/interaction.d.ts +33 -0
- package/lib/editor/managers/interaction.js +200 -0
- package/lib/editor/managers/plugin.d.ts +14 -0
- package/lib/editor/managers/plugin.js +49 -0
- package/lib/editor/managers/state.d.ts +22 -0
- package/lib/editor/managers/state.js +145 -0
- package/lib/editor/plugins/base.d.ts +12 -0
- package/lib/editor/plugins/base.js +9 -0
- package/lib/editor/plugins/edit-bar/components/button.d.ts +12 -0
- package/lib/editor/plugins/edit-bar/components/button.js +57 -0
- package/lib/editor/plugins/edit-bar/components/color-picker.d.ts +10 -0
- package/lib/editor/plugins/edit-bar/components/color-picker.js +354 -0
- package/lib/editor/plugins/edit-bar/components/icons.d.ts +26 -0
- package/lib/editor/plugins/edit-bar/components/icons.js +33 -0
- package/lib/editor/plugins/edit-bar/components/index.d.ts +5 -0
- package/lib/editor/plugins/edit-bar/components/index.js +21 -0
- package/lib/editor/plugins/edit-bar/components/popover.d.ts +23 -0
- package/lib/editor/plugins/edit-bar/components/popover.js +381 -0
- package/lib/editor/plugins/edit-bar/components/select.d.ts +22 -0
- package/lib/editor/plugins/edit-bar/components/select.js +204 -0
- package/lib/editor/plugins/edit-bar/edit-bar.d.ts +32 -0
- package/lib/editor/plugins/edit-bar/edit-bar.js +215 -0
- package/lib/editor/plugins/edit-bar/edit-items/align-elements.d.ts +2 -0
- package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +316 -0
- package/lib/editor/plugins/edit-bar/edit-items/font-align.d.ts +3 -0
- package/lib/editor/plugins/edit-bar/edit-items/font-align.js +85 -0
- package/lib/editor/plugins/edit-bar/edit-items/font-color.d.ts +3 -0
- package/lib/editor/plugins/edit-bar/edit-items/font-color.js +81 -0
- package/lib/editor/plugins/edit-bar/edit-items/font-family.d.ts +3 -0
- package/lib/editor/plugins/edit-bar/edit-items/font-family.js +119 -0
- package/lib/editor/plugins/edit-bar/edit-items/font-size.d.ts +3 -0
- package/lib/editor/plugins/edit-bar/edit-items/font-size.js +92 -0
- package/lib/editor/plugins/edit-bar/edit-items/icon-color.d.ts +3 -0
- package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +81 -0
- package/lib/editor/plugins/edit-bar/edit-items/index.d.ts +7 -0
- package/lib/editor/plugins/edit-bar/edit-items/index.js +22 -0
- package/lib/editor/plugins/edit-bar/edit-items/types.d.ts +3 -0
- package/lib/editor/plugins/edit-bar/edit-items/types.js +2 -0
- package/lib/editor/plugins/edit-bar/index.d.ts +4 -0
- package/lib/editor/plugins/edit-bar/index.js +9 -0
- package/lib/editor/plugins/edit-bar/utils.d.ts +4 -0
- package/lib/editor/plugins/edit-bar/utils.js +17 -0
- package/lib/editor/plugins/index.d.ts +3 -0
- package/lib/editor/plugins/index.js +22 -0
- package/lib/editor/plugins/resize-element.d.ts +45 -0
- package/lib/editor/plugins/resize-element.js +397 -0
- package/lib/editor/types/command.d.ts +28 -0
- package/lib/editor/types/command.js +2 -0
- package/lib/editor/types/editor.d.ts +4 -0
- package/lib/editor/types/editor.js +2 -0
- package/lib/editor/types/index.d.ts +7 -0
- package/lib/editor/types/index.js +2 -0
- package/lib/editor/types/interaction.d.ts +44 -0
- package/lib/editor/types/interaction.js +2 -0
- package/lib/editor/types/plugin.d.ts +30 -0
- package/lib/editor/types/plugin.js +2 -0
- package/lib/editor/types/selection.d.ts +2 -0
- package/lib/editor/types/selection.js +2 -0
- package/lib/editor/types/shape.d.ts +16 -0
- package/lib/editor/types/shape.js +2 -0
- package/lib/editor/types/state.d.ts +57 -0
- package/lib/editor/types/state.js +2 -0
- package/lib/editor/utils/click-handler.d.ts +28 -0
- package/lib/editor/utils/click-handler.js +101 -0
- package/lib/editor/utils/coordinate.d.ts +6 -0
- package/lib/editor/utils/coordinate.js +38 -0
- package/lib/editor/utils/data.d.ts +10 -0
- package/lib/editor/utils/data.js +22 -0
- package/lib/editor/utils/element.d.ts +2 -0
- package/lib/editor/utils/element.js +12 -0
- package/lib/editor/utils/event.d.ts +3 -0
- package/lib/editor/utils/event.js +67 -0
- package/lib/editor/utils/extension.d.ts +13 -0
- package/lib/editor/utils/extension.js +43 -0
- package/lib/editor/utils/hotkey.d.ts +20 -0
- package/lib/editor/utils/hotkey.js +113 -0
- package/lib/editor/utils/index.d.ts +7 -0
- package/lib/editor/utils/index.js +23 -0
- package/lib/exporter/svg.js +6 -4
- package/lib/index.d.ts +5 -2
- package/lib/index.js +14 -1
- package/lib/jsx/components/Polygon.js +2 -1
- package/lib/jsx/components/Text.js +66 -68
- package/lib/options/types.d.ts +15 -2
- package/lib/renderer/composites/background.js +1 -1
- package/lib/renderer/composites/button.js +3 -2
- package/lib/renderer/composites/icon.d.ts +1 -1
- package/lib/renderer/composites/icon.js +2 -0
- package/lib/renderer/composites/text.js +2 -1
- package/lib/renderer/renderer.js +2 -1
- package/lib/renderer/stylize/rough.js +3 -7
- package/lib/renderer/types/index.d.ts +0 -1
- package/lib/resource/utils/index.d.ts +0 -1
- package/lib/resource/utils/index.js +0 -1
- package/lib/resource/utils/ref.js +2 -2
- package/lib/runtime/Infographic.d.ts +8 -2
- package/lib/runtime/Infographic.js +34 -2
- package/lib/runtime/options.d.ts +2 -0
- package/lib/runtime/options.js +27 -0
- package/lib/runtime/utils.d.ts +2 -0
- package/lib/runtime/utils.js +21 -0
- package/lib/templates/built-in.js +112 -1
- package/lib/templates/hierarchy-mindmap.d.ts +2 -0
- package/lib/templates/hierarchy-mindmap.js +64 -0
- package/lib/types/attrs.d.ts +15 -13
- package/lib/types/data.d.ts +2 -0
- package/lib/types/element.d.ts +1 -1
- package/lib/types/event.d.ts +6 -0
- package/lib/types/event.js +2 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/{renderer/types → types}/text.d.ts +0 -1
- package/lib/types/text.js +2 -0
- package/lib/utils/attrs.d.ts +1 -0
- package/lib/utils/attrs.js +12 -0
- package/lib/utils/element.d.ts +4 -0
- package/lib/utils/element.js +18 -0
- package/lib/utils/icon.d.ts +5 -3
- package/lib/utils/icon.js +42 -21
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/index.js +5 -0
- package/lib/utils/measure-text.d.ts +5 -0
- package/lib/utils/measure-text.js +28 -0
- package/lib/utils/recognizer.d.ts +15 -0
- package/lib/utils/recognizer.js +72 -2
- package/lib/utils/style.d.ts +1 -0
- package/lib/utils/style.js +11 -0
- package/lib/utils/text.d.ts +7 -0
- package/lib/utils/text.js +113 -32
- package/package.json +7 -3
- package/src/constants/components.ts +1 -0
- package/src/constants/element.ts +17 -5
- package/src/constants/index.ts +2 -0
- package/src/constants/shape.ts +16 -0
- package/src/designs/components/Btn.tsx +3 -2
- package/src/designs/components/BtnsGroup.tsx +2 -1
- package/src/designs/components/Illus.tsx +3 -2
- package/src/designs/components/ItemDesc.tsx +2 -2
- package/src/designs/components/ItemIcon.tsx +3 -2
- package/src/designs/components/ItemLabel.tsx +2 -2
- package/src/designs/components/ItemValue.tsx +2 -2
- package/src/designs/components/ItemsGroup.tsx +2 -1
- package/src/designs/components/Title.tsx +8 -5
- package/src/designs/items/CandyCardLite.tsx +3 -3
- package/src/designs/items/CircularProgress.tsx +19 -8
- package/src/designs/items/HorizontalIconArrow.tsx +4 -5
- package/src/designs/items/HorizontalIconLine.tsx +7 -10
- package/src/designs/items/IconBadge.tsx +3 -3
- package/src/designs/items/LinedText.tsx +131 -0
- package/src/designs/items/PlainText.tsx +25 -3
- package/src/designs/items/QuarterCircular.tsx +2 -31
- package/src/designs/items/index.ts +1 -0
- package/src/designs/layouts/Align.tsx +31 -48
- package/src/designs/layouts/Flex.tsx +33 -31
- package/src/designs/structures/chart-bar.tsx +289 -0
- package/src/designs/structures/chart-line.tsx +415 -0
- package/src/designs/structures/chart-pie.tsx +298 -0
- package/src/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.tsx +2 -2
- package/src/designs/structures/hierarchy-mindmap.tsx +394 -0
- package/src/designs/structures/index.ts +4 -0
- package/src/designs/structures/list-sector.tsx +2 -1
- package/src/designs/structures/sequence-ascending-steps.tsx +0 -1
- package/src/designs/structures/sequence-circular.tsx +1 -1
- package/src/designs/structures/sequence-cylinders-3d.tsx +5 -5
- package/src/designs/structures/sequence-roadmap-vertical.tsx +2 -1
- package/src/designs/structures/sequence-zigzag-pucks-3d.tsx +18 -25
- package/src/editor/commands/Batch.ts +24 -0
- package/src/editor/commands/UpdateElement.ts +115 -0
- package/src/editor/commands/UpdateOptions.ts +31 -0
- package/src/editor/commands/UpdateText.ts +54 -0
- package/src/editor/commands/index.ts +4 -0
- package/src/editor/editor.ts +78 -0
- package/src/editor/index.ts +4 -0
- package/src/editor/interactions/base.ts +25 -0
- package/src/editor/interactions/brush-select.ts +204 -0
- package/src/editor/interactions/click-select.ts +72 -0
- package/src/editor/interactions/dblclick-edit-text.ts +260 -0
- package/src/editor/interactions/drag-element.ts +516 -0
- package/src/editor/interactions/hotkey-history.ts +34 -0
- package/src/editor/interactions/index.ts +8 -0
- package/src/editor/interactions/select-highlight.ts +140 -0
- package/src/editor/interactions/zoom-wheel.ts +52 -0
- package/src/editor/managers/command.ts +83 -0
- package/src/editor/managers/index.ts +4 -0
- package/src/editor/managers/interaction.ts +244 -0
- package/src/editor/managers/plugin.ts +66 -0
- package/src/editor/managers/state.ts +186 -0
- package/src/editor/plugins/base.ts +25 -0
- package/src/editor/plugins/edit-bar/components/button.ts +77 -0
- package/src/editor/plugins/edit-bar/components/color-picker.ts +397 -0
- package/src/editor/plugins/edit-bar/components/icons.ts +86 -0
- package/src/editor/plugins/edit-bar/components/index.ts +5 -0
- package/src/editor/plugins/edit-bar/components/popover.ts +446 -0
- package/src/editor/plugins/edit-bar/components/select.ts +247 -0
- package/src/editor/plugins/edit-bar/edit-bar.ts +292 -0
- package/src/editor/plugins/edit-bar/edit-items/align-elements.ts +447 -0
- package/src/editor/plugins/edit-bar/edit-items/font-align.ts +129 -0
- package/src/editor/plugins/edit-bar/edit-items/font-color.ts +101 -0
- package/src/editor/plugins/edit-bar/edit-items/font-family.ts +147 -0
- package/src/editor/plugins/edit-bar/edit-items/font-size.ts +116 -0
- package/src/editor/plugins/edit-bar/edit-items/icon-color.ts +101 -0
- package/src/editor/plugins/edit-bar/edit-items/index.ts +7 -0
- package/src/editor/plugins/edit-bar/edit-items/types.ts +9 -0
- package/src/editor/plugins/edit-bar/index.ts +18 -0
- package/src/editor/plugins/edit-bar/utils.ts +16 -0
- package/src/editor/plugins/index.ts +3 -0
- package/src/editor/plugins/resize-element.ts +518 -0
- package/src/editor/types/command.ts +32 -0
- package/src/editor/types/editor.ts +4 -0
- package/src/editor/types/index.ts +7 -0
- package/src/editor/types/interaction.ts +56 -0
- package/src/editor/types/plugin.ts +34 -0
- package/src/editor/types/selection.ts +3 -0
- package/src/editor/types/shape.ts +28 -0
- package/src/editor/types/state.ts +51 -0
- package/src/editor/utils/click-handler.ts +114 -0
- package/src/editor/utils/coordinate.ts +54 -0
- package/src/editor/utils/data.ts +30 -0
- package/src/editor/utils/element.ts +13 -0
- package/src/editor/utils/event.ts +92 -0
- package/src/editor/utils/extension.ts +45 -0
- package/src/editor/utils/hotkey.ts +139 -0
- package/src/editor/utils/index.ts +7 -0
- package/src/exporter/svg.ts +15 -5
- package/src/index.ts +14 -3
- package/src/jsx/components/Polygon.ts +2 -1
- package/src/jsx/components/Text.ts +70 -71
- package/src/options/types.ts +17 -2
- package/src/renderer/composites/background.ts +2 -2
- package/src/renderer/composites/button.ts +4 -3
- package/src/renderer/composites/icon.ts +2 -0
- package/src/renderer/composites/text.ts +2 -1
- package/src/renderer/renderer.ts +4 -2
- package/src/renderer/stylize/rough.ts +3 -7
- package/src/renderer/types/index.ts +0 -1
- package/src/resource/utils/index.ts +0 -1
- package/src/resource/utils/ref.ts +1 -1
- package/src/runtime/Infographic.tsx +45 -4
- package/src/runtime/options.ts +37 -0
- package/src/runtime/utils.ts +23 -0
- package/src/templates/built-in.ts +112 -1
- package/src/templates/hierarchy-mindmap.ts +129 -0
- package/src/types/attrs.ts +17 -13
- package/src/types/data.ts +2 -0
- package/src/types/element.ts +1 -1
- package/src/types/event.ts +6 -0
- package/src/types/index.ts +2 -0
- package/src/{renderer/types → types}/text.ts +0 -1
- package/src/utils/attrs.ts +9 -0
- package/src/utils/element.ts +26 -0
- package/src/utils/icon.ts +45 -25
- package/src/utils/index.ts +5 -0
- package/src/utils/measure-text.ts +38 -0
- package/src/utils/recognizer.ts +75 -1
- package/src/utils/style.ts +8 -0
- package/src/utils/text.ts +135 -40
- /package/esm/{renderer/types/text.js → constants/shape.js} +0 -0
- /package/esm/{resource/utils → utils}/hash.d.ts +0 -0
- /package/esm/{resource/utils → utils}/hash.js +0 -0
- /package/lib/{renderer/types/text.js → constants/shape.js} +0 -0
- /package/lib/{resource/utils → utils}/hash.d.ts +0 -0
- /package/lib/{resource/utils → utils}/hash.js +0 -0
- /package/src/{resource/utils → utils}/hash.ts +0 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { COMPONENT_ROLE } from '../../../../constants';
|
|
2
|
+
import { injectStyleOnce, setElementRole } from '../../../../utils';
|
|
3
|
+
const POPOVER_CLASS = 'infographic-edit-popover';
|
|
4
|
+
const POPOVER_CONTENT_CLASS = `${POPOVER_CLASS}__content`;
|
|
5
|
+
const POPOVER_ARROW_CLASS = `${POPOVER_CLASS}__arrow`;
|
|
6
|
+
const POPOVER_STYLE_ID = 'infographic-edit-popover-style';
|
|
7
|
+
export function Popover(props) {
|
|
8
|
+
ensurePopoverStyle();
|
|
9
|
+
const placement = props.placement ?? 'top';
|
|
10
|
+
const closeOnOutsideClick = props.closeOnOutsideClick ?? true;
|
|
11
|
+
const triggerActions = Array.isArray(props.trigger)
|
|
12
|
+
? props.trigger
|
|
13
|
+
: [props.trigger || 'hover'];
|
|
14
|
+
const hoverOpenDelay = props.mouseEnterDelay ?? 50;
|
|
15
|
+
const hoverCloseDelay = props.mouseLeaveDelay ?? 150;
|
|
16
|
+
const offset = props.offset ?? 8;
|
|
17
|
+
const arrowSize = 8;
|
|
18
|
+
const arrowInnerSize = 7;
|
|
19
|
+
const bodyPadding = typeof props.padding === 'number'
|
|
20
|
+
? `${props.padding}px`
|
|
21
|
+
: (props.padding ?? '4px');
|
|
22
|
+
const container = document.createElement('div');
|
|
23
|
+
container.classList.add(POPOVER_CLASS);
|
|
24
|
+
const trigger = props.target ?? document.createElement('div');
|
|
25
|
+
container.appendChild(trigger);
|
|
26
|
+
const getContentContainer = () => {
|
|
27
|
+
const next = typeof props.getContainer === 'function'
|
|
28
|
+
? props.getContainer()
|
|
29
|
+
: props.getContainer;
|
|
30
|
+
return next ?? document.body;
|
|
31
|
+
};
|
|
32
|
+
const content = document.createElement('div');
|
|
33
|
+
content.classList.add(POPOVER_CONTENT_CLASS);
|
|
34
|
+
setElementRole(content, COMPONENT_ROLE);
|
|
35
|
+
content.dataset.placement = Array.isArray(placement)
|
|
36
|
+
? placement[0]
|
|
37
|
+
: placement;
|
|
38
|
+
content.setAttribute('data-open', String(Boolean(props.open)));
|
|
39
|
+
content.style.setProperty('--popover-gap', `${offset}px`);
|
|
40
|
+
content.style.setProperty('--popover-arrow-size', `${arrowSize}px`);
|
|
41
|
+
content.style.setProperty('--popover-arrow-inner-size', `${arrowInnerSize}px`);
|
|
42
|
+
const contentContainer = getContentContainer();
|
|
43
|
+
const isPortal = contentContainer !== container;
|
|
44
|
+
const arrow = document.createElement('div');
|
|
45
|
+
arrow.classList.add(POPOVER_ARROW_CLASS);
|
|
46
|
+
content.appendChild(arrow);
|
|
47
|
+
const body = document.createElement('div');
|
|
48
|
+
body.classList.add(`${POPOVER_CONTENT_CLASS}-body`);
|
|
49
|
+
body.style.padding = bodyPadding;
|
|
50
|
+
content.appendChild(body);
|
|
51
|
+
contentContainer.appendChild(content);
|
|
52
|
+
let open = Boolean(props.open);
|
|
53
|
+
let placementPriority = Array.isArray(placement) ? placement : [placement];
|
|
54
|
+
let currentPlacement = placementPriority[0] ?? 'top';
|
|
55
|
+
const updatePosition = () => {
|
|
56
|
+
const targetRect = trigger.getBoundingClientRect();
|
|
57
|
+
const contentRect = content.getBoundingClientRect();
|
|
58
|
+
const scrollX = window.scrollX || document.documentElement.scrollLeft;
|
|
59
|
+
const scrollY = window.scrollY || document.documentElement.scrollTop;
|
|
60
|
+
const viewportWidth = document.documentElement.clientWidth;
|
|
61
|
+
const viewportHeight = document.documentElement.clientHeight;
|
|
62
|
+
let left = 0;
|
|
63
|
+
let top = 0;
|
|
64
|
+
const calcPosition = (placementValue) => {
|
|
65
|
+
switch (placementValue) {
|
|
66
|
+
case 'top':
|
|
67
|
+
return {
|
|
68
|
+
left: scrollX +
|
|
69
|
+
targetRect.left +
|
|
70
|
+
targetRect.width / 2 -
|
|
71
|
+
contentRect.width / 2,
|
|
72
|
+
top: scrollY + targetRect.top - contentRect.height - offset,
|
|
73
|
+
};
|
|
74
|
+
case 'bottom':
|
|
75
|
+
return {
|
|
76
|
+
left: scrollX +
|
|
77
|
+
targetRect.left +
|
|
78
|
+
targetRect.width / 2 -
|
|
79
|
+
contentRect.width / 2,
|
|
80
|
+
top: scrollY + targetRect.bottom + offset,
|
|
81
|
+
};
|
|
82
|
+
case 'left':
|
|
83
|
+
return {
|
|
84
|
+
left: scrollX + targetRect.left - contentRect.width - offset,
|
|
85
|
+
top: scrollY +
|
|
86
|
+
targetRect.top +
|
|
87
|
+
targetRect.height / 2 -
|
|
88
|
+
contentRect.height / 2,
|
|
89
|
+
};
|
|
90
|
+
case 'right':
|
|
91
|
+
default:
|
|
92
|
+
return {
|
|
93
|
+
left: scrollX + targetRect.right + offset,
|
|
94
|
+
top: scrollY +
|
|
95
|
+
targetRect.top +
|
|
96
|
+
targetRect.height / 2 -
|
|
97
|
+
contentRect.height / 2,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const fitsViewport = (nextLeft, nextTop) => nextLeft >= scrollX &&
|
|
102
|
+
nextTop >= scrollY &&
|
|
103
|
+
nextLeft + contentRect.width <= scrollX + viewportWidth &&
|
|
104
|
+
nextTop + contentRect.height <= scrollY + viewportHeight;
|
|
105
|
+
let chosenPlacement = placementPriority[0] ?? 'top';
|
|
106
|
+
let position = calcPosition(chosenPlacement);
|
|
107
|
+
for (const candidate of placementPriority) {
|
|
108
|
+
const nextPosition = calcPosition(candidate);
|
|
109
|
+
position = nextPosition;
|
|
110
|
+
if (fitsViewport(nextPosition.left, nextPosition.top)) {
|
|
111
|
+
chosenPlacement = candidate;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
currentPlacement = chosenPlacement;
|
|
116
|
+
content.dataset.placement = currentPlacement;
|
|
117
|
+
if (!isPortal)
|
|
118
|
+
return;
|
|
119
|
+
({ left, top } = position);
|
|
120
|
+
content.style.left = `${left}px`;
|
|
121
|
+
content.style.top = `${top}px`;
|
|
122
|
+
content.style.right = 'auto';
|
|
123
|
+
content.style.bottom = 'auto';
|
|
124
|
+
content.style.transform = 'translate(0, 0)';
|
|
125
|
+
};
|
|
126
|
+
if (isPortal) {
|
|
127
|
+
content.style.position = 'absolute';
|
|
128
|
+
window.addEventListener('resize', updatePosition);
|
|
129
|
+
window.addEventListener('scroll', updatePosition, true);
|
|
130
|
+
}
|
|
131
|
+
const setContent = (next) => {
|
|
132
|
+
let nextContent = next;
|
|
133
|
+
if (typeof nextContent === 'function') {
|
|
134
|
+
nextContent = nextContent();
|
|
135
|
+
}
|
|
136
|
+
body.innerHTML = '';
|
|
137
|
+
if (nextContent instanceof HTMLElement) {
|
|
138
|
+
body.appendChild(nextContent);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
body.textContent = nextContent ?? '';
|
|
142
|
+
}
|
|
143
|
+
updatePosition();
|
|
144
|
+
};
|
|
145
|
+
const setPlacement = (next) => {
|
|
146
|
+
placementPriority = Array.isArray(next) ? next : [next];
|
|
147
|
+
currentPlacement = placementPriority[0] ?? 'top';
|
|
148
|
+
updatePosition();
|
|
149
|
+
};
|
|
150
|
+
const setOpen = (value) => {
|
|
151
|
+
open = value;
|
|
152
|
+
content.setAttribute('data-open', String(open));
|
|
153
|
+
if (open)
|
|
154
|
+
updatePosition();
|
|
155
|
+
if (open && closeOnOutsideClick) {
|
|
156
|
+
document.addEventListener('click', handleOutsideClick, true);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
document.removeEventListener('click', handleOutsideClick, true);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const toggle = () => setOpen(!open);
|
|
163
|
+
const handleOutsideClick = (event) => {
|
|
164
|
+
const targetNode = event.target;
|
|
165
|
+
if (!container.contains(targetNode) &&
|
|
166
|
+
(isPortal ? !content.contains(targetNode) : true)) {
|
|
167
|
+
setOpen(false);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
let openTimer;
|
|
171
|
+
let closeTimer;
|
|
172
|
+
const hasHover = triggerActions.includes('hover');
|
|
173
|
+
const hasClick = triggerActions.includes('click');
|
|
174
|
+
const clearTimers = () => {
|
|
175
|
+
if (openTimer !== undefined) {
|
|
176
|
+
clearTimeout(openTimer);
|
|
177
|
+
openTimer = undefined;
|
|
178
|
+
}
|
|
179
|
+
if (closeTimer !== undefined) {
|
|
180
|
+
clearTimeout(closeTimer);
|
|
181
|
+
closeTimer = undefined;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const handleMouseEnter = () => {
|
|
185
|
+
if (!hasHover)
|
|
186
|
+
return;
|
|
187
|
+
clearTimers();
|
|
188
|
+
openTimer = window.setTimeout(() => setOpen(true), hoverOpenDelay);
|
|
189
|
+
};
|
|
190
|
+
const handleMouseLeave = () => {
|
|
191
|
+
if (!hasHover)
|
|
192
|
+
return;
|
|
193
|
+
clearTimers();
|
|
194
|
+
closeTimer = window.setTimeout(() => setOpen(false), hoverCloseDelay);
|
|
195
|
+
};
|
|
196
|
+
if (hasClick) {
|
|
197
|
+
trigger.addEventListener('click', toggle);
|
|
198
|
+
}
|
|
199
|
+
if (hasHover) {
|
|
200
|
+
container.addEventListener('mouseenter', handleMouseEnter);
|
|
201
|
+
container.addEventListener('mouseleave', handleMouseLeave);
|
|
202
|
+
content.addEventListener('mouseenter', handleMouseEnter);
|
|
203
|
+
content.addEventListener('mouseleave', handleMouseLeave);
|
|
204
|
+
}
|
|
205
|
+
setContent(props.content);
|
|
206
|
+
setPlacement(placement);
|
|
207
|
+
setOpen(open);
|
|
208
|
+
const api = {
|
|
209
|
+
setOpen,
|
|
210
|
+
toggle,
|
|
211
|
+
setContent,
|
|
212
|
+
setPlacement,
|
|
213
|
+
destroy: () => {
|
|
214
|
+
document.removeEventListener('click', handleOutsideClick, true);
|
|
215
|
+
if (hasClick)
|
|
216
|
+
trigger.removeEventListener('click', toggle);
|
|
217
|
+
if (hasHover) {
|
|
218
|
+
container.removeEventListener('mouseenter', handleMouseEnter);
|
|
219
|
+
container.removeEventListener('mouseleave', handleMouseLeave);
|
|
220
|
+
content.removeEventListener('mouseenter', handleMouseEnter);
|
|
221
|
+
content.removeEventListener('mouseleave', handleMouseLeave);
|
|
222
|
+
clearTimers();
|
|
223
|
+
}
|
|
224
|
+
if (isPortal) {
|
|
225
|
+
window.removeEventListener('resize', updatePosition);
|
|
226
|
+
window.removeEventListener('scroll', updatePosition, true);
|
|
227
|
+
content.remove();
|
|
228
|
+
}
|
|
229
|
+
container.remove();
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
return Object.assign(container, api);
|
|
233
|
+
}
|
|
234
|
+
function ensurePopoverStyle() {
|
|
235
|
+
injectStyleOnce(POPOVER_STYLE_ID, `
|
|
236
|
+
.${POPOVER_CLASS} {
|
|
237
|
+
position: relative;
|
|
238
|
+
display: inline-flex;
|
|
239
|
+
}
|
|
240
|
+
.${POPOVER_CONTENT_CLASS} {
|
|
241
|
+
position: absolute;
|
|
242
|
+
z-index: 1200;
|
|
243
|
+
padding: 0;
|
|
244
|
+
--popover-gap: 8px;
|
|
245
|
+
--popover-arrow-size: 8px;
|
|
246
|
+
--popover-arrow-inner-size: 7px;
|
|
247
|
+
background: #fff;
|
|
248
|
+
border-radius: 8px;
|
|
249
|
+
border: 1px solid rgba(239, 240, 240, 0.9);
|
|
250
|
+
box-shadow: rgba(0, 0, 0, 0.08) 0px 1px 2px -2px, rgba(0, 0, 0, 0.04) 0px 2px 6px, rgba(0, 0, 0, 0.02) 0px 4px 8px 1px;
|
|
251
|
+
opacity: 0;
|
|
252
|
+
visibility: hidden;
|
|
253
|
+
pointer-events: none;
|
|
254
|
+
transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
|
|
255
|
+
}
|
|
256
|
+
.${POPOVER_CONTENT_CLASS}-body {
|
|
257
|
+
padding: 4px;
|
|
258
|
+
color: #000000d9;
|
|
259
|
+
font-size: 12px;
|
|
260
|
+
line-height: 1.5;
|
|
261
|
+
}
|
|
262
|
+
.${POPOVER_CONTENT_CLASS}[data-open="true"] {
|
|
263
|
+
opacity: 1;
|
|
264
|
+
visibility: visible;
|
|
265
|
+
pointer-events: auto;
|
|
266
|
+
}
|
|
267
|
+
.${POPOVER_ARROW_CLASS} {
|
|
268
|
+
position: absolute;
|
|
269
|
+
width: 0;
|
|
270
|
+
height: 0;
|
|
271
|
+
}
|
|
272
|
+
.${POPOVER_ARROW_CLASS}::after {
|
|
273
|
+
content: '';
|
|
274
|
+
position: absolute;
|
|
275
|
+
width: 0;
|
|
276
|
+
height: 0;
|
|
277
|
+
}
|
|
278
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="top"] {
|
|
279
|
+
left: 50%;
|
|
280
|
+
bottom: calc(100% + var(--popover-gap));
|
|
281
|
+
transform: translate(-50%, calc(-1 * var(--popover-gap) / 2));
|
|
282
|
+
}
|
|
283
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="top"] .${POPOVER_ARROW_CLASS} {
|
|
284
|
+
left: 50%;
|
|
285
|
+
bottom: calc(-1 * var(--popover-arrow-size));
|
|
286
|
+
transform: translateX(-50%);
|
|
287
|
+
border-left: var(--popover-arrow-size) solid transparent;
|
|
288
|
+
border-right: var(--popover-arrow-size) solid transparent;
|
|
289
|
+
border-top: var(--popover-arrow-size) solid rgba(239, 240, 240, 0.9);
|
|
290
|
+
}
|
|
291
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="top"] .${POPOVER_ARROW_CLASS}::after {
|
|
292
|
+
left: 50%;
|
|
293
|
+
bottom: 1px;
|
|
294
|
+
transform: translateX(-50%);
|
|
295
|
+
border-left: var(--popover-arrow-inner-size) solid transparent;
|
|
296
|
+
border-right: var(--popover-arrow-inner-size) solid transparent;
|
|
297
|
+
border-top: var(--popover-arrow-inner-size) solid #fff;
|
|
298
|
+
}
|
|
299
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="top"][data-open="true"] {
|
|
300
|
+
transform: translate(-50%, 0);
|
|
301
|
+
}
|
|
302
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="bottom"] {
|
|
303
|
+
left: 50%;
|
|
304
|
+
top: calc(100% + var(--popover-gap));
|
|
305
|
+
transform: translate(-50%, calc(var(--popover-gap) / 2));
|
|
306
|
+
}
|
|
307
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="bottom"] .${POPOVER_ARROW_CLASS} {
|
|
308
|
+
left: 50%;
|
|
309
|
+
top: calc(-1 * var(--popover-arrow-size) + 2px);
|
|
310
|
+
transform: translateX(-50%);
|
|
311
|
+
border-left: var(--popover-arrow-size) solid transparent;
|
|
312
|
+
border-right: var(--popover-arrow-size) solid transparent;
|
|
313
|
+
border-bottom: var(--popover-arrow-size) solid rgba(239, 240, 240, 0.9);
|
|
314
|
+
}
|
|
315
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="bottom"] .${POPOVER_ARROW_CLASS}::after {
|
|
316
|
+
left: 50%;
|
|
317
|
+
top: 1px;
|
|
318
|
+
transform: translateX(-50%);
|
|
319
|
+
border-left: var(--popover-arrow-inner-size) solid transparent;
|
|
320
|
+
border-right: var(--popover-arrow-inner-size) solid transparent;
|
|
321
|
+
border-bottom: var(--popover-arrow-inner-size) solid #fff;
|
|
322
|
+
}
|
|
323
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="bottom"][data-open="true"] {
|
|
324
|
+
transform: translate(-50%, 0);
|
|
325
|
+
}
|
|
326
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="left"] {
|
|
327
|
+
right: calc(100% + var(--popover-gap));
|
|
328
|
+
top: 50%;
|
|
329
|
+
transform: translate(calc(-1 * var(--popover-gap) / 2), -50%);
|
|
330
|
+
}
|
|
331
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="left"] .${POPOVER_ARROW_CLASS} {
|
|
332
|
+
right: calc(-1 * var(--popover-arrow-size) + 1px);
|
|
333
|
+
top: 50%;
|
|
334
|
+
transform: translateY(-50%);
|
|
335
|
+
border-top: var(--popover-arrow-size) solid transparent;
|
|
336
|
+
border-bottom: var(--popover-arrow-size) solid transparent;
|
|
337
|
+
border-left: var(--popover-arrow-size) solid rgba(239, 240, 240, 0.9);
|
|
338
|
+
border-right: 0;
|
|
339
|
+
}
|
|
340
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="left"] .${POPOVER_ARROW_CLASS}::after {
|
|
341
|
+
right: 1px;
|
|
342
|
+
top: 50%;
|
|
343
|
+
transform: translateY(-50%);
|
|
344
|
+
border-top: var(--popover-arrow-inner-size) solid transparent;
|
|
345
|
+
border-bottom: var(--popover-arrow-inner-size) solid transparent;
|
|
346
|
+
border-left: var(--popover-arrow-inner-size) solid #fff;
|
|
347
|
+
border-right: 0;
|
|
348
|
+
}
|
|
349
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="left"][data-open="true"] {
|
|
350
|
+
transform: translate(0, -50%);
|
|
351
|
+
}
|
|
352
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="right"] {
|
|
353
|
+
left: calc(100% + var(--popover-gap));
|
|
354
|
+
top: 50%;
|
|
355
|
+
transform: translate(calc(var(--popover-gap) / 2), -50%);
|
|
356
|
+
}
|
|
357
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="right"] .${POPOVER_ARROW_CLASS} {
|
|
358
|
+
left: calc(-1 * var(--popover-arrow-size) + 1px);
|
|
359
|
+
top: 50%;
|
|
360
|
+
transform: translateY(-50%);
|
|
361
|
+
border-top: var(--popover-arrow-size) solid transparent;
|
|
362
|
+
border-bottom: var(--popover-arrow-size) solid transparent;
|
|
363
|
+
border-right: var(--popover-arrow-size) solid rgba(239, 240, 240, 0.9);
|
|
364
|
+
border-left: 0;
|
|
365
|
+
}
|
|
366
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="right"] .${POPOVER_ARROW_CLASS}::after {
|
|
367
|
+
left: 1px;
|
|
368
|
+
top: 50%;
|
|
369
|
+
transform: translateY(-50%);
|
|
370
|
+
border-top: var(--popover-arrow-inner-size) solid transparent;
|
|
371
|
+
border-bottom: var(--popover-arrow-inner-size) solid transparent;
|
|
372
|
+
border-right: var(--popover-arrow-inner-size) solid #fff;
|
|
373
|
+
}
|
|
374
|
+
.${POPOVER_CONTENT_CLASS}[data-placement="right"][data-open="true"] {
|
|
375
|
+
transform: translate(0, -50%);
|
|
376
|
+
}
|
|
377
|
+
`);
|
|
378
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type SelectValue = string;
|
|
2
|
+
export type SelectOption = {
|
|
3
|
+
label?: string;
|
|
4
|
+
value: SelectValue;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
render?: () => HTMLElement;
|
|
7
|
+
};
|
|
8
|
+
export type SelectProps = {
|
|
9
|
+
options: SelectOption[];
|
|
10
|
+
value?: SelectValue;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
onChange?: (value: SelectValue, option?: SelectOption) => void;
|
|
13
|
+
renderOption?: (option: SelectOption) => HTMLElement;
|
|
14
|
+
renderLabel?: (option: SelectOption | undefined) => HTMLElement | string | null | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type SelectHandle = {
|
|
17
|
+
setValue: (value: SelectValue) => void;
|
|
18
|
+
getValue: () => SelectValue | undefined;
|
|
19
|
+
setOptions: (options: SelectOption[]) => void;
|
|
20
|
+
destroy: () => void;
|
|
21
|
+
};
|
|
22
|
+
export declare function Select(props: SelectProps): HTMLDivElement & SelectHandle;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { injectStyleOnce } from '../../../../utils';
|
|
2
|
+
const SELECT_CLASS = 'infographic-edit-select';
|
|
3
|
+
const SELECT_STYLE_ID = 'infographic-edit-select-style';
|
|
4
|
+
const OPTION_CLASS = `${SELECT_CLASS}__option`;
|
|
5
|
+
const DROPDOWN_CLASS = `${SELECT_CLASS}__dropdown`;
|
|
6
|
+
const TRIGGER_CLASS = `${SELECT_CLASS}__trigger`;
|
|
7
|
+
const LABEL_CLASS = `${SELECT_CLASS}__label`;
|
|
8
|
+
const ARROW_CLASS = `${SELECT_CLASS}__arrow`;
|
|
9
|
+
export function Select(props) {
|
|
10
|
+
ensureSelectStyle();
|
|
11
|
+
let open = false;
|
|
12
|
+
let options = props.options || [];
|
|
13
|
+
let selected = props.value;
|
|
14
|
+
const container = document.createElement('div');
|
|
15
|
+
container.classList.add(SELECT_CLASS);
|
|
16
|
+
container.tabIndex = 0;
|
|
17
|
+
const trigger = document.createElement('button');
|
|
18
|
+
trigger.type = 'button';
|
|
19
|
+
trigger.classList.add(TRIGGER_CLASS);
|
|
20
|
+
const label = document.createElement('span');
|
|
21
|
+
label.classList.add(LABEL_CLASS);
|
|
22
|
+
trigger.appendChild(label);
|
|
23
|
+
const arrow = document.createElement('span');
|
|
24
|
+
arrow.classList.add(ARROW_CLASS);
|
|
25
|
+
arrow.textContent = 'v';
|
|
26
|
+
trigger.appendChild(arrow);
|
|
27
|
+
const dropdown = document.createElement('div');
|
|
28
|
+
dropdown.classList.add(DROPDOWN_CLASS);
|
|
29
|
+
dropdown.setAttribute('data-open', 'false');
|
|
30
|
+
container.appendChild(trigger);
|
|
31
|
+
container.appendChild(dropdown);
|
|
32
|
+
const handleDocumentClick = (event) => {
|
|
33
|
+
if (!container.contains(event.target)) {
|
|
34
|
+
setOpen(false);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const renderLabel = () => {
|
|
38
|
+
const option = options.find((opt) => opt.value === selected);
|
|
39
|
+
const custom = props.renderLabel?.(option);
|
|
40
|
+
if (typeof custom === 'string') {
|
|
41
|
+
label.textContent = custom;
|
|
42
|
+
}
|
|
43
|
+
else if (custom instanceof HTMLElement) {
|
|
44
|
+
label.replaceChildren(custom);
|
|
45
|
+
}
|
|
46
|
+
else if (custom === null || custom === undefined) {
|
|
47
|
+
if (option) {
|
|
48
|
+
label.textContent = option.label ?? option.value;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
label.textContent = props.placeholder ?? '请选择';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
label.textContent = String(custom);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const renderOptions = () => {
|
|
59
|
+
dropdown.innerHTML = '';
|
|
60
|
+
options.forEach((option) => {
|
|
61
|
+
const optionNode = props.renderOption?.(option) ??
|
|
62
|
+
option.render?.() ??
|
|
63
|
+
defaultOptionNode(option);
|
|
64
|
+
optionNode.classList.add(OPTION_CLASS);
|
|
65
|
+
optionNode.setAttribute('data-value', option.value);
|
|
66
|
+
if (option.disabled) {
|
|
67
|
+
optionNode.setAttribute('aria-disabled', 'true');
|
|
68
|
+
optionNode.classList.add(`${OPTION_CLASS}--disabled`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
optionNode.addEventListener('click', () => {
|
|
72
|
+
selectValue(option.value, option);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
dropdown.appendChild(optionNode);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const selectValue = (value, option) => {
|
|
79
|
+
selected = value;
|
|
80
|
+
renderLabel();
|
|
81
|
+
props.onChange?.(value, option);
|
|
82
|
+
setOpen(false);
|
|
83
|
+
};
|
|
84
|
+
const setOpen = (value) => {
|
|
85
|
+
open = value;
|
|
86
|
+
dropdown.setAttribute('data-open', String(open));
|
|
87
|
+
container.setAttribute('data-open', String(open));
|
|
88
|
+
if (open) {
|
|
89
|
+
document.addEventListener('click', handleDocumentClick);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
document.removeEventListener('click', handleDocumentClick);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
trigger.addEventListener('click', () => setOpen(!open));
|
|
96
|
+
renderLabel();
|
|
97
|
+
renderOptions();
|
|
98
|
+
const api = {
|
|
99
|
+
setValue: (value) => {
|
|
100
|
+
selected = value;
|
|
101
|
+
renderLabel();
|
|
102
|
+
},
|
|
103
|
+
getValue: () => selected,
|
|
104
|
+
setOptions: (nextOptions) => {
|
|
105
|
+
options = nextOptions;
|
|
106
|
+
renderOptions();
|
|
107
|
+
renderLabel();
|
|
108
|
+
},
|
|
109
|
+
destroy: () => {
|
|
110
|
+
document.removeEventListener('click', handleDocumentClick);
|
|
111
|
+
container.remove();
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
return Object.assign(container, api);
|
|
115
|
+
}
|
|
116
|
+
function ensureSelectStyle() {
|
|
117
|
+
injectStyleOnce(SELECT_STYLE_ID, `
|
|
118
|
+
.${SELECT_CLASS} {
|
|
119
|
+
position: relative;
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
min-width: 140px;
|
|
122
|
+
font-family: "Helvetica Neue", Arial, sans-serif;
|
|
123
|
+
}
|
|
124
|
+
.${TRIGGER_CLASS} {
|
|
125
|
+
width: 100%;
|
|
126
|
+
height: 32px;
|
|
127
|
+
padding: 4px 28px 4px 8px;
|
|
128
|
+
background: #fff;
|
|
129
|
+
border: 1px solid #d9d9d9;
|
|
130
|
+
border-radius: 6px;
|
|
131
|
+
color: #000000d9;
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
outline: none;
|
|
134
|
+
display: inline-flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
justify-content: space-between;
|
|
137
|
+
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
138
|
+
}
|
|
139
|
+
.${TRIGGER_CLASS}:hover {
|
|
140
|
+
border-color: #4096ff;
|
|
141
|
+
}
|
|
142
|
+
.${TRIGGER_CLASS}:focus-visible {
|
|
143
|
+
border-color: #4096ff;
|
|
144
|
+
box-shadow: 0 0 0 2px rgba(64, 150, 255, 0.2);
|
|
145
|
+
}
|
|
146
|
+
.${LABEL_CLASS} {
|
|
147
|
+
flex: 1;
|
|
148
|
+
text-align: left;
|
|
149
|
+
overflow: hidden;
|
|
150
|
+
text-overflow: ellipsis;
|
|
151
|
+
white-space: nowrap;
|
|
152
|
+
}
|
|
153
|
+
.${ARROW_CLASS} {
|
|
154
|
+
display: inline-flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
margin-left: 6px;
|
|
157
|
+
font-size: 10px;
|
|
158
|
+
color: #8c8c8c;
|
|
159
|
+
}
|
|
160
|
+
.${DROPDOWN_CLASS} {
|
|
161
|
+
position: absolute;
|
|
162
|
+
left: 0;
|
|
163
|
+
right: 0;
|
|
164
|
+
top: calc(100% + 4px);
|
|
165
|
+
background: #fff;
|
|
166
|
+
border: 1px solid #e5e5e5;
|
|
167
|
+
border-radius: 6px;
|
|
168
|
+
box-shadow: 0 6px 16px rgba(0,0,0,0.08), 0 3px 6px -4px rgba(0,0,0,0.12), 0 9px 28px 8px rgba(0,0,0,0.05);
|
|
169
|
+
padding: 4px 0;
|
|
170
|
+
z-index: 1000;
|
|
171
|
+
max-height: 200px;
|
|
172
|
+
overflow-y: auto;
|
|
173
|
+
display: none;
|
|
174
|
+
}
|
|
175
|
+
.${DROPDOWN_CLASS}[data-open="true"] {
|
|
176
|
+
display: block;
|
|
177
|
+
}
|
|
178
|
+
.${OPTION_CLASS} {
|
|
179
|
+
padding: 6px 12px;
|
|
180
|
+
font-size: 12px;
|
|
181
|
+
color: #000000d9;
|
|
182
|
+
cursor: pointer;
|
|
183
|
+
line-height: 1.5;
|
|
184
|
+
}
|
|
185
|
+
.${OPTION_CLASS}:hover {
|
|
186
|
+
background: #f5f5f5;
|
|
187
|
+
}
|
|
188
|
+
.${OPTION_CLASS}--disabled {
|
|
189
|
+
color: #bfbfbf;
|
|
190
|
+
cursor: not-allowed;
|
|
191
|
+
}
|
|
192
|
+
.${OPTION_CLASS}--disabled:hover {
|
|
193
|
+
background: transparent;
|
|
194
|
+
}
|
|
195
|
+
`);
|
|
196
|
+
}
|
|
197
|
+
function defaultOptionNode(option) {
|
|
198
|
+
const node = document.createElement('div');
|
|
199
|
+
node.textContent = option.label ?? option.value;
|
|
200
|
+
return node;
|
|
201
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TextElement } from '../../../types';
|
|
2
|
+
import type { IPlugin, PluginInitOptions, Selection } from '../../types';
|
|
3
|
+
import { Plugin } from '../base';
|
|
4
|
+
export interface EditBarOptions {
|
|
5
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
6
|
+
className?: string;
|
|
7
|
+
getContainer?: HTMLElement | (() => HTMLElement);
|
|
8
|
+
}
|
|
9
|
+
type EditItem = HTMLElement;
|
|
10
|
+
export declare class EditBar extends Plugin implements IPlugin {
|
|
11
|
+
private options?;
|
|
12
|
+
name: string;
|
|
13
|
+
private container?;
|
|
14
|
+
private selection;
|
|
15
|
+
constructor(options?: EditBarOptions | undefined);
|
|
16
|
+
init(options: PluginInitOptions): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
private handleSelectionChanged;
|
|
19
|
+
private handleGeometryChanged;
|
|
20
|
+
private handleHistoryChanged;
|
|
21
|
+
protected getEditItems(selection: Selection): HTMLElement[];
|
|
22
|
+
protected getOrCreateEditBar(): HTMLDivElement;
|
|
23
|
+
protected getTextEditItems(text: TextElement): EditItem[];
|
|
24
|
+
protected getTextCollectionEditItems(selection: TextElement[]): EditItem[];
|
|
25
|
+
protected getIconEditItems(selection: Selection): EditItem[];
|
|
26
|
+
protected getIconCollectionEditItems(selection: Selection): EditItem[];
|
|
27
|
+
protected getGeometryEditItems(_selection: Selection): EditItem[];
|
|
28
|
+
protected getGeometryCollectionEditItems(selection: Selection): EditItem[];
|
|
29
|
+
protected getElementCollectionEditItems(selection: Selection): EditItem[];
|
|
30
|
+
private placeEditBar;
|
|
31
|
+
}
|
|
32
|
+
export {};
|