@spaziodati/atoka-design-system 10.1.0 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ import Col from "react-bootstrap/Col";
7
7
  import { f as findChildByComponent } from "../_shared/Utils-CXFvxozf.js";
8
8
  import { F as Form } from "../_shared/Form-l9l_S-Uk.js";
9
9
  import classnames from "classnames";
10
- import { S as SelectDropdown } from "../_shared/SelectDropdown-BqLfmaLM.js";
10
+ import { S as SelectDropdown } from "../_shared/SelectDropdown-GHblwuD9.js";
11
11
  import { faList } from "@fortawesome/pro-light-svg-icons/faList";
12
12
  import { faTh } from "@fortawesome/pro-light-svg-icons/faTh";
13
13
  import { T as ToggleButtonGroup } from "../_shared/ToggleButtonGroup-Duq22aii.js";
@@ -1,4 +1,4 @@
1
- import { D } from "../_shared/DatePicker-B83yTQAi.js";
1
+ import { D } from "../_shared/DatePicker-DLES5hkO.js";
2
2
  export {
3
3
  D as DatePicker
4
4
  };
@@ -5,7 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
5
  import { faTimes } from "@fortawesome/pro-light-svg-icons/faTimes";
6
6
  import { a as FormControl } from "../_shared/Form-l9l_S-Uk.js";
7
7
  import { I as InputGroupComponent } from "../_shared/InputGroupShortcut-B6ccNgw4.js";
