tgui-core 1.8.4 → 2.0.1

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.
Files changed (82) hide show
  1. package/dist/common/constants.d.ts +4 -0
  2. package/dist/common/constants.js +17 -0
  3. package/dist/common/hotkeys.js +48 -48
  4. package/dist/common/ui.d.ts +6 -0
  5. package/dist/common/ui.js +63 -59
  6. package/dist/components/AnimatedNumber.d.ts +1 -1
  7. package/dist/components/Button.d.ts +3 -3
  8. package/dist/components/Button.js +21 -22
  9. package/dist/components/Chart.d.ts +3 -15
  10. package/dist/components/Chart.js +68 -86
  11. package/dist/components/ColorBox.js +3 -3
  12. package/dist/components/Dialog.d.ts +16 -0
  13. package/dist/components/Dialog.js +5 -5
  14. package/dist/components/DmIcon.d.ts +1 -1
  15. package/dist/components/DraggableControl.d.ts +56 -0
  16. package/dist/components/DraggableControl.js +126 -176
  17. package/dist/components/Dropdown.d.ts +8 -6
  18. package/dist/components/Dropdown.js +137 -129
  19. package/dist/components/FitText.d.ts +1 -1
  20. package/dist/components/Floating.d.ts +75 -0
  21. package/dist/components/Floating.js +2235 -0
  22. package/dist/components/ImageButton.d.ts +2 -3
  23. package/dist/components/ImageButton.js +88 -98
  24. package/dist/components/InfinitePlane.d.ts +35 -32
  25. package/dist/components/InfinitePlane.js +123 -133
  26. package/dist/components/Knob.d.ts +22 -6
  27. package/dist/components/Knob.js +45 -46
  28. package/dist/components/MenuBar.js +81 -97
  29. package/dist/components/Modal.js +12 -12
  30. package/dist/components/NumberInput.d.ts +1 -1
  31. package/dist/components/Popper.d.ts +5 -1
  32. package/dist/components/Popper.js +1026 -121
  33. package/dist/components/ProgressBar.js +3 -3
  34. package/dist/components/RoundGauge.js +30 -30
  35. package/dist/components/Section.js +7 -7
  36. package/dist/components/Slider.d.ts +22 -6
  37. package/dist/components/Slider.js +55 -56
  38. package/dist/components/Stack.js +3 -3
  39. package/dist/components/Table.js +7 -7
  40. package/dist/components/Tabs.js +7 -7
  41. package/dist/components/TextArea.d.ts +17 -0
  42. package/dist/components/TextArea.js +35 -33
  43. package/dist/components/Tooltip.d.ts +3 -34
  44. package/dist/components/Tooltip.js +14 -77
  45. package/dist/components/TrackOutsideClicks.d.ts +1 -1
  46. package/dist/components/index.d.ts +1 -0
  47. package/dist/components/index.js +64 -62
  48. package/package.json +26 -27
  49. package/styles/base.scss +13 -11
  50. package/styles/colors.scss +63 -67
  51. package/styles/components/BlockQuote.scss +5 -8
  52. package/styles/components/Button.scss +123 -99
  53. package/styles/components/Dialog.scss +23 -30
  54. package/styles/components/Dimmer.scss +3 -8
  55. package/styles/components/Divider.scss +6 -7
  56. package/styles/components/Dropdown.scss +103 -51
  57. package/styles/components/Flex.scss +0 -1
  58. package/styles/components/Floating.scss +60 -0
  59. package/styles/components/ImageButton.scss +136 -192
  60. package/styles/components/Input.scss +24 -26
  61. package/styles/components/Knob.scss +37 -41
  62. package/styles/components/LabeledList.scss +8 -6
  63. package/styles/components/MenuBar.scss +17 -21
  64. package/styles/components/Modal.scss +8 -7
  65. package/styles/components/NoticeBox.scss +22 -26
  66. package/styles/components/NumberInput.scss +30 -28
  67. package/styles/components/ProgressBar.scss +27 -19
  68. package/styles/components/RoundGauge.scss +46 -26
  69. package/styles/components/Section.scss +17 -32
  70. package/styles/components/Slider.scss +18 -15
  71. package/styles/components/Stack.scss +8 -48
  72. package/styles/components/Table.scss +2 -2
  73. package/styles/components/Tabs.scss +92 -66
  74. package/styles/components/TextArea.scss +32 -36
  75. package/styles/components/Tooltip.scss +10 -13
  76. package/styles/functions.scss +1 -62
  77. package/styles/main.scss +6 -1
  78. package/styles/reset.scss +7 -11
  79. package/styles/vars-colors.scss +108 -0
  80. package/styles/vars-components.scss +162 -0
  81. package/styles/vars-values.scss +110 -0
  82. package/dist/popper-CiqSDJTE.js +0 -906
