@cognite/aura 0.3.2 → 0.3.4

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 (143) hide show
  1. package/DESIGN.md +134 -5
  2. package/README.md +24 -3
  3. package/dist/components/index.d.ts +5 -1
  4. package/dist/components/index.js +59 -327
  5. package/dist/components/ui/core/accordion/accordion.js +79 -114
  6. package/dist/components/ui/core/action-toolbar/action-toolbar.js +108 -176
  7. package/dist/components/ui/core/alert/alert.js +158 -206
  8. package/dist/components/ui/core/avatar/avatar.js +64 -90
  9. package/dist/components/ui/core/badge/badge.js +73 -108
  10. package/dist/components/ui/core/banner/banner.js +146 -215
  11. package/dist/components/ui/core/breadcrumb/breadcrumb.js +105 -200
  12. package/dist/components/ui/core/button/button.js +47 -52
  13. package/dist/components/ui/core/button-group/button-group.js +40 -79
  14. package/dist/components/ui/core/calendar/calendar-header.js +63 -0
  15. package/dist/components/ui/core/calendar/calendar-utils.js +39 -0
  16. package/dist/components/ui/core/calendar/calendar.js +68 -0
  17. package/dist/components/ui/core/calendar/constants.d.ts +1 -0
  18. package/dist/components/ui/core/card/card.js +102 -185
  19. package/dist/components/ui/core/chart/chart.js +116 -206
  20. package/dist/components/ui/core/chart/index.js +2 -8
  21. package/dist/components/ui/core/checkbox/checkbox.js +67 -132
  22. package/dist/components/ui/core/checkbox/checkbox.metadata.js +7 -7
  23. package/dist/components/ui/core/code-block/code-block.d.ts +1 -1
  24. package/dist/components/ui/core/code-block/code-block.js +179 -267
  25. package/dist/components/ui/core/collapsible/collapsible.js +29 -49
  26. package/dist/components/ui/core/combobox/combobox.js +41 -0
  27. package/dist/components/ui/core/command/command.js +85 -150
  28. package/dist/components/ui/core/count/count.js +21 -32
  29. package/dist/components/ui/core/data-grid/data-grid-cell.d.ts +10 -0
  30. package/dist/components/ui/core/data-grid/data-grid-header-row.d.ts +13 -0
  31. package/dist/components/ui/core/data-grid/data-grid-row.d.ts +18 -0
  32. package/dist/components/ui/core/data-grid/data-grid.d.ts +43 -0
  33. package/dist/components/ui/core/data-grid/data-grid.fixtures.d.ts +12 -0
  34. package/dist/components/ui/core/data-grid/data-grid.utils.d.ts +9 -0
  35. package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +60 -72
  36. package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +2 -1
  37. package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +36 -51
  38. package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +63 -87
  39. package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +2 -1
  40. package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +60 -68
  41. package/dist/components/ui/core/date-time-pickers/date-time-picker/index.d.ts +1 -0
  42. package/dist/components/ui/core/date-time-pickers/date-time-picker/types.d.ts +36 -0
  43. package/dist/components/ui/core/date-time-pickers/date-time-picker/use-date-time-picker.d.ts +3 -0
  44. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +118 -174
  45. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +7 -6
  46. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +104 -145
  47. package/dist/components/ui/core/date-time-pickers/index.d.ts +3 -1
  48. package/dist/components/ui/core/date-time-pickers/index.js +6 -10
  49. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.d.ts +3 -2
  50. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js +42 -56
  51. package/dist/components/ui/core/date-time-pickers/shared/constants.d.ts +3 -8
  52. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +64 -98
  53. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js +38 -67
  54. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +23 -23
  55. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js +52 -62
  56. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js +18 -18
  57. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js +24 -31
  58. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.d.ts +3 -3
  59. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js +24 -33
  60. package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js +4 -7
  61. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.d.ts +3 -2
  62. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js +17 -31
  63. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts +3 -2
  64. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js +40 -40
  65. package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js +33 -50
  66. package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js +78 -99
  67. package/dist/components/ui/core/date-time-pickers/time-picker/types.d.ts +5 -4
  68. package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js +41 -63
  69. package/dist/components/ui/core/date-time-pickers/time-range-picker/index.d.ts +1 -0
  70. package/dist/components/ui/core/date-time-pickers/time-range-picker/types.d.ts +40 -0
  71. package/dist/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.d.ts +3 -0
  72. package/dist/components/ui/core/date-time-pickers/utils/format-utils.d.ts +1 -0
  73. package/dist/components/ui/core/date-time-pickers/utils/time-utils.d.ts +3 -3
  74. package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +7 -15
  75. package/dist/components/ui/core/dialog/dialog.js +82 -155
  76. package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +2 -2
  77. package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +150 -248
  78. package/dist/components/ui/core/empty-state/empty-state.context.js +5 -8
  79. package/dist/components/ui/core/empty-state/empty-state.js +86 -138
  80. package/dist/components/ui/core/helper-text/helper-text.js +37 -65
  81. package/dist/components/ui/core/hover-card/hover-card.js +54 -80
  82. package/dist/components/ui/core/inline-citation/inline-citation.js +98 -181
  83. package/dist/components/ui/core/input/input.js +12 -27
  84. package/dist/components/ui/core/input-group/input-group.js +76 -173
  85. package/dist/components/ui/core/kbd/kbd.js +20 -36
  86. package/dist/components/ui/core/label/label.js +26 -43
  87. package/dist/components/ui/core/loader/loader.js +80 -117
  88. package/dist/components/ui/core/message/message-response-default-streamdown-controls.js +12 -12
  89. package/dist/components/ui/core/message/message.d.ts +2 -2
  90. package/dist/components/ui/core/message/message.js +316 -542
  91. package/dist/components/ui/core/overflow-list/overflow-list.utils.d.ts +52 -0
  92. package/dist/components/ui/core/pagination/pagination-size-context.js +5 -6
  93. package/dist/components/ui/core/pagination/pagination-teleport.js +86 -106
  94. package/dist/components/ui/core/pagination/pagination-teleport.utils.js +6 -6
  95. package/dist/components/ui/core/pagination/pagination.js +231 -334
  96. package/dist/components/ui/core/popover/popover.js +90 -157
  97. package/dist/components/ui/core/progress/progress.js +36 -61
  98. package/dist/components/ui/core/prompt-input/prompt-input.js +274 -413
  99. package/dist/components/ui/core/radio-group/radio-group.js +58 -113
  100. package/dist/components/ui/core/reasoning/reasoning.js +55 -86
  101. package/dist/components/ui/core/scroll-area/scroll-area.js +41 -71
  102. package/dist/components/ui/core/search/search.js +77 -99
  103. package/dist/components/ui/core/segmented-control/segmented-control.js +110 -167
  104. package/dist/components/ui/core/select/select.js +168 -293
  105. package/dist/components/ui/core/separator/separator.js +13 -23
  106. package/dist/components/ui/core/shimmer/shimmer.d.ts +2 -4
  107. package/dist/components/ui/core/shimmer/shimmer.js +40 -107
  108. package/dist/components/ui/core/skeleton/skeleton.js +13 -18
  109. package/dist/components/ui/core/slider/slider.d.ts +9 -0
  110. package/dist/components/ui/core/slider/slider.js +40 -0
  111. package/dist/components/ui/core/sonner-toast/sonner-toast.js +54 -47
  112. package/dist/components/ui/core/sources/sources.d.ts +5 -1
  113. package/dist/components/ui/core/sources/sources.js +58 -79
  114. package/dist/components/ui/core/switch/switch.js +62 -0
  115. package/dist/components/ui/core/tabs/tabs.js +149 -223
  116. package/dist/components/ui/core/tabs/tabs.utils.js +6 -8
  117. package/dist/components/ui/core/textarea/textarea.js +13 -27
  118. package/dist/components/ui/core/toggle/toggle.js +55 -74
  119. package/dist/components/ui/core/tool/tool.js +127 -163
  120. package/dist/components/ui/core/tooltip/tooltip.js +47 -86
  121. package/dist/components/ui/core/topbar/topbar.js +106 -190
  122. package/dist/eslint/index.js +5 -10
  123. package/dist/eslint/no-overriding-styles.js +178 -237
  124. package/dist/icons/index.d.ts +1 -0
  125. package/dist/icons/index.js +1 -0
  126. package/dist/index.d.ts +1 -1
  127. package/dist/lib/highlight-code.d.ts +9 -0
  128. package/dist/lib/highlight-code.js +42 -0
  129. package/dist/lib/portal-container-context.js +8 -9
  130. package/dist/lib/style-scope.js +6 -6
  131. package/dist/lib/use-controllable-state.js +21 -30
  132. package/dist/lib/utils.d.ts +0 -2
  133. package/dist/lib/utils.js +32 -112
  134. package/dist/styles.css +1 -1
  135. package/dist/styles.source.css +26 -0
  136. package/package.json +42 -8
  137. package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +0 -119
  138. package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.js +0 -93
  139. package/dist/components/ui/core/date-time-pickers/shared/constants.js +0 -14
  140. package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.js +0 -52
  141. /package/dist/components/ui/core/{date-time-pickers/shared/calendar-header → calendar}/calendar-header.d.ts +0 -0
  142. /package/dist/components/ui/core/{date-time-pickers/utils → calendar}/calendar-utils.d.ts +0 -0
  143. /package/dist/components/ui/core/{date-time-pickers/shared/calendar → calendar}/calendar.d.ts +0 -0