8
- import { M as MultiModeDatePicker } from "../_shared/MultiModeDatePicker-ZX2nGY4n.js";
8
+ import { M as MultiModeDatePicker } from "../_shared/MultiModeDatePicker-BVFPSsWL.js";
9
9
  function useClickOutside(callback) {
10
10
  const ref = React__default.useRef(null);
11
11
  useEffect(() => {
@@ -7,7 +7,7 @@ import "../_shared/Form-l9l_S-Uk.js";
7
7
  import { c as isStringEmpty } from "../_shared/Text-DT1G7-vq.js";
8
8
  import "../_shared/Style-CSNnkrg3.js";
9
9
  import { B as Button } from "../_shared/Button-Bn8PyQFK.js";
10
- import { I as InlineStringEditor } from "../_shared/InlineStringEditor-mo49_wqf.js";
10
+ import { I as InlineStringEditor } from "../_shared/InlineStringEditor-Qd51lEZm.js";
11
11
  import { _ as _inheritsLoose, a as _extends, b as _objectWithoutPropertiesLoose, T as TransitionGroupContext, P as PropTypes, C as CSSTransition } from "../_shared/CSSTransition-BGcESi-j.js";
12
12
  function _assertThisInitialized(e) {
13
13
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -1,4 +1,4 @@
1
- import { I } from "../_shared/InlineStringEditor-mo49_wqf.js";
1
+ import { I } from "../_shared/InlineStringEditor-Qd51lEZm.js";
2
2
  export {
3
3
  I as InlineStringEditor
4
4
  };
@@ -1,4 +1,4 @@
1
- import { M } from "../_shared/MultiModeDatePicker-ZX2nGY4n.js";
1
+ import { M } from "../_shared/MultiModeDatePicker-BVFPSsWL.js";
2
2
  export {
3
3
  M as MultiModeDatePicker
4
4
  };
@@ -16,17 +16,25 @@ export interface SelectDropdownProps extends PropsWithClassName {
16
16
  direction?: 'up' | 'down';
17
17
  isFixed?: boolean;
18
18
  }
19
+ interface SelectDropdownState {
20
+ isInsideModal: boolean;
21
+ }
19
22
  /**
20
23
  * ### Overview
21
24
  *
22
25
  * The `SelectDropdown` allows users to either filter or sort items in a list according to specific parameters.
23
26
  */
24
- export declare class SelectDropdown extends React.PureComponent<React.PropsWithChildren<SelectDropdownProps>> {
27
+ export declare class SelectDropdown extends React.PureComponent<React.PropsWithChildren<SelectDropdownProps>, SelectDropdownState> {
25
28
  static displayName: string;
26
29
  static defaultProps: Partial<SelectDropdownProps>;
30
+ private wrapperRef;
31
+ state: SelectDropdownState;
32
+ componentDidMount(): void;
33
+ private get isEffectivelyFixed();
27
34
  private renderOptions;
28
35
  private renderItem;
29
36
  private renderSelectedValue;
30
37
  private get popperConfig();
31
38
  render(): React.ReactNode;
32
39
  }
40
+ export {};
@@ -1,4 +1,4 @@
1
- import { S } from "../_shared/SelectDropdown-BqLfmaLM.js";
1
+ import { S } from "../_shared/SelectDropdown-GHblwuD9.js";
2
2
  export {
3
3
  S as SelectDropdown
4
4
  };
@@ -7,7 +7,7 @@ import ReactDOM__default from "react-dom";
7
7
  import { faChevronLeft } from "@fortawesome/pro-regular-svg-icons/faChevronLeft";
8
8
  import { faChevronRight } from "@fortawesome/pro-regular-svg-icons/faChevronRight";
9
9
  import { B as Button } from "./Button-Bn8PyQFK.js";
10
- import { S as SelectDropdown } from "./SelectDropdown-BqLfmaLM.js";
10
+ import { S as SelectDropdown } from "./SelectDropdown-GHblwuD9.js";
11
11
  function r(e) {
12
12
  var t, f, n = "";
13
13
  if ("string" == typeof e || "number" == typeof e) n += e;
@@ -6,7 +6,7 @@ import { faTimes } from "@fortawesome/pro-light-svg-icons/faTimes";
6
6
  import classnames from "classnames";
7
7
  import { B as Button } from "./Button-Bn8PyQFK.js";
8
8
  import { F as Form, a as FormControl } from "./Form-l9l_S-Uk.js";
9
- import { S as SelectDropdown } from "./SelectDropdown-BqLfmaLM.js";
9
+ import { S as SelectDropdown } from "./SelectDropdown-GHblwuD9.js";
10
10
  class InlineStringEditor extends React__default.Component {
11
11
  static displayName = "InlineStringEditor";
12
12
  static defaultProps = {
@@ -3,7 +3,7 @@ import { useState } from "react";
3
3
  import Col from "react-bootstrap/Col";
4
4
  import Row from "react-bootstrap/Row";
5
5
  import { B as Button } from "./Button-Bn8PyQFK.js";
6
- import { D as DatePicker, p as parse } from "./DatePicker-B83yTQAi.js";
6
+ import { D as DatePicker, p as parse } from "./DatePicker-DLES5hkO.js";
7
7
  import { T as TabSwitcher } from "./TabSwitcher-jXRZG1zt.js";
8
8
  import { b as FormControlFeedBack, a as FormControl } from "./Form-l9l_S-Uk.js";
9
9
  const formatOptions = {
@@ -3,6 +3,35 @@ import React__default from "react";
3
3
  import BsDropdown from "react-bootstrap/Dropdown";
4
4
  import classnames from "classnames";
5
5
  import { D as Dropdown, a as AtokaCustomDropdownToggleWithChevron } from "./AtokaDropdownToggles-B6q-ieDU.js";
6
+ function fixedPositionFromRectFn({ state }) {
7
+ const reference = state.elements.reference;
8
+ const toggle = reference.closest?.(".atoka-select-dropdown")?.querySelector(".atoka-dropdown-toggle") ?? reference;
9
+ const rect = toggle.getBoundingClientRect();
10
+ state.styles.popper = {
11
+ ...state.styles.popper,
12
+ position: "fixed",
13
+ top: `${rect.bottom}px`,
14
+ left: `${rect.left}px`,
15
+ right: "auto",
16
+ bottom: "auto",
17
+ width: `${rect.width}px`,
18
+ transform: "none",
19
+ margin: "0"
20
+ };
21
+ }
22
+ const FIXED_POPPER_MODIFIERS = [
23
+ {
24
+ name: "fixedPositionFromRect",
25
+ enabled: true,
26
+ phase: "beforeWrite",
27
+ requires: ["computeStyles"],
28
+ fn: fixedPositionFromRectFn
29
+ },
30
+ {
31
+ name: "offset",
32
+ enabled: false
33
+ }
34
+ ];
6
35
  class SelectDropdown extends React__default.PureComponent {
7
36
  static displayName = "SelectDropdown";
8
37
  static defaultProps = {
@@ -10,6 +39,16 @@ class SelectDropdown extends React__default.PureComponent {
10
39
  placeholder: "--",
11
40
  direction: "down"
12
41
  };
42
+ wrapperRef = React__default.createRef();
43
+ state = { isInsideModal: false };
44
+ componentDidMount() {
45
+ if (this.wrapperRef.current?.closest(".modal")) {
46
+ this.setState({ isInsideModal: true });
47
+ }
48
+ }
49
+ get isEffectivelyFixed() {
50
+ return this.props.isFixed || this.state.isInsideModal;
51
+ }
13
52
  renderOptions() {
14
53
  return this.props.options.map(this.renderItem);
15
54
  }
@@ -32,41 +71,29 @@ class SelectDropdown extends React__default.PureComponent {
32
71
  return this.props.renderSelectedValue?.(selection) ?? selection.label;
33
72
  }
34
73
  get popperConfig() {
35
- if (!this.props.isFixed) {
74
+ if (!this.isEffectivelyFixed) {
36
75
  return void 0;
37
76
  }
38
77
  return {
39
78
  strategy: "fixed",
40
- modifiers: [
41
- {
42
- name: "sameWidth",
43
- enabled: true,
44
- phase: "beforeWrite",
45
- requires: ["computeStyles"],
46
- fn: ({ state }) => {
47
- state.styles.popper.width = `${state.rects.reference.width}px`;
48
- },
49
- effect: ({ state }) => {
50
- const element = state.elements.reference;
51
- state.elements.popper.style.width = `${element.offsetWidth}px`;
52
- }
53
- }
54
- ]
79
+ modifiers: FIXED_POPPER_MODIFIERS
55
80
  };
56
81
  }
57
82
  render() {
83
+ const isFixed = this.isEffectivelyFixed;
58
84
  const classNames = classnames("atoka-select-dropdown", this.props.className, this.props.size, {
59
85
  "is-invalid": this.props.isInvalid,
60
- "position-static": this.props.isFixed
86
+ "position-static": isFixed,
87
+ "is-fixed": isFixed
61
88
  }), menuClassNames = classnames(
62
89
  "atoka-select-dropdown-menu",
63
90
  this.props.size,
64
91
  this.props.menuClassName
65
92
  );
66
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(Dropdown, { onSelect: this.props.onSelect, className: classNames, drop: this.props.direction, children: [
93
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: this.wrapperRef, style: { display: "contents" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Dropdown, { onSelect: this.props.onSelect, className: classNames, drop: this.props.direction, children: [
67
94
  /* @__PURE__ */ jsxRuntimeExports.jsx(Dropdown.Toggle, { disabled: this.props.disabled, as: AtokaCustomDropdownToggleWithChevron, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "dropdown-toggle-text-container", children: this.renderSelectedValue() }) }),
68
95
  /* @__PURE__ */ jsxRuntimeExports.jsx(BsDropdown.Menu, { className: menuClassNames, flip: false, popperConfig: this.popperConfig, children: this.renderOptions() })
69
- ] });
96
+ ] }) });
70
97
  }
71
98
  }
72
99
  export {