@aivenio/aquarium 2.0.0 → 2.1.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.
package/dist/charts.cjs CHANGED
@@ -80,7 +80,10 @@ __export(charts_exports, {
80
80
  Tooltip: () => Tooltip,
81
81
  extractChildByDisplayName: () => extractChildByDisplayName,
82
82
  getDisplayName: () => getDisplayName,
83
+ getXAxisExtent: () => getXAxisExtent,
83
84
  getXAxisTicks: () => getXAxisTicks,
85
+ getXAxisValues: () => getXAxisValues,
86
+ normalizeAxisDomain: () => normalizeAxisDomain,
84
87
  renderXAxis: () => renderXAxis,
85
88
  renderXTimeAxis: () => renderXTimeAxis,
86
89
  renderYAxis: () => renderYAxis,
@@ -1974,12 +1977,13 @@ function calendar(ticks2, tickInterval, year, month, week, day, hour, minute, se
1974
1977
  };
1975
1978
  return scale;
1976
1979
  }
1977
- function time() {
1978
- return initRange.apply(calendar(timeTicks, timeTickInterval, timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute, second, timeFormat).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
1980
+
1981
+ // node_modules/d3-scale/src/utcTime.js
1982
+ function utcTime() {
1983
+ return initRange.apply(calendar(utcTicks, utcTickInterval, utcYear, utcMonth, utcSunday, utcDay, utcHour, utcMinute, second, utcFormat).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments);
1979
1984
  }
1980
1985
 
1981
1986
  // src/charts/lib/utils.ts
1982
- var import_isArray = __toESM(require("lodash/isArray"));
1983
1987
  var import_isDate = __toESM(require("lodash/isDate"));
1984
1988
  var CHART_MARGIN_BOTTOM = 15;
1985
1989
  var CHART_YLABEL_DEFAULT_OFFSET = 10;
@@ -1999,23 +2003,22 @@ var getDisplayName = (Comp) => {
1999
2003
  }
2000
2004
  return Comp.displayName || Comp.name || "Component";
2001
2005
  };
2002
- var isDateArray = (arr) => arr.every(import_isDate.default);
2003
- var getXAxisTicks = ({ dataKey, ticks: ticks2 }, chartProps) => {
2006
+ var isDateArray = (arr) => Array.isArray(arr) && arr.every(import_isDate.default);
2007
+ var isNumberOrDate = (value) => Number.isFinite(value) || (0, import_isDate.default)(value);
2008
+ var getXAxisTicks = ({ dataKey, ticks: ticks2, domain }, chartProps) => {
2004
2009
  var _a;
2005
- if (!ticks2 || (0, import_isArray.default)(ticks2)) {
2010
+ if (!ticks2 || Array.isArray(ticks2)) {
2006
2011
  return ticks2 != null ? ticks2 : void 0;
2007
2012
  }
2008
- const xValues = ((_a = chartProps.data) != null ? _a : []).map(
2009
- (datum) => typeof dataKey === "function" ? dataKey(datum) : dataKey ? datum[dataKey] : void 0
2010
- );
2011
- if (!isDateArray(xValues)) {
2012
- console.warn(
2013
- "Time intervals can only be used with date values. Please make sure that `dataKey` prop refers to a prop type of `Date`."
2014
- );
2013
+ const normalizedDomain = normalizeAxisDomain(domain);
2014
+ const [domainMin, domainMax] = (_a = domainExtent(normalizedDomain)) != null ? _a : [];
2015
+ const [dataMin, dataMax] = getXAxisExtent(chartProps.data, dataKey);
2016
+ const min = isNumberOrDate(domainMin) ? Number(domainMin) : dataMin;
2017
+ const max = isNumberOrDate(domainMax) ? Number(domainMax) : dataMax;
2018
+ if (min === void 0 || max === void 0) {
2015
2019
  return void 0;
2016
2020
  }
2017
- const [min = new Date(), max = new Date()] = extent(xValues);
2018
- return time().domain([min, max]).ticks(ticks2).map((v) => v.valueOf());
2021
+ return utcTime().domain([min, max]).ticks(ticks2).map((v) => v.valueOf());
2019
2022
  };
2020
2023
  var extractChildByDisplayName = (children, name) => {
2021
2024
  const childIndex = children.findIndex((child) => getDisplayName(child.type) === name);
@@ -2026,6 +2029,20 @@ var extractChildByDisplayName = (children, name) => {
2026
2029
  const remainingChildren = children.slice(0, childIndex).concat(children.slice(childIndex + 1));
2027
2030
  return [foundChild, remainingChildren];
2028
2031
  };
2032
+ var normalizeAxisDomain = (domain) => {
2033
+ return isDateArray(domain) ? domain.map((d) => d.valueOf()) : domain;
2034
+ };
2035
+ var getXAxisValues = (data = [], dataKey) => {
2036
+ return data.map((datum) => typeof dataKey === "function" ? dataKey(datum) : dataKey ? datum[dataKey] : void 0);
2037
+ };
2038
+ var getXAxisExtent = (data = [], dataKey) => extent(getXAxisValues(data, dataKey));
2039
+ var domainExtent = (domain) => {
2040
+ if (!Array.isArray(domain)) {
2041
+ return void 0;
2042
+ }
2043
+ const [min, max] = domain;
2044
+ return Number.isFinite(min) && Number.isFinite(max) ? [min, max] : void 0;
2045
+ };
2029
2046
 
2030
2047
  // src/charts/Axis/Axis.tsx
2031
2048
  var XTimeAxis = () => null;
@@ -2036,19 +2053,25 @@ XAxis.Time = XTimeAxis;
2036
2053
  var YAxis = () => null;
2037
2054
  YAxis.displayName = "Axis.YAxis";
2038
2055
  var renderXAxis = (child, chartProps) => {
2039
- const _a = child.props, { tickLine = false, ticks: ticks2 } = _a, props = __objRest(_a, ["tickLine", "ticks"]);
2040
- const xticks = getXAxisTicks(child.props, chartProps);
2056
+ const _a = child.props, { tickLine = false, ticks: ticks2, domain } = _a, props = __objRest(_a, ["tickLine", "ticks", "domain"]);
2057
+ const xticks = getXAxisTicks(__spreadValues({ domain }, child.props), chartProps);
2041
2058
  return /* @__PURE__ */ import_react.default.createElement(import_recharts.XAxis, __spreadValues({
2042
2059
  tickLine,
2043
- ticks: xticks
2060
+ ticks: xticks,
2061
+ domain
2044
2062
  }, props));
2045
2063
  };
2046
2064
  var renderXTimeAxis = (child, chartProps) => {
2047
- const _a = child.props, { tickLine = false, ticks: ticks2 } = _a, props = __objRest(_a, ["tickLine", "ticks"]);
2048
- const xticks = getXAxisTicks(child.props, chartProps);
2065
+ const _a = child.props, { tickLine = false, ticks: ticks2, domain, utc = true } = _a, props = __objRest(_a, ["tickLine", "ticks", "domain", "utc"]);
2066
+ const xticks = getXAxisTicks(__spreadValues({ domain }, child.props), chartProps);
2067
+ const normalizedDomain = normalizeAxisDomain(domain);
2068
+ const [min, max] = getXAxisExtent(chartProps.data, child.props.dataKey);
2069
+ const effectiveDomain = normalizedDomain != null ? normalizedDomain : min !== void 0 && max !== void 0 ? [Number(min), Number(max)] : ["auto", "auto"];
2049
2070
  return /* @__PURE__ */ import_react.default.createElement(import_recharts.XAxis, __spreadValues({
2050
- scale: "time",
2071
+ scale: utc ? "utc" : "time",
2072
+ type: "number",
2051
2073
  allowDataOverflow: true,
2074
+ domain: effectiveDomain,
2052
2075
  tickLine,
2053
2076
  ticks: xticks
2054
2077
  }, props));
@@ -2626,7 +2649,10 @@ var Reference = {
2626
2649
  Tooltip,
2627
2650
  extractChildByDisplayName,
2628
2651
  getDisplayName,
2652
+ getXAxisExtent,
2629
2653
  getXAxisTicks,
2654
+ getXAxisValues,
2655
+ normalizeAxisDomain,
2630
2656
  renderXAxis,
2631
2657
  renderXTimeAxis,
2632
2658
  renderYAxis,
package/dist/charts.mjs CHANGED
@@ -1850,12 +1850,13 @@ function calendar(ticks2, tickInterval, year, month, week, day, hour, minute, se
1850
1850
  };
1851
1851
  return scale;
1852
1852
  }
1853
- function time() {
1854
- return initRange.apply(calendar(timeTicks, timeTickInterval, timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute, second, timeFormat).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
1853
+
1854
+ // node_modules/d3-scale/src/utcTime.js
1855
+ function utcTime() {
1856
+ return initRange.apply(calendar(utcTicks, utcTickInterval, utcYear, utcMonth, utcSunday, utcDay, utcHour, utcMinute, second, utcFormat).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments);
1855
1857
  }
1856
1858
 
1857
1859
  // src/charts/lib/utils.ts
1858
- import isArray from "lodash/isArray";
1859
1860
  import isDate from "lodash/isDate";
1860
1861
  var CHART_MARGIN_BOTTOM = 15;
1861
1862
  var CHART_YLABEL_DEFAULT_OFFSET = 10;
@@ -1875,23 +1876,22 @@ var getDisplayName = (Comp) => {
1875
1876
  }
1876
1877
  return Comp.displayName || Comp.name || "Component";
1877
1878
  };
1878
- var isDateArray = (arr) => arr.every(isDate);
1879
- var getXAxisTicks = ({ dataKey, ticks: ticks2 }, chartProps) => {
1879
+ var isDateArray = (arr) => Array.isArray(arr) && arr.every(isDate);
1880
+ var isNumberOrDate = (value) => Number.isFinite(value) || isDate(value);
1881
+ var getXAxisTicks = ({ dataKey, ticks: ticks2, domain }, chartProps) => {
1880
1882
  var _a;
1881
- if (!ticks2 || isArray(ticks2)) {
1883
+ if (!ticks2 || Array.isArray(ticks2)) {
1882
1884
  return ticks2 != null ? ticks2 : void 0;
1883
1885
  }
1884
- const xValues = ((_a = chartProps.data) != null ? _a : []).map(
1885
- (datum) => typeof dataKey === "function" ? dataKey(datum) : dataKey ? datum[dataKey] : void 0
1886
- );
1887
- if (!isDateArray(xValues)) {
1888
- console.warn(
1889
- "Time intervals can only be used with date values. Please make sure that `dataKey` prop refers to a prop type of `Date`."
1890
- );
1886
+ const normalizedDomain = normalizeAxisDomain(domain);
1887
+ const [domainMin, domainMax] = (_a = domainExtent(normalizedDomain)) != null ? _a : [];
1888
+ const [dataMin, dataMax] = getXAxisExtent(chartProps.data, dataKey);
1889
+ const min = isNumberOrDate(domainMin) ? Number(domainMin) : dataMin;
1890
+ const max = isNumberOrDate(domainMax) ? Number(domainMax) : dataMax;
1891
+ if (min === void 0 || max === void 0) {
1891
1892
  return void 0;
1892
1893
  }
1893
- const [min = new Date(), max = new Date()] = extent(xValues);
1894
- return time().domain([min, max]).ticks(ticks2).map((v) => v.valueOf());
1894
+ return utcTime().domain([min, max]).ticks(ticks2).map((v) => v.valueOf());
1895
1895
  };
1896
1896
  var extractChildByDisplayName = (children, name) => {
1897
1897
  const childIndex = children.findIndex((child) => getDisplayName(child.type) === name);
@@ -1902,6 +1902,20 @@ var extractChildByDisplayName = (children, name) => {
1902
1902
  const remainingChildren = children.slice(0, childIndex).concat(children.slice(childIndex + 1));
1903
1903
  return [foundChild, remainingChildren];
1904
1904
  };
1905
+ var normalizeAxisDomain = (domain) => {
1906
+ return isDateArray(domain) ? domain.map((d) => d.valueOf()) : domain;
1907
+ };
1908
+ var getXAxisValues = (data = [], dataKey) => {
1909
+ return data.map((datum) => typeof dataKey === "function" ? dataKey(datum) : dataKey ? datum[dataKey] : void 0);
1910
+ };
1911
+ var getXAxisExtent = (data = [], dataKey) => extent(getXAxisValues(data, dataKey));
1912
+ var domainExtent = (domain) => {
1913
+ if (!Array.isArray(domain)) {
1914
+ return void 0;
1915
+ }
1916
+ const [min, max] = domain;
1917
+ return Number.isFinite(min) && Number.isFinite(max) ? [min, max] : void 0;
1918
+ };
1905
1919
 
1906
1920
  // src/charts/Axis/Axis.tsx
1907
1921
  var XTimeAxis = () => null;
@@ -1912,19 +1926,25 @@ XAxis.Time = XTimeAxis;
1912
1926
  var YAxis = () => null;
1913
1927
  YAxis.displayName = "Axis.YAxis";
1914
1928
  var renderXAxis = (child, chartProps) => {
1915
- const _a = child.props, { tickLine = false, ticks: ticks2 } = _a, props = __objRest(_a, ["tickLine", "ticks"]);
1916
- const xticks = getXAxisTicks(child.props, chartProps);
1929
+ const _a = child.props, { tickLine = false, ticks: ticks2, domain } = _a, props = __objRest(_a, ["tickLine", "ticks", "domain"]);
1930
+ const xticks = getXAxisTicks(__spreadValues({ domain }, child.props), chartProps);
1917
1931
  return /* @__PURE__ */ React.createElement(_XAxis, __spreadValues({
1918
1932
  tickLine,
1919
- ticks: xticks
1933
+ ticks: xticks,
1934
+ domain
1920
1935
  }, props));
1921
1936
  };
1922
1937
  var renderXTimeAxis = (child, chartProps) => {
1923
- const _a = child.props, { tickLine = false, ticks: ticks2 } = _a, props = __objRest(_a, ["tickLine", "ticks"]);
1924
- const xticks = getXAxisTicks(child.props, chartProps);
1938
+ const _a = child.props, { tickLine = false, ticks: ticks2, domain, utc = true } = _a, props = __objRest(_a, ["tickLine", "ticks", "domain", "utc"]);
1939
+ const xticks = getXAxisTicks(__spreadValues({ domain }, child.props), chartProps);
1940
+ const normalizedDomain = normalizeAxisDomain(domain);
1941
+ const [min, max] = getXAxisExtent(chartProps.data, child.props.dataKey);
1942
+ const effectiveDomain = normalizedDomain != null ? normalizedDomain : min !== void 0 && max !== void 0 ? [Number(min), Number(max)] : ["auto", "auto"];
1925
1943
  return /* @__PURE__ */ React.createElement(_XAxis, __spreadValues({
1926
- scale: "time",
1944
+ scale: utc ? "utc" : "time",
1945
+ type: "number",
1927
1946
  allowDataOverflow: true,
1947
+ domain: effectiveDomain,
1928
1948
  tickLine,
1929
1949
  ticks: xticks
1930
1950
  }, props));
@@ -2504,7 +2524,10 @@ export {
2504
2524
  Tooltip,
2505
2525
  extractChildByDisplayName,
2506
2526
  getDisplayName,
2527
+ getXAxisExtent,
2507
2528
  getXAxisTicks,
2529
+ getXAxisValues,
2530
+ normalizeAxisDomain,
2508
2531
  renderXAxis,
2509
2532
  renderXTimeAxis,
2510
2533
  renderYAxis,
@@ -4,21 +4,23 @@ import type { ImgHTMLAttributes } from 'react';
4
4
  declare type ModalKind = {
5
5
  kind?: 'dialog' | 'drawer';
6
6
  };
7
+ export declare type ModalSize = 'full' | 'md' | 'screen' | 'sm';
7
8
  declare type ModalProps = ModalKind & {
8
9
  /** State of the modal */
9
10
  open: boolean;
10
11
  };
11
12
  declare type DialogProps = ModalKind & {
12
- /** Optional size (width) of the modal: sm, md, full */
13
- size?: 'full' | 'md' | 'sm';
13
+ /** Optional size (width) of the modal: sm, md, full, screen */
14
+ size?: ModalSize;
14
15
  };
15
16
  declare type DivProps = React.HTMLProps<HTMLDivElement>;
16
17
  declare type ImgProps = Omit<ImgHTMLAttributes<HTMLImageElement>, 'src'>;
17
18
  declare type DialogComponentProps = DialogProps & Omit<DivProps, 'size'>;
19
+ declare type HeaderProps = DialogProps & Omit<DivProps, 'size'>;
18
20
  declare type ComposedModalProps = {
19
21
  BackDrop: React.FC<DivProps>;
20
22
  Dialog: React.ForwardRefExoticComponent<DialogComponentProps & React.RefAttributes<HTMLDivElement>>;
21
- Header: React.FC<DivProps>;
23
+ Header: React.FC<HeaderProps>;
22
24
  HeaderImage: React.FC<ImgProps & {
23
25
  backgroundImage: string | null;
24
26
  }>;
@@ -33,5 +35,287 @@ declare type ComposedModalProps = {
33
35
  Footer: React.FC<DivProps>;
34
36
  Actions: React.FC<DivProps>;
35
37
  };
38
+ export declare const modalStyles: import("tailwind-variants").TVReturnType<{
39
+ kind: {
40
+ dialog: {
41
+ overlay: string;
42
+ dialog: string;
43
+ };
44
+ drawer: {
45
+ overlay: string;
46
+ dialog: string;
47
+ title: string;
48
+ };
49
+ };
50
+ size: {
51
+ sm: "";
52
+ md: "";
53
+ full: "";
54
+ screen: {
55
+ overlay: string;
56
+ dialog: string;
57
+ header: string;
58
+ };
59
+ };
60
+ noFooter: {
61
+ true: {
62
+ body: string;
63
+ };
64
+ };
65
+ backgroundImage: {
66
+ true: {
67
+ headerImage: string;
68
+ };
69
+ false: {
70
+ headerImage: string;
71
+ };
72
+ };
73
+ }, {
74
+ overlay: string;
75
+ backdrop: string;
76
+ dialog: string;
77
+ header: string;
78
+ headerImage: string;
79
+ titleContainer: string;
80
+ title: string;
81
+ closeButtonContainer: string;
82
+ body: string;
83
+ footer: string;
84
+ actions: string;
85
+ }, undefined, import("tailwind-variants/dist/config").TVConfig<{
86
+ kind: {
87
+ dialog: {
88
+ overlay: string;
89
+ dialog: string;
90
+ };
91
+ drawer: {
92
+ overlay: string;
93
+ dialog: string;
94
+ title: string;
95
+ };
96
+ };
97
+ size: {
98
+ sm: "";
99
+ md: "";
100
+ full: "";
101
+ screen: {
102
+ overlay: string;
103
+ dialog: string;
104
+ header: string;
105
+ };
106
+ };
107
+ noFooter: {
108
+ true: {
109
+ body: string;
110
+ };
111
+ };
112
+ backgroundImage: {
113
+ true: {
114
+ headerImage: string;
115
+ };
116
+ false: {
117
+ headerImage: string;
118
+ };
119
+ };
120
+ }, {
121
+ kind: {
122
+ dialog: {
123
+ overlay: string;
124
+ dialog: string;
125
+ };
126
+ drawer: {
127
+ overlay: string;
128
+ dialog: string;
129
+ title: string;
130
+ };
131
+ };
132
+ size: {
133
+ sm: "";
134
+ md: "";
135
+ full: "";
136
+ screen: {
137
+ overlay: string;
138
+ dialog: string;
139
+ header: string;
140
+ };
141
+ };
142
+ noFooter: {
143
+ true: {
144
+ body: string;
145
+ };
146
+ };
147
+ backgroundImage: {
148
+ true: {
149
+ headerImage: string;
150
+ };
151
+ false: {
152
+ headerImage: string;
153
+ };
154
+ };
155
+ }>, {
156
+ kind: {
157
+ dialog: {
158
+ overlay: string;
159
+ dialog: string;
160
+ };
161
+ drawer: {
162
+ overlay: string;
163
+ dialog: string;
164
+ title: string;
165
+ };
166
+ };
167
+ size: {
168
+ sm: "";
169
+ md: "";
170
+ full: "";
171
+ screen: {
172
+ overlay: string;
173
+ dialog: string;
174
+ header: string;
175
+ };
176
+ };
177
+ noFooter: {
178
+ true: {
179
+ body: string;
180
+ };
181
+ };
182
+ backgroundImage: {
183
+ true: {
184
+ headerImage: string;
185
+ };
186
+ false: {
187
+ headerImage: string;
188
+ };
189
+ };
190
+ }, {
191
+ overlay: string;
192
+ backdrop: string;
193
+ dialog: string;
194
+ header: string;
195
+ headerImage: string;
196
+ titleContainer: string;
197
+ title: string;
198
+ closeButtonContainer: string;
199
+ body: string;
200
+ footer: string;
201
+ actions: string;
202
+ }, import("tailwind-variants").TVReturnType<{
203
+ kind: {
204
+ dialog: {
205
+ overlay: string;
206
+ dialog: string;
207
+ };
208
+ drawer: {
209
+ overlay: string;
210
+ dialog: string;
211
+ title: string;
212
+ };
213
+ };
214
+ size: {
215
+ sm: "";
216
+ md: "";
217
+ full: "";
218
+ screen: {
219
+ overlay: string;
220
+ dialog: string;
221
+ header: string;
222
+ };
223
+ };
224
+ noFooter: {
225
+ true: {
226
+ body: string;
227
+ };
228
+ };
229
+ backgroundImage: {
230
+ true: {
231
+ headerImage: string;
232
+ };
233
+ false: {
234
+ headerImage: string;
235
+ };
236
+ };
237
+ }, {
238
+ overlay: string;
239
+ backdrop: string;
240
+ dialog: string;
241
+ header: string;
242
+ headerImage: string;
243
+ titleContainer: string;
244
+ title: string;
245
+ closeButtonContainer: string;
246
+ body: string;
247
+ footer: string;
248
+ actions: string;
249
+ }, undefined, import("tailwind-variants/dist/config").TVConfig<{
250
+ kind: {
251
+ dialog: {
252
+ overlay: string;
253
+ dialog: string;
254
+ };
255
+ drawer: {
256
+ overlay: string;
257
+ dialog: string;
258
+ title: string;
259
+ };
260
+ };
261
+ size: {
262
+ sm: "";
263
+ md: "";
264
+ full: "";
265
+ screen: {
266
+ overlay: string;
267
+ dialog: string;
268
+ header: string;
269
+ };
270
+ };
271
+ noFooter: {
272
+ true: {
273
+ body: string;
274
+ };
275
+ };
276
+ backgroundImage: {
277
+ true: {
278
+ headerImage: string;
279
+ };
280
+ false: {
281
+ headerImage: string;
282
+ };
283
+ };
284
+ }, {
285
+ kind: {
286
+ dialog: {
287
+ overlay: string;
288
+ dialog: string;
289
+ };
290
+ drawer: {
291
+ overlay: string;
292
+ dialog: string;
293
+ title: string;
294
+ };
295
+ };
296
+ size: {
297
+ sm: "";
298
+ md: "";
299
+ full: "";
300
+ screen: {
301
+ overlay: string;
302
+ dialog: string;
303
+ header: string;
304
+ };
305
+ };
306
+ noFooter: {
307
+ true: {
308
+ body: string;
309
+ };
310
+ };
311
+ backgroundImage: {
312
+ true: {
313
+ headerImage: string;
314
+ };
315
+ false: {
316
+ headerImage: string;
317
+ };
318
+ };
319
+ }>, unknown, unknown, undefined>>;
36
320
  export declare const Modal: ComposedModalProps & React.FC<DivProps & ModalProps>;
37
321
  export {};