@@ -0,0 +1,52 @@
1
+ import { ComponentType, ReactElement, ReactNode } from 'react';
2
+ export type OverflowComponent = ComponentType<{
3
+ items: ReactElement[];
4
+ }>;
5
+ export type ItemElement = ReactElement<Record<string, unknown>>;
6
+ export type CollapseStrategy = 'asc' | 'desc' | 'innerAscFirstKeepLast' | 'innerDescFirstKeepLast';
7
+ export type CollapseUnit = number | number[];
8
+ export declare function resolveCollapseOrder(order: CollapseUnit[] | CollapseStrategy, itemCount: number): CollapseUnit[];
9
+ export type CollapseState = {
10
+ hiddenIndices: number[];
11
+ overflowAt: number;
12
+ };
13
+ export declare const INITIAL_STATE: CollapseState;
14
+ export declare function arraysEqual(a: number[], b: number[]): boolean;
15
+ export declare function totalWidth(itemWidths: number[], gap: number): number;
16
+ export declare const FIT_EPSILON = 0.5;
17
+ export declare function getMeasurements(measureEl: HTMLElement, overflowEl: HTMLElement, hasSep: boolean, orientation?: 'horizontal' | 'vertical', lastItemFlexibleSelector?: string): {
18
+ itemWidths: number[];
19
+ gap: number;
20
+ overflowWidth: number;
21
+ outerMarginLeft: number;
22
+ outerMarginRight: number;
23
+ lastItemFlexibleWidth?: number;
24
+ };
25
+ export declare function hideUntilFit(total: number, itemWidths: number[], gap: number, overflowCost: number, hideOrder: CollapseUnit[], containerWidth: number): {
26
+ hidden: Set<number>;
27
+ firstHidden: number | null;
28
+ };
29
+ export declare function computeCollapseState({ containerSize, itemWidths, gap, overflowWidth, outerMarginLeft, outerMarginRight, collapseOrder, }: {
30
+ containerSize: number;
31
+ itemWidths: number[];
32
+ gap: number;
33
+ overflowWidth: number;
34
+ outerMarginLeft?: number;
35
+ outerMarginRight?: number;
36
+ collapseOrder: CollapseUnit[];
37
+ }): CollapseState;
38
+ export declare function computeCollapsedMinWidth({ itemWidths, gap, overflowWidth, outerMarginLeft, outerMarginRight, collapseOrder, lastItemMinVisible, lastItemFlexibleWidth, }: {
39
+ itemWidths: number[];
40
+ gap: number;
41
+ overflowWidth: number;
42
+ outerMarginLeft?: number;
43
+ outerMarginRight?: number;
44
+ collapseOrder: CollapseUnit[];
45
+ lastItemMinVisible?: number;
46
+ lastItemFlexibleWidth?: number;
47
+ }): number;
48
+ export declare function collapseStatesEqual(a: CollapseState, b: CollapseState): boolean;
49
+ export declare function buildVisibleTokens(items: ReactElement[], hiddenSet: Set<number>, overflowAt: number, hiddenItems: ReactElement[], Overflow: OverflowComponent): Array<{
50
+ key: string | number;
51
+ node: ReactNode;
52
+ }>;
@@ -1,6 +1,5 @@
1
- import { createContext as t, useContext as e } from "react";
2
- const o = t("default"), i = () => e(o);
3
- export {
4
- o as PaginationSizeContext,
5
- i as usePaginationSize
6
- };
1
+ import { createContext as e, useContext as t } from "react";
2
+ //#region libs/aura/src/components/ui/core/pagination/pagination-size-context.tsx
3
+ var n = e("default"), r = () => t(n);
4
+ //#endregion
5
+ export { n as PaginationSizeContext, r as usePaginationSize };
@@ -1,108 +1,88 @@
1
- import { jsx as P } from "react/jsx-runtime";
2
- import { forwardRef as T, useRef as v, useLayoutEffect as k, useState as x } from "react";
3
- import { cva as N } from "class-variance-authority";
4
- import { cn as S } from "../../../../lib/utils.js";
5
- import { Input as V } from "../input/input.js";
6
- import { usePaginationSize as I } from "./pagination-size-context.js";
7
- import { getPaginationTeleportWidth as R } from "./pagination-teleport.utils.js";
8
- const C = N(
9
- [
10
- "tabular-nums text-center font-normal",
11
- "bg-background text-secondary-foreground border-border-emphasized",
12
- "[&:not(:placeholder-shown):not(:focus)]:bg-background [&:not(:placeholder-shown)]:text-secondary-foreground",
13
- "hover:bg-accent-background [&:not(:placeholder-shown):not(:focus):hover]:bg-accent-background hover:border-border-emphasized",
14
- "focus-visible:bg-background focus-visible:text-secondary-foreground focus-visible:border-border-emphasized focus-visible:shadow-focus-ring"
15
- ],
16
- {
17
- variants: {
18
- size: {
19
- default: "h-9 rounded-lg px-3 py-0 text-base leading-5 tracking-tightest",
20
- small: "h-7 rounded-md px-2 py-0 text-sm leading-4.5 tracking-tight"
21
- }
22
- },
23
- defaultVariants: {
24
- size: "default"
25
- }
26
- }
27
- ), W = {
28
- small: {
29
- minWidthPx: 43,
30
- paddingPx: 16
31
- },
32
- default: {
33
- minWidthPx: 55,
34
- paddingPx: 24
35
- }
1
+ import { cn as e } from "../../../../lib/utils.js";
2
+ import { Input as t } from "../input/input.js";
3
+ import { usePaginationSize as n } from "./pagination-size-context.js";
4
+ import { getPaginationTeleportWidth as r } from "./pagination-teleport.utils.js";
5
+ import { forwardRef as i, useLayoutEffect as a, useRef as o, useState as s } from "react";
6
+ import { jsx as c } from "react/jsx-runtime";
7
+ import { cva as l } from "class-variance-authority";
8
+ //#region libs/aura/src/components/ui/core/pagination/pagination-teleport.tsx
9
+ var u = l([
10
+ "tabular-nums text-center font-normal",
11
+ "bg-background text-secondary-foreground border-border-emphasized",
12
+ "[&:not(:placeholder-shown):not(:focus)]:bg-background [&:not(:placeholder-shown)]:text-secondary-foreground",
13
+ "hover:bg-accent-background [&:not(:placeholder-shown):not(:focus):hover]:bg-accent-background hover:border-border-emphasized",
14
+ "focus-visible:bg-background focus-visible:text-secondary-foreground focus-visible:border-border-emphasized focus-visible:shadow-focus-ring"
15
+ ], {
16
+ variants: { size: {
17
+ default: "h-9 rounded-lg px-3 py-0 text-base leading-5 tracking-tightest",
18
+ small: "h-7 rounded-md px-2 py-0 text-sm leading-4.5 tracking-tight"
19
+ } },
20
+ defaultVariants: { size: "default" }
21
+ }), d = {
22
+ small: {
23
+ minWidthPx: 43,
24
+ paddingPx: 16
25
+ },
26
+ default: {
27
+ minWidthPx: 55,
28
+ paddingPx: 24
29
+ }
36
30
  };
37
- function B({
38
- currentPage: o,
39
- totalPages: c,
40
- onPageChange: i
41
- }) {
42
- const s = Math.max(1, c), [d, r] = x(""), [u, t] = x(!1), n = v(!1);
43
- return {
44
- displayValue: u ? d : `${o}/${s}`,
45
- isEditing: u,
46
- onChange: (e) => {
47
- const a = e.target.value;
48
- (a === "" || /^\d+$/.test(a)) && r(a);
49
- },
50
- onFocus: () => {
51
- n.current = !1, t(!0), r(o.toString());
52
- },
53
- onBlur: () => {
54
- if (t(!1), n.current) {
55
- n.current = !1;
56
- return;
57
- }
58
- const e = Number.parseInt(d, 10);
59
- !Number.isNaN(e) && e >= 1 && e <= s && i(e);
60
- },
61
- onKeyDown: (e) => {
62
- e.key === "Enter" ? e.currentTarget.blur() : e.key === "Escape" && (n.current = !0, r(o.toString()), e.currentTarget.blur());
63
- }
64
- };
31
+ function f({ currentPage: e, totalPages: t, onPageChange: n }) {
32
+ let r = Math.max(1, t), [i, a] = s(""), [c, l] = s(!1), u = o(!1);
33
+ return {
34
+ displayValue: c ? i : `${e}/${r}`,
35
+ isEditing: c,
36
+ onChange: (e) => {
37
+ let t = e.target.value;
38
+ (t === "" || /^\d+$/.test(t)) && a(t);
39
+ },
40
+ onFocus: () => {
41
+ u.current = !1, l(!0), a(e.toString());
42
+ },
43
+ onBlur: () => {
44
+ if (l(!1), u.current) {
45
+ u.current = !1;
46
+ return;
47
+ }
48
+ let e = Number.parseInt(i, 10);
49
+ !Number.isNaN(e) && e >= 1 && e <= r && n(e);
50
+ },
51
+ onKeyDown: (t) => {
52
+ t.key === "Enter" ? t.currentTarget.blur() : t.key === "Escape" && (u.current = !0, a(e.toString()), t.currentTarget.blur());
53
+ }
54
+ };
65
55
  }
66
- const D = T(
67
- ({ className: o, currentPage: c, totalPages: i, onPageChange: s, size: d, style: r, ...u }, t) => {
68
- const n = I(), l = d ?? n, { displayValue: h, isEditing: g, onChange: m, onFocus: b, onBlur: e, onKeyDown: a } = B({
69
- currentPage: c,
70
- totalPages: i,
71
- onPageChange: s
72
- }), f = v(null), w = (p) => {
73
- f.current = p, typeof t == "function" ? t(p) : t && (t.current = p);
74
- };
75
- k(() => {
76
- g && f.current && f.current.select();
77
- }, [g]);
78
- const y = W[l], z = R(
79
- i,
80
- y.minWidthPx,
81
- y.paddingPx
82
- ), E = S(
83
- C({ size: l }),
84
- o
85
- );
86
- return /* @__PURE__ */ P(
87
- V,
88
- {
89
- ref: w,
90
- type: "text",
91
- inputMode: "numeric",
92
- value: h,
93
- onChange: m,
94
- onFocus: b,
95
- onBlur: e,
96
- onKeyDown: a,
97
- "data-slot": "pagination-teleport",
98
- className: E,
99
- style: { width: z, ...r },
100
- ...u
101
- }
102
- );
103
- }
104
- );
105
- D.displayName = "PaginationTeleport";
106
- export {
107
- D as PaginationTeleport
108
- };
56
+ var p = i(({ className: i, currentPage: s, totalPages: l, onPageChange: p, size: m, style: h, ...g }, _) => {
57
+ let v = n(), y = m ?? v, { displayValue: b, isEditing: x, onChange: S, onFocus: C, onBlur: w, onKeyDown: T } = f({
58
+ currentPage: s,
59
+ totalPages: l,
60
+ onPageChange: p
61
+ }), E = o(null), D = (e) => {
62
+ E.current = e, typeof _ == "function" ? _(e) : _ && (_.current = e);
63
+ };
64
+ a(() => {
65
+ x && E.current && E.current.select();
66
+ }, [x]);
67
+ let O = d[y], k = r(l, O.minWidthPx, O.paddingPx);
68
+ return /* @__PURE__ */ c(t, {
69
+ ref: D,
70
+ type: "text",
71
+ inputMode: "numeric",
72
+ value: b,
73
+ onChange: S,
74
+ onFocus: C,
75
+ onBlur: w,
76
+ onKeyDown: T,
77
+ "data-slot": "pagination-teleport",
78
+ className: e(u({ size: y }), i),
79
+ style: {
80
+ width: k,
81
+ ...h
82
+ },
83
+ ...g
84
+ });
85
+ });
86
+ p.displayName = "PaginationTeleport";
87
+ //#endregion
88
+ export { p as PaginationTeleport };
@@ -1,7 +1,7 @@
1
- function c(a, e, n) {
2
- const t = Math.max(1, a), o = `${t}/${t}`.length;
3
- return `max(${e}px, calc(${o}ch + ${n}px))`;
1
+ //#region libs/aura/src/components/ui/core/pagination/pagination-teleport.utils.ts
2
+ function e(e, t, n) {
3
+ let r = Math.max(1, e);
4
+ return `max(${t}px, calc(${`${r}/${r}`.length}ch + ${n}px))`;
4
5
  }
5
- export {
6
- c as getPaginationTeleportWidth
7
- };
6
+ //#endregion
7
+ export { e as getPaginationTeleportWidth };