@oliasoft-open-source/charts-library 4.7.0-beta-4 → 4.7.0-beta-6

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/index.js CHANGED
@@ -11,7 +11,7 @@ import React__default, { forwardRef, useRef, useEffect, createContext as createC
11
11
  import { produce } from "immer";
12
12
  import { round as round$2, displayNumber, isCloseTo, roundByMagnitude } from "@oliasoft-open-source/units";
13
13
  import cx from "classnames";
14
- import { Portal, Icon, Menu, Tooltip as Tooltip$2, Button, Flex, Text, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer } from "@oliasoft-open-source/react-ui-library";
14
+ import { Portal, Icon, Menu, Tooltip as Tooltip$2, Button, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer, Flex, Text } from "@oliasoft-open-source/react-ui-library";
15
15
  import { isEmpty, isArray as isArray$2, some, has, cloneDeep, defaultTo, findIndex, set as set$2, debounce as debounce$3, isNil, map as map$3, find, get as get$1 } from "lodash";
16
16
  /*!
17
17
  * @kurkle/color v0.3.2
@@ -22892,20 +22892,7 @@ function getLineOptions({
22892
22892
  }
22893
22893
  ];
22894
22894
  }
22895
- const LineOptions = ({
22896
- lineEnabled,
22897
- onToggleLine,
22898
- onTogglePoints,
22899
- pointsEnabled,
22900
- translations
22901
- }) => {
22902
- const options = getLineOptions({
22903
- lineEnabled,
22904
- onToggleLine,
22905
- onTogglePoints,
22906
- pointsEnabled,
22907
- translations
22908
- });
22895
+ const LineOptions = ({ options }) => {
22909
22896
  const [menuOpen, setMenuOpen] = useState(false);
22910
22897
  const selectedOption = options.find((option) => option.selected);
22911
22898
  return /* @__PURE__ */ jsx(
@@ -23055,7 +23042,6 @@ function getDragOptions({
23055
23042
  dragToZoom,
23056
23043
  doubleClickToReset,
23057
23044
  dragToPan,
23058
- orDoubleClickToCanvas,
23059
23045
  dragToMovePoints,
23060
23046
  dragDisabled,
23061
23047
  dragToMoveAnnotation
@@ -23063,24 +23049,26 @@ function getDragOptions({
23063
23049
  }) {
23064
23050
  return [
23065
23051
  {
23066
- buttonLabel: dragToZoom,
23067
- label: /* @__PURE__ */ jsxs(Flex, { direction: "column", children: [
23068
- /* @__PURE__ */ jsx(Text, { children: "Drag to zoom" }),
23069
- /* @__PURE__ */ jsx(Text, { small: true, muted: true, children: doubleClickToReset })
23070
- ] }),
23052
+ label: dragToZoom,
23053
+ description: doubleClickToReset,
23071
23054
  icon: /* @__PURE__ */ jsx(TbZoomIn, {}),
23072
23055
  selected: zoomEnabled,
23073
- onClick: onToggleZoom
23056
+ type: "Option",
23057
+ onClick: () => {
23058
+ if (!zoomEnabled)
23059
+ onToggleZoom();
23060
+ }
23074
23061
  },
23075
23062
  {
23076
- buttonLabel: dragToPan,
23077
- label: /* @__PURE__ */ jsxs(Flex, { direction: "column", children: [
23078
- /* @__PURE__ */ jsx(Text, { children: "Drag to pan" }),
23079
- /* @__PURE__ */ jsx(Text, { small: true, muted: true, children: orDoubleClickToCanvas })
23080
- ] }),
23063
+ label: dragToPan,
23064
+ description: doubleClickToReset,
23081
23065
  icon: /* @__PURE__ */ jsx(TbArrowsMove, {}),
23082
23066
  selected: panEnabled,
23083
- onClick: onTogglePan
23067
+ type: "Option",
23068
+ onClick: () => {
23069
+ if (!panEnabled)
23070
+ onTogglePan();
23071
+ }
23084
23072
  },
23085
23073
  ...isDragDataAllowed ? [
23086
23074
  {
@@ -23088,7 +23076,10 @@ function getDragOptions({
23088
23076
  icon: /* @__PURE__ */ jsx(TbHandStop, {}),
23089
23077
  selected: enableDragPoints,
23090
23078
  type: "Option",
23091
- onClick: onToggleDragPoints
23079
+ onClick: () => {
23080
+ if (!enableDragPoints)
23081
+ onToggleDragPoints();
23082
+ }
23092
23083
  }
23093
23084
  ] : [],
23094
23085
  ...isDragAnnotationAllowed ? [
@@ -23097,79 +23088,28 @@ function getDragOptions({
23097
23088
  icon: /* @__PURE__ */ jsx(TbHandStop, {}),
23098
23089
  selected: enableDragAnnotation,
23099
23090
  type: "Option",
23100
- onClick: onToggleDragAnnotation
23091
+ onClick: () => {
23092
+ if (!enableDragAnnotation)
23093
+ onToggleDragAnnotation();
23094
+ }
23101
23095
  }
23102
23096
  ] : [],
23103
23097
  {
23104
23098
  label: dragDisabled,
23105
23099
  icon: /* @__PURE__ */ jsx(TbBan, {}),
23106
23100
  selected: !zoomEnabled && !panEnabled && !enableDragPoints && !enableDragAnnotation,
23101
+ type: "Option",
23107
23102
  onClick: onDisableDragOptions
23108
23103
  }
23109
23104
  ];
23110
23105
  }
23111
- const DragOptions = ({
23112
- onTogglePan,
23113
- onToggleZoom,
23114
- panEnabled,
23115
- zoomEnabled,
23116
- enableDragPoints,
23117
- enableDragAnnotation,
23118
- isDragDataAllowed,
23119
- isDragAnnotationAllowed,
23120
- onToggleDragAnnotation,
23121
- onToggleDragPoints,
23122
- onDisableDragOptions,
23123
- translations: {
23124
- dragToZoom,
23125
- doubleClickToReset,
23126
- dragToPan,
23127
- orDoubleClickToCanvas,
23128
- dragToMovePoints,
23129
- dragDisabled,
23130
- dragToMoveAnnotation
23131
- }
23132
- }) => {
23133
- const options = useMemo(
23134
- () => getDragOptions({
23135
- onTogglePan,
23136
- onToggleZoom,
23137
- panEnabled,
23138
- zoomEnabled,
23139
- enableDragPoints,
23140
- enableDragAnnotation,
23141
- isDragDataAllowed,
23142
- isDragAnnotationAllowed,
23143
- onToggleDragAnnotation,
23144
- onToggleDragPoints,
23145
- onDisableDragOptions,
23146
- translations: {
23147
- dragToZoom,
23148
- doubleClickToReset,
23149
- dragToPan,
23150
- orDoubleClickToCanvas,
23151
- dragToMovePoints,
23152
- dragDisabled,
23153
- dragToMoveAnnotation
23154
- }
23155
- }),
23156
- [zoomEnabled, panEnabled, enableDragPoints, isDragDataAllowed]
23157
- );
23106
+ const DragOptions = ({ options }) => {
23158
23107
  const selectedOption = options.find((option) => option.selected);
23159
- const optionsWithDragPoints = options.map(
23160
- ({ icon, label, onClick, selected }) => ({
23161
- icon,
23162
- label,
23163
- type: "Option",
23164
- onClick,
23165
- disabled: selected
23166
- })
23167
- );
23168
23108
  return /* @__PURE__ */ jsx(
23169
23109
  Menu,
23170
23110
  {
23171
23111
  menu: {
23172
- sections: optionsWithDragPoints,
23112
+ sections: options,
23173
23113
  trigger: "Component",
23174
23114
  component: /* @__PURE__ */ jsx(
23175
23115
  Button,
@@ -23177,7 +23117,7 @@ const DragOptions = ({
23177
23117
  colored: "muted",
23178
23118
  basic: true,
23179
23119
  small: true,
23180
- label: (selectedOption == null ? void 0 : selectedOption.buttonLabel) || (selectedOption == null ? void 0 : selectedOption.label),
23120
+ label: selectedOption == null ? void 0 : selectedOption.label,
23181
23121
  icon: selectedOption == null ? void 0 : selectedOption.icon
23182
23122
  }
23183
23123
  )
@@ -24641,6 +24581,39 @@ const Controls = ({
24641
24581
  });
24642
24582
  const [measureRef, { width }] = useMeasure$1();
24643
24583
  const isNarrow = width < 200;
24584
+ const lineOptions = useMemo(
24585
+ () => getLineOptions({
24586
+ lineEnabled,
24587
+ onToggleLine,
24588
+ onTogglePoints,
24589
+ pointsEnabled,
24590
+ translations
24591
+ }),
24592
+ [lineEnabled, pointsEnabled]
24593
+ );
24594
+ const dragOptions = useMemo(
24595
+ () => getDragOptions({
24596
+ onTogglePan,
24597
+ onToggleZoom,
24598
+ panEnabled,
24599
+ zoomEnabled,
24600
+ enableDragPoints,
24601
+ enableDragAnnotation,
24602
+ isDragDataAllowed: dragData == null ? void 0 : dragData.enableDragData,
24603
+ isDragAnnotationAllowed: annotations == null ? void 0 : annotations.enableDragAnnotation,
24604
+ onToggleDragAnnotation,
24605
+ onToggleDragPoints,
24606
+ onDisableDragOptions,
24607
+ translations
24608
+ }),
24609
+ [
24610
+ zoomEnabled,
24611
+ panEnabled,
24612
+ enableDragPoints,
24613
+ dragData == null ? void 0 : dragData.enableDragData,
24614
+ annotations == null ? void 0 : annotations.enableDragAnnotation
24615
+ ]
24616
+ );
24644
24617
  return /* @__PURE__ */ jsxs(Fragment, { children: [
24645
24618
  /* @__PURE__ */ jsxs("div", { className: styles$4.controls, children: [
24646
24619
  !!options.title && /* @__PURE__ */ jsx(Text, { bold: true, children: options.title }),
@@ -24670,36 +24643,11 @@ const Controls = ({
24670
24643
  menu: {
24671
24644
  placement: "bottom-end",
24672
24645
  sections: [
24673
- ...getLineOptions({
24674
- lineEnabled,
24675
- onToggleLine,
24676
- onTogglePoints,
24677
- pointsEnabled,
24678
- translations
24679
- }).map((option) => ({
24680
- ...option,
24681
- type: "Option"
24682
- })),
24646
+ ...lineOptions,
24683
24647
  {
24684
24648
  type: "Divider"
24685
24649
  },
24686
- ...getDragOptions({
24687
- onTogglePan,
24688
- onToggleZoom,
24689
- panEnabled,
24690
- zoomEnabled,
24691
- enableDragPoints,
24692
- enableDragAnnotation,
24693
- isDragDataAllowed: dragData == null ? void 0 : dragData.enableDragData,
24694
- isDragAnnotationAllowed: annotations == null ? void 0 : annotations.enableDragAnnotation,
24695
- onToggleDragAnnotation,
24696
- onToggleDragPoints,
24697
- onDisableDragOptions,
24698
- translations
24699
- }).map((option) => ({
24700
- ...option,
24701
- type: "Option"
24702
- })),
24650
+ ...dragOptions,
24703
24651
  {
24704
24652
  type: "Divider"
24705
24653
  },
@@ -24715,16 +24663,7 @@ const Controls = ({
24715
24663
  }
24716
24664
  }
24717
24665
  ) : /* @__PURE__ */ jsxs(Fragment, { children: [
24718
- /* @__PURE__ */ jsx(
24719
- LineOptions,
24720
- {
24721
- lineEnabled,
24722
- pointsEnabled,
24723
- onToggleLine,
24724
- onTogglePoints,
24725
- translations
24726
- }
24727
- ),
24666
+ /* @__PURE__ */ jsx(LineOptions, { options: lineOptions }),
24728
24667
  /* @__PURE__ */ jsx(
24729
24668
  Tooltip$2,
24730
24669
  {
@@ -24744,23 +24683,7 @@ const Controls = ({
24744
24683
  )
24745
24684
  }
24746
24685
  ),
24747
- /* @__PURE__ */ jsx(
24748
- DragOptions,
24749
- {
24750
- panEnabled,
24751
- zoomEnabled,
24752
- onTogglePan,
24753
- onToggleZoom,
24754
- enableDragPoints,
24755
- enableDragAnnotation,
24756
- isDragDataAllowed: dragData == null ? void 0 : dragData.enableDragData,
24757
- isDragAnnotationAllowed: annotations == null ? void 0 : annotations.enableDragAnnotation,
24758
- onToggleDragAnnotation,
24759
- onToggleDragPoints,
24760
- onDisableDragOptions,
24761
- translations
24762
- }
24763
- )
24686
+ /* @__PURE__ */ jsx(DragOptions, { options: dragOptions })
24764
24687
  ] })
24765
24688
  ] }),
24766
24689
  table2 ? /* @__PURE__ */ jsx(