@@ -1,98 +1,80 @@
1
- var w = Object.defineProperty;
2
- var R = (t, o, e) => o in t ? w(t, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[o] = e;
3
- var p = (t, o, e) => R(t, typeof o != "symbol" ? o + "" : o, e);
4
- import { jsx as c, jsxs as g } from "react/jsx-runtime";
5
- import { Component as B, createRef as C } from "react";
6
- import { zip as u } from "../common/collections.js";
7
- import { Box as v } from "./Box.js";
8
- function $(t, o, e, n) {
9
- if (t.length === 0)
1
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
2
+ import { useRef as y, useState as B, useEffect as R } from "react";
3
+ import { zip as w } from "../common/collections.js";
4
+ import { Box as $ } from "./Box.js";
5
+ function C(n, l, o, i) {
6
+ if (n.length === 0)
10
7
  return [];
11
- const f = u(...t), h = f.map((r) => Math.min(...r)), a = f.map((r) => Math.max(...r));
12
- return e !== void 0 && (h[0] = e[0], a[0] = e[1]), n !== void 0 && (h[1] = n[0], a[1] = n[1]), t.map(
13
- (r) => u(r, h, a, o).map(
14
- ([l, i, d, m]) => (l - i) / (d - i) * m
8
+ const f = w(...n), c = f.map((r) => Math.min(...r)), t = f.map((r) => Math.max(...r));
9
+ return o !== void 0 && (c[0] = o[0], t[0] = o[1]), i !== void 0 && (c[1] = i[0], t[1] = i[1]), n.map(
10
+ (r) => w(r, c, t, l).map(
11
+ ([s, p, e, u]) => (s - p) / (e - p) * u
15
12
  )
16
13
  );
17
14
  }
18
- function L(t) {
19
- let o = "";
20
- for (let e = 0; e < t.length; e++) {
21
- const n = t[e];
22
- o += `${n[0]},${n[1]} `;
15
+ function k(n) {
16
+ let l = "";
17
+ for (let o = 0; o < n.length; o++) {
18
+ const i = n[o];
19
+ l += `${i[0]},${i[1]} `;
23
20
  }
24
- return o;
21
+ return l;
25
22
  }
26
- class b extends B {
27
- constructor(e) {
28
- super(e);
29
- p(this, "ref");
30
- p(this, "state");
31
- p(this, "handleResize", () => {
32
- const e = this.ref.current;
33
- e && this.setState({
34
- viewBox: [e.offsetWidth, e.offsetHeight]
35
- });
36
- });
37
- this.ref = C(), this.state = {
38
- // Initial guess
39
- viewBox: [600, 200]
40
- }, this.handleResize = this.handleResize.bind(this);
41
- }
42
- componentDidMount() {
43
- window.addEventListener("resize", this.handleResize), this.handleResize();
23
+ const x = {
24
+ position: "absolute",
25
+ top: 0,
26
+ left: 0,
27
+ right: 0,
28
+ bottom: 0,
29
+ overflow: "hidden"
30
+ };
31
+ function z(n) {
32
+ const {
33
+ data: l = [],
34
+ rangeX: o,
35
+ rangeY: i,
36
+ fillColor: f = "none",
37
+ strokeColor: c = "#ffffff",
38
+ strokeWidth: t = 2,
39
+ ...v
40
+ } = n, r = y(null), [s, p] = B([600, 200]), e = C(l, s, o, i);
41
+ if (e.length > 0) {
42
+ const m = e[0], a = e[e.length - 1];
43
+ e.push([s[0] + t, a[1]]), e.push([s[0] + t, -t]), e.push([-t, -t]), e.push([-t, m[1]]);
44
44
  }
45
- componentWillUnmount() {
46
- window.removeEventListener("resize", this.handleResize);
45
+ const u = k(e);
46
+ function d() {
47
+ const m = r.current;
48
+ if (!m)
49
+ return;
50
+ const a = m.getBoundingClientRect();
51
+ p([a.width, a.height]);
47
52
  }
48
- render() {
49
- const {
50
- data: e = [],
51
- rangeX: n,
52
- rangeY: f,
53
- fillColor: h = "none",
54
- strokeColor: a = "#ffffff",
55
- strokeWidth: s = 2,
56
- ...r
57
- } = this.props, { viewBox: l } = this.state, i = $(e, l, n, f);
58
- if (i.length > 0) {
59
- const z = i[0], x = i[i.length - 1];
60
- i.push([l[0] + s, x[1]]), i.push([l[0] + s, -s]), i.push([-s, -s]), i.push([-s, z[1]]);
53
+ return R(() => (window.addEventListener("resize", d), d(), () => {
54
+ window.removeEventListener("resize", d);
55
+ }), []), /* @__PURE__ */ h($, { position: "relative", ...v, children: /* @__PURE__ */ h("div", { ref: r, style: x, children: /* @__PURE__ */ g(
56
+ "svg",
57
+ {
58
+ viewBox: `0 0 ${s[0]} ${s[1]}`,
59
+ preserveAspectRatio: "none",
60
+ style: x,
61
+ children: [
62
+ /* @__PURE__ */ h("title", { children: "chart" }),
63
+ /* @__PURE__ */ h(
64
+ "polyline",
65
+ {
66
+ transform: `scale(1, -1) translate(0, -${s[1]})`,
67
+ fill: f,
68
+ stroke: c,
69
+ strokeWidth: t,
70
+ points: u
71
+ }
72
+ )
73
+ ]
61
74
  }
62
- const d = L(i), m = { ...r, className: "", ref: this.ref };
63
- return /* @__PURE__ */ c(v, { position: "relative", ...r, children: /* @__PURE__ */ c(v, { ...m, children: /* @__PURE__ */ g(
64
- "svg",
65
- {
66
- viewBox: `0 0 ${l[0]} ${l[1]}`,
67
- preserveAspectRatio: "none",
68
- style: {
69
- position: "absolute",
70
- top: 0,
71
- left: 0,
72
- right: 0,
73
- bottom: 0,
74
- overflow: "hidden"
75
- },
76
- children: [
77
- /* @__PURE__ */ c("title", { children: "chart" }),
78
- /* @__PURE__ */ c(
79
- "polyline",
80
- {
81
- transform: `scale(1, -1) translate(0, -${l[1]})`,
82
- fill: h,
83
- stroke: a,
84
- strokeWidth: s,
85
- points: d
86
- }
87
- )
88
- ]
89
- }
90
- ) }) });
91
- }
75
+ ) }) });
92
76
  }
93
- const j = {
94
- Line: b
95
- };
77
+ z.Line = z;
96
78
  export {
97
- j as Chart
79
+ z as Chart
98
80
  };
@@ -1,13 +1,13 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
2
  import { classes as c } from "../common/react.js";
3
- import { computeBoxClassName as s, computeBoxProps as m } from "../common/ui.js";
3
+ import { computeBoxProps as s, computeBoxClassName as m } from "../common/ui.js";
4
4
  function d(r) {
5
5
  const { content: l, children: a, className: e, ...o } = r;
6
6
  return o.color = l ? null : "default", o.backgroundColor = r.color || "default", /* @__PURE__ */ t(
7
7
  "div",
8
8
  {
9
- className: c(["ColorBox", e, s(o)]),
10
- ...m(o),
9
+ className: c(["ColorBox", e, m(o)]),
10
+ ...s(o),
11
11
  children: l || ""
12
12
  }
13
13
  );
@@ -1,11 +1,27 @@
1
1
  import { ReactNode } from 'react';
2
2
  type DialogProps = {
3
+ /** The content of the dialog. */
3
4
  children: ReactNode;
5
+ /** The height of the dialog. */
4
6
  height?: string;
7
+ /** The function to call when close is clicked */
5
8
  onClose: () => void;
9
+ /** The title of the dialog. */
6
10
  title: ReactNode;
11
+ /** The width of the dialog. */
7
12
  width?: string;
8
13
  };
14
+ /**
15
+ * ## Dialog
16
+ * A themed dialog for user interaction.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * <Dialog title="Dialog Title" onClose={() => {}}>
21
+ * <div>Dialog Content</div>
22
+ * </Dialog>
23
+ * ```
24
+ */
9
25
  export declare function Dialog(props: DialogProps): import("react/jsx-runtime").JSX.Element;
10
26
  export declare namespace Dialog {
11
27
  var Button: typeof DialogButton;
@@ -9,15 +9,15 @@ function d(o) {
9
9
  /* @__PURE__ */ t(e, { mr: 2, children: /* @__PURE__ */ t(
10
10
  r,
11
11
  {
12
- mr: "-3px",
13
- width: "26px",
14
- lineHeight: "22px",
15
- textAlign: "center",
16
12
  color: "transparent",
17
13
  icon: "window-close-o",
14
+ lineHeight: "22px",
15
+ mr: "-3px",
16
+ onClick: n,
17
+ textAlign: "center",
18
18
  tooltip: "Close",
19
19
  tooltipPosition: "bottom-start",
20
- onClick: n
20
+ width: "26px"
21
21
  }
22
22
  ) })
23
23
  ] }),
@@ -30,5 +30,5 @@ type Props = {
30
30
  * Displays an icon from the BYOND icon reference map. Requires Byond 515+.
31
31
  * A much faster alternative to base64 icons.
32
32
  */
33
- export declare function DmIcon(props: Props): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
33
+ export declare function DmIcon(props: Props): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
34
34
  export {};
@@ -0,0 +1,56 @@
1
+ import { MouseEventHandler, ReactNode } from 'react';
2
+ import { BoxProps } from './Box';
3
+ type Control = {
4
+ /** Tooltip-like node to display. */
5
+ displayElement: ReactNode;
6
+ /** The value to display. */
7
+ displayValue: number;
8
+ /** Whether the element is being dragged */
9
+ dragging: boolean;
10
+ /** Whether the input is currently being edited */
11
+ editing: boolean;
12
+ /** Attach this to the element you want to be draggable */
13
+ handleDragStart: MouseEventHandler<HTMLDivElement>;
14
+ /** The input element. */
15
+ inputElement: ReactNode;
16
+ };
17
+ type Props = {
18
+ children: (control: Control) => ReactNode;
19
+ /** The external state value. */
20
+ value: number;
21
+ } & Partial<{
22
+ /** Animates the value if it was changed externally. */
23
+ animated: boolean;
24
+ /** The matrix to use for the drag. */
25
+ dragMatrix: [number, number];
26
+ /** Format the value using this function before displaying it. */
27
+ format: (value: number) => string;
28
+ /** The maximum value. */
29
+ maxValue: number;
30
+ /** The minimum value. */
31
+ minValue: number;
32
+ /** An event which fires when you release the input, or successfully enter a number. */
33
+ onChange: (event: Event, value: number) => void;
34
+ /** An event which fires when you drag the input. */
35
+ onDrag: (event: MouseEvent, value: number) => void;
36
+ /** The step size. */
37
+ step: number;
38
+ /** The step size in pixels. */
39
+ stepPixelSize: number;
40
+ /** The number of milliseconds to suppress flickering. */
41
+ suppressFlicker: number;
42
+ /** Whether to unclamp the value. */
43
+ unclamped: boolean;
44
+ /** The unit of the value. */
45
+ unit: string;
46
+ /** The rate at which the value is updated. */
47
+ updateRate: number;
48
+ }> & Omit<BoxProps, 'children'>;
49
+ /**
50
+ * ## DraggableControl
51
+ *
52
+ * A wrapper component for draggable elements.
53
+ * Generally, you won't need to use this component directly.
54
+ */
55
+ export declare function DraggableControl(props: Props): ReactNode;
56
+ export {};
@@ -1,182 +1,132 @@
1
- import { jsxs as T, Fragment as I, jsx as F } from "react/jsx-runtime";
2
- import { Component as x, createRef as y } from "react";
3
- import { clamp as c } from "../common/math.js";
4
- import { AnimatedNumber as M } from "./AnimatedNumber.js";
5
- const R = 400;
6
- function N(v, u) {
7
- return v.screenX * u[0] + v.screenY * u[1];
1
+ import { jsxs as W, Fragment as Z, jsx as P } from "react/jsx-runtime";
2
+ import { useState as y, useRef as c, useEffect as C } from "react";
3
+ import { KEY as Y } from "../common/keys.js";
4
+ import { clamp as F } from "../common/math.js";
5
+ import { AnimatedNumber as ee } from "./AnimatedNumber.js";
6
+ const te = 400;
7
+ function K(r, p) {
8
+ return r.screenX * p[0] + r.screenY * p[1];
8
9
  }
9
- class C extends x {
10
- constructor(u) {
11
- super(u), this.inputRef = y(), this.state = {
12
- value: u.value,
13
- dragging: !1,
14
- editing: !1,
15
- internalValue: null,
16
- origin: null,
17
- suppressingFlicker: !1
18
- }, this.flickerTimer = null, this.suppressFlicker = () => {
19
- const { suppressFlicker: e } = this.props;
20
- e > 0 && (this.setState({
21
- suppressingFlicker: !0
22
- }), clearTimeout(this.flickerTimer), this.flickerTimer = setTimeout(() => {
23
- this.setState({
24
- suppressingFlicker: !1
25
- });
26
- }, e));
27
- }, this.handleDragStart = (e) => {
28
- const { value: i, dragMatrix: l } = this.props, { editing: s } = this.state;
29
- s || (document.body.style["pointer-events"] = "none", this.ref = e.target, this.setState({
30
- dragging: !1,
31
- origin: N(e, l),
32
- value: i,
33
- internalValue: i
34
- }), this.timer = setTimeout(() => {
35
- this.setState({
36
- dragging: !0
37
- });
38
- }, 250), this.dragInterval = setInterval(() => {
39
- const { dragging: o, value: g } = this.state, { onDrag: r } = this.props;
40
- o && r && r(e, g);
41
- }, this.props.updateRate || R), document.addEventListener("mousemove", this.handleDragMove), document.addEventListener("mouseup", this.handleDragEnd));
42
- }, this.handleDragMove = (e) => {
43
- const { minValue: i, maxValue: l, step: s, stepPixelSize: o, dragMatrix: g } = this.props;
44
- this.setState((r) => {
45
- const a = { ...r }, p = N(e, g) - a.origin;
46
- if (r.dragging) {
47
- const h = Number.isFinite(i) ? i % s : 0;
48
- a.internalValue = c(
49
- a.internalValue + p * s / o,
50
- i - s,
51
- l + s
52
- ), a.value = c(
53
- a.internalValue - a.internalValue % s + h,
54
- i,
55
- l
56
- ), a.origin = N(e, g);
57
- } else Math.abs(p) > 4 && (a.dragging = !0);
58
- return a;
59
- });
60
- }, this.handleDragEnd = (e) => {
61
- const { onChange: i, onDrag: l } = this.props, { dragging: s, value: o, internalValue: g } = this.state;
62
- if (document.body.style["pointer-events"] = "auto", clearTimeout(this.timer), clearInterval(this.dragInterval), this.setState({
63
- dragging: !1,
64
- editing: !s,
65
- origin: null
66
- }), document.removeEventListener("mousemove", this.handleDragMove), document.removeEventListener("mouseup", this.handleDragEnd), s)
67
- this.suppressFlicker(), i && i(e, o), l && l(e, o);
68
- else if (this.inputRef) {
69
- const r = this.inputRef.current;
70
- r.value = g, setTimeout(() => {
71
- r.focus(), r.select();
72
- }, 10);
73
- }
74
- };
10
+ function se(r) {
11
+ const {
12
+ // Our props
13
+ animated: p,
14
+ children: M,
15
+ dragMatrix: V = [1, 0],
16
+ format: E,
17
+ maxValue: g = Number.POSITIVE_INFINITY,
18
+ minValue: l = Number.NEGATIVE_INFINITY,
19
+ onChange: s,
20
+ onDrag: a,
21
+ step: o = 1,
22
+ stepPixelSize: O = 1,
23
+ suppressFlicker: S = 50,
24
+ unclamped: j,
25
+ unit: h,
26
+ updateRate: w = te,
27
+ // Box props
28
+ fontSize: z,
29
+ height: B,
30
+ lineHeight: U
31
+ } = r, [G, T] = y(r.value), [v, f] = y(!1), [k, D] = y(!1), i = c(!1), n = c(0), m = c(0), R = c(null), N = c(null), I = c(null), b = c(null);
32
+ C(() => {
33
+ T(r.value);
34
+ }, [r.value]);
35
+ function _(e) {
36
+ if (document.body.style["pointer-events"] = "auto", b.current && clearTimeout(b.current), I.current && clearInterval(I.current), i.current = !1, f(!1), m.current = 0, document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", _), L(), s == null || s(e, n.current), a == null || a(e, n.current), N.current) {
37
+ const t = N.current;
38
+ t.value = n.toString(), setTimeout(() => {
39
+ t.focus(), t.select();
40
+ }, 10);
41
+ }
75
42
  }
76
- render() {
77
- const {
78
- dragging: u,
79
- editing: e,
80
- value: i,
81
- suppressingFlicker: l
82
- } = this.state, {
83
- animated: s,
84
- value: o,
85
- unit: g,
86
- minValue: r,
87
- maxValue: a,
88
- unclamped: p,
89
- format: h,
90
- onChange: m,
91
- onDrag: f,
92
- children: S,
93
- // Input props
94
- height: V,
95
- lineHeight: D,
96
- fontSize: b
97
- } = this.props;
98
- let d = o;
99
- (u || l) && (d = i);
100
- const k = /* @__PURE__ */ T(I, { children: [
101
- s && !u && !l ? /* @__PURE__ */ F(M, { value: d, format: h }) : h ? h(d) : d,
102
- g ? ` ${g}` : ""
103
- ] }), E = /* @__PURE__ */ F(
104
- "input",
105
- {
106
- ref: this.inputRef,
107
- className: "NumberInput__input",
108
- style: {
109
- display: e ? void 0 : "none",
110
- height: V,
111
- lineHeight: D,
112
- fontsize: b
113
- },
114
- onBlur: (n) => {
115
- if (!e)
116
- return;
117
- let t;
118
- if (p ? t = Number.parseFloat(n.target.value) : t = c(
119
- Number.parseFloat(n.target.value),
120
- r,
121
- a
122
- ), Number.isNaN(t)) {
123
- this.setState({
124
- editing: !1
125
- });
126
- return;
127
- }
128
- this.setState({
129
- editing: !1,
130
- value: t
131
- }), this.suppressFlicker(), m && m(n, t), f && f(n, t);
132
- },
133
- onKeyDown: (n) => {
134
- if (n.keyCode === 13) {
135
- let t;
136
- if (p ? t = Number.parseFloat(n.target.value) : t = c(
137
- Number.parseFloat(n.target.value),
138
- r,
139
- a
140
- ), Number.isNaN(t)) {
141
- this.setState({
142
- editing: !1
143
- });
144
- return;
145
- }
146
- this.setState({
147
- editing: !1,
148
- value: t
149
- }), this.suppressFlicker(), m && m(n, t), f && f(n, t);
150
- return;
151
- }
152
- if (n.keyCode === 27) {
153
- this.setState({
154
- editing: !1
155
- });
156
- return;
157
- }
158
- }
159
- }
160
- );
161
- return S({
162
- dragging: u,
163
- editing: e,
164
- value: o,
165
- displayValue: d,
166
- displayElement: k,
167
- inputElement: E,
168
- handleDragStart: this.handleDragStart
169
- });
43
+ function x(e) {
44
+ if (!m.current) return;
45
+ const t = K(e, V), u = t - m.current;
46
+ if (!i.current) {
47
+ Math.abs(u) > 4 && (i.current = !0);
48
+ return;
49
+ }
50
+ const Q = Number.isFinite(l) ? l % o : 0;
51
+ n.current = F(
52
+ n.current + u * o / O,
53
+ l - o,
54
+ g + o
55
+ ), T(
56
+ F(
57
+ n.current - n.current % o + Q,
58
+ l,
59
+ g
60
+ )
61
+ ), m.current = t;
170
62
  }
63
+ function H(e) {
64
+ if (v) return;
65
+ const t = e.nativeEvent;
66
+ document.body.style["pointer-events"] = "none", m.current = K(t, V), n.current = r.value, b.current = setTimeout(() => {
67
+ i.current = !0;
68
+ }, 250), I.current = setInterval(() => {
69
+ i && (a == null || a(t, r.value));
70
+ }, w), document.addEventListener("mousemove", x), document.addEventListener("mouseup", _);
71
+ }
72
+ function X(e) {
73
+ if (e.key === Y.Enter) {
74
+ e.preventDefault(), e.stopPropagation(), A(e.nativeEvent, e.currentTarget.value);
75
+ return;
76
+ }
77
+ if (e.key === Y.Escape) {
78
+ f(!1);
79
+ return;
80
+ }
81
+ }
82
+ function A(e, t) {
83
+ let u = Number.parseFloat(t);
84
+ if (j || (u = F(u, l, g)), Number.isNaN(u)) {
85
+ f(!1);
86
+ return;
87
+ }
88
+ f(!1), T(u), n.current = u, L(), s == null || s(e, u);
89
+ }
90
+ function L() {
91
+ if (S <= 0) return;
92
+ const e = R.current;
93
+ if (e)
94
+ return D(!0), clearTimeout(e), R.current = setTimeout(() => {
95
+ D(!1);
96
+ }, S), () => clearTimeout(e);
97
+ }
98
+ function $(e) {
99
+ v && f(!1), A(e.nativeEvent, e.currentTarget.value);
100
+ }
101
+ let d = r.value;
102
+ (i.current || k) && (d = G);
103
+ const q = /* @__PURE__ */ W(Z, { children: [
104
+ p && !i.current && !k ? /* @__PURE__ */ P(ee, { value: d, format: E }) : E ? E(d) : d,
105
+ h ? ` ${h}` : ""
106
+ ] }), J = /* @__PURE__ */ P(
107
+ "input",
108
+ {
109
+ ref: N,
110
+ className: "NumberInput__input",
111
+ style: {
112
+ display: v ? void 0 : "none",
113
+ height: B,
114
+ lineHeight: U,
115
+ fontSize: z
116
+ },
117
+ onBlur: $,
118
+ onKeyDown: X
119
+ }
120
+ );
121
+ return M({
122
+ displayElement: q,
123
+ displayValue: d,
124
+ dragging: i.current,
125
+ editing: v,
126
+ handleDragStart: H,
127
+ inputElement: J
128
+ });
171
129
  }
172
- C.defaultProps = {
173
- minValue: Number.NEGATIVE_INFINITY,
174
- maxValue: Number.POSITIVE_INFINITY,
175
- step: 1,
176
- stepPixelSize: 1,
177
- suppressFlicker: 50,
178
- dragMatrix: [1, 0]
179
- };
180
130
  export {
181
- C as DraggableControl
131
+ se as DraggableControl
182
132
  };
@@ -18,8 +18,6 @@ type Props = {
18
18
  autoScroll: boolean;
19
19
  /** Whether to display previous / next buttons */
20
20
  buttons: boolean;
21
- /** Whether to clip the selected text */
22
- clipSelectedText: boolean;
23
21
  /** Color of dropdown button */
24
22
  color: string;
25
23
  /** Disables the dropdown */
@@ -28,20 +26,24 @@ type Props = {
28
26
  displayText: ReactNode;
29
27
  /** Icon to display in dropdown button */
30
28
  icon: string;
29
+ /** Whether the icon should be displayed alone */
30
+ iconOnly: boolean;
31
31
  /** Angle of the icon */
32
32
  iconRotation: number;
33
33
  /** Whether or not the icon should spin */
34
34
  iconSpin: boolean;
35
- /** Width of the dropdown menu. Default: 15rem */
36
- menuWidth: string;
35
+ /** Width of the dropdown menu in box units. Default: 15 */
36
+ menuWidth: string | number;
37
37
  /** Whether or not the arrow on the right hand side of the dropdown button is visible */
38
38
  noChevron: boolean;
39
- /** Called when dropdown button is clicked */
40
- onClick: (event: any) => void;
41
39
  /** Dropdown renders over instead of below */
42
40
  over: boolean;
43
41
  /** Text to show when nothing has been selected. */
44
42
  placeholder: string;
43
+ /** @deprecated If you want to allow dropdown breaks layout, set width 100% */
44
+ clipSelectedText: boolean;
45
+ /** Called when dropdown button is clicked */
46
+ onClick: (event: any) => void;
45
47
  }> & BoxProps;
46
48
  /**
47
49
  * ## Dropdown