@terreno/ui 0.23.1 → 0.25.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.
Files changed (80) hide show
  1. package/dist/AIRequestExplorer.js +6 -1
  2. package/dist/AIRequestExplorer.js.map +1 -1
  3. package/dist/ActionSheet.d.ts +1 -0
  4. package/dist/ActionSheet.js +3 -0
  5. package/dist/ActionSheet.js.map +1 -1
  6. package/dist/AiSuggestionBox.d.ts +11 -0
  7. package/dist/AiSuggestionBox.js +50 -23
  8. package/dist/AiSuggestionBox.js.map +1 -1
  9. package/dist/Common.d.ts +25 -1
  10. package/dist/Common.js.map +1 -1
  11. package/dist/CustomSelectField.js +2 -2
  12. package/dist/CustomSelectField.js.map +1 -1
  13. package/dist/FilePickerButton.js +2 -1
  14. package/dist/FilePickerButton.js.map +1 -1
  15. package/dist/PickerSelect.d.ts +10 -2
  16. package/dist/PickerSelect.js +91 -17
  17. package/dist/PickerSelect.js.map +1 -1
  18. package/dist/SelectBadge.js +1 -1
  19. package/dist/SelectBadge.js.map +1 -1
  20. package/dist/SelectField.js +9 -9
  21. package/dist/SelectField.js.map +1 -1
  22. package/dist/WebDropdownMenu.d.ts +36 -5
  23. package/dist/WebDropdownMenu.js +211 -29
  24. package/dist/WebDropdownMenu.js.map +1 -1
  25. package/dist/createWebPortal.d.ts +7 -0
  26. package/dist/createWebPortal.js +3 -0
  27. package/dist/createWebPortal.js.map +1 -0
  28. package/dist/createWebPortal.native.d.ts +7 -0
  29. package/dist/createWebPortal.native.js +2 -0
  30. package/dist/createWebPortal.native.js.map +1 -0
  31. package/dist/fieldElements/FieldHelperText.js +1 -1
  32. package/dist/fieldElements/FieldHelperText.js.map +1 -1
  33. package/dist/icons/SparklesIcon.d.ts +7 -0
  34. package/dist/icons/SparklesIcon.js +32 -0
  35. package/dist/icons/SparklesIcon.js.map +1 -0
  36. package/dist/icons/index.d.ts +1 -0
  37. package/dist/icons/index.js +1 -0
  38. package/dist/icons/index.js.map +1 -1
  39. package/package.json +2 -2
  40. package/src/AIRequestExplorer.tsx +6 -1
  41. package/src/ActionSheet.test.tsx +198 -2
  42. package/src/ActionSheet.tsx +4 -0
  43. package/src/AiSuggestionBox.test.tsx +184 -15
  44. package/src/AiSuggestionBox.tsx +72 -55
  45. package/src/Common.ts +28 -1
  46. package/src/CustomSelectField.test.tsx +13 -3
  47. package/src/CustomSelectField.tsx +2 -0
  48. package/src/EmojiSelector.test.tsx +153 -0
  49. package/src/FilePickerButton.tsx +2 -1
  50. package/src/Modal.test.tsx +47 -0
  51. package/src/PickerSelect.test.tsx +253 -14
  52. package/src/PickerSelect.tsx +206 -49
  53. package/src/SelectBadge.tsx +1 -0
  54. package/src/SelectBadge.web.test.tsx +10 -0
  55. package/src/SelectField.tsx +19 -15
  56. package/src/WebDropdownMenu.test.tsx +449 -0
  57. package/src/WebDropdownMenu.tsx +405 -60
  58. package/src/__snapshots__/AddressField.test.tsx.snap +2088 -665
  59. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +489 -102
  60. package/src/__snapshots__/CustomSelectField.test.tsx.snap +2118 -1369
  61. package/src/__snapshots__/Field.test.tsx.snap +3787 -1806
  62. package/src/__snapshots__/HeightField.test.tsx.snap +3 -0
  63. package/src/__snapshots__/PickerSelect.test.tsx.snap +7 -7
  64. package/src/__snapshots__/SelectField.test.tsx.snap +1548 -1102
  65. package/src/__snapshots__/Slider.test.tsx.snap +3 -0
  66. package/src/__snapshots__/TextArea.test.tsx.snap +3 -0
  67. package/src/__snapshots__/TextField.test.tsx.snap +3 -0
  68. package/src/__snapshots__/TimezonePicker.test.tsx.snap +2499 -1353
  69. package/src/createWebPortal.native.ts +8 -0
  70. package/src/createWebPortal.test.tsx +13 -0
  71. package/src/createWebPortal.ts +10 -0
  72. package/src/fieldElements/FieldHelperText.tsx +4 -2
  73. package/src/fieldElements/__snapshots__/FieldHelperText.test.tsx.snap +3 -0
  74. package/src/icons/SparklesIcon.test.tsx +16 -0
  75. package/src/icons/SparklesIcon.tsx +38 -0
  76. package/src/icons/__snapshots__/SparklesIcon.test.tsx.snap +47 -0
  77. package/src/icons/index.ts +1 -0
  78. package/src/table/TableBadge.test.tsx +19 -11
  79. package/src/table/__snapshots__/TableBadge.test.tsx.snap +226 -175
  80. package/src/types/react-dom.d.ts +5 -0
@@ -0,0 +1,8 @@
1
+ import type {ReactElement} from "react";
2
+
3
+ interface CreateWebPortalOptions {
4
+ children: ReactElement;
5
+ container: Element;
6
+ }
7
+
8
+ export const createWebPortal = ({children}: CreateWebPortalOptions): ReactElement => children;
@@ -0,0 +1,13 @@
1
+ import {describe, expect, it} from "bun:test";
2
+ import React from "react";
3
+
4
+ import {createWebPortal as createNativePortal} from "./createWebPortal.native";
5
+
6
+ describe("createWebPortal (native)", () => {
7
+ it("returns the children unchanged without creating a portal", () => {
8
+ const container = {nodeType: 1} as unknown as Element;
9
+ const children = React.createElement("div", null, "native-content");
10
+
11
+ expect(createNativePortal({children, container})).toBe(children);
12
+ });
13
+ });
@@ -0,0 +1,10 @@
1
+ import type {ReactElement} from "react";
2
+ import {createPortal} from "react-dom";
3
+
4
+ interface CreateWebPortalOptions {
5
+ children: ReactElement;
6
+ container: Element;
7
+ }
8
+
9
+ export const createWebPortal = ({children, container}: CreateWebPortalOptions): ReactElement =>
10
+ createPortal(children, container);
@@ -15,8 +15,10 @@ export const FieldHelperText: FC<FieldHelperTextProps> = ({text, testID}) => {
15
15
  const {theme} = useTheme();
16
16
 
17
17
  return (
18
- <View style={{marginTop: 2}} {...toTestProps(testID)}>
19
- <Text style={{color: theme.text.primary, fontSize: 12, lineHeight: 16}}>{text}</Text>
18
+ <View style={{alignSelf: "stretch", marginTop: 2, maxWidth: "100%"}} {...toTestProps(testID)}>
19
+ <Text style={{color: theme.text.primary, flexShrink: 1, fontSize: 12, lineHeight: 16}}>
20
+ {text}
21
+ </Text>
20
22
  </View>
21
23
  );
22
24
  };
@@ -12,6 +12,7 @@ exports[`FieldHelperText renders correctly 1`] = `
12
12
  "props": {
13
13
  "style": {
14
14
  "color": "#1C1C1C",
15
+ "flexShrink": 1,
15
16
  "fontSize": 12,
16
17
  "lineHeight": 16,
17
18
  },
@@ -21,7 +22,9 @@ exports[`FieldHelperText renders correctly 1`] = `
21
22
  ],
22
23
  "props": {
23
24
  "style": {
25
+ "alignSelf": "stretch",
24
26
  "marginTop": 2,
27
+ "maxWidth": "100%",
25
28
  },
26
29
  "testID": undefined,
27
30
  },
@@ -0,0 +1,16 @@
1
+ import {describe, expect, it} from "bun:test";
2
+ import {render} from "@testing-library/react-native";
3
+
4
+ import {SparklesIcon} from "./SparklesIcon";
5
+
6
+ describe("SparklesIcon", () => {
7
+ it("renders correctly", () => {
8
+ const {toJSON} = render(<SparklesIcon />);
9
+ expect(toJSON()).toMatchSnapshot();
10
+ });
11
+
12
+ it("accepts custom props", () => {
13
+ const {toJSON} = render(<SparklesIcon fill="#0A0A0A" height={24} width={24} />);
14
+ expect(toJSON()).toMatchSnapshot();
15
+ });
16
+ });
@@ -0,0 +1,38 @@
1
+ import type React from "react";
2
+ import Svg, {Path, type SvgProps} from "react-native-svg";
3
+
4
+ /**
5
+ * Builds a four-pointed sparkle path with concave edges, centered at (cx, cy) with
6
+ * outer radius r. FontAwesome 6 free has no standalone `sparkles` glyph (it is a Pro
7
+ * icon), so the glyph is composed locally from three of these sparkle shapes.
8
+ */
9
+ const sparklePath = (cx: number, cy: number, r: number): string => {
10
+ const pinch = r * 0.16;
11
+ return [
12
+ `M ${cx} ${cy - r}`,
13
+ `Q ${cx + pinch} ${cy - pinch} ${cx + r} ${cy}`,
14
+ `Q ${cx + pinch} ${cy + pinch} ${cx} ${cy + r}`,
15
+ `Q ${cx - pinch} ${cy + pinch} ${cx - r} ${cy}`,
16
+ `Q ${cx - pinch} ${cy - pinch} ${cx} ${cy - r}`,
17
+ "Z",
18
+ ].join(" ");
19
+ };
20
+
21
+ /** One large sparkle with two smaller companions, mirroring Font Awesome's sparkles layout. */
22
+ const SPARKLES_PATH = [
23
+ sparklePath(200, 272, 200),
24
+ sparklePath(420, 92, 88),
25
+ sparklePath(420, 428, 80),
26
+ ].join(" ");
27
+
28
+ /**
29
+ * Solid "sparkles" icon (three four-pointed stars). Defaults to 16x16 — pass
30
+ * `height`/`width` to resize and `fill` to recolor.
31
+ */
32
+ export const SparklesIcon = (props: SvgProps): React.ReactElement => {
33
+ return (
34
+ <Svg fill="currentColor" height={16} viewBox="0 0 512 512" width={16} {...props}>
35
+ <Path d={SPARKLES_PATH} />
36
+ </Svg>
37
+ );
38
+ };
@@ -0,0 +1,47 @@
1
+ // Bun Snapshot v1, https://bun.sh/docs/test/snapshots
2
+
3
+ exports[`SparklesIcon renders correctly 1`] = `
4
+ {
5
+ "$$typeof": Symbol(react.test.json),
6
+ "children": [
7
+ {
8
+ "$$typeof": Symbol(react.test.json),
9
+ "children": null,
10
+ "props": {
11
+ "d": "M 200 72 Q 232 240 400 272 Q 232 304 200 472 Q 168 304 0 272 Q 168 240 200 72 Z M 420 4 Q 434.08 77.92 508 92 Q 434.08 106.08 420 180 Q 405.92 106.08 332 92 Q 405.92 77.92 420 4 Z M 420 348 Q 432.8 415.2 500 428 Q 432.8 440.8 420 508 Q 407.2 440.8 340 428 Q 407.2 415.2 420 348 Z",
12
+ },
13
+ "type": "Path",
14
+ },
15
+ ],
16
+ "props": {
17
+ "fill": "currentColor",
18
+ "height": 16,
19
+ "viewBox": "0 0 512 512",
20
+ "width": 16,
21
+ },
22
+ "type": "Svg",
23
+ }
24
+ `;
25
+
26
+ exports[`SparklesIcon accepts custom props 1`] = `
27
+ {
28
+ "$$typeof": Symbol(react.test.json),
29
+ "children": [
30
+ {
31
+ "$$typeof": Symbol(react.test.json),
32
+ "children": null,
33
+ "props": {
34
+ "d": "M 200 72 Q 232 240 400 272 Q 232 304 200 472 Q 168 304 0 272 Q 168 240 200 72 Z M 420 4 Q 434.08 77.92 508 92 Q 434.08 106.08 420 180 Q 405.92 106.08 332 92 Q 405.92 77.92 420 4 Z M 420 348 Q 432.8 415.2 500 428 Q 432.8 440.8 420 508 Q 407.2 440.8 340 428 Q 407.2 415.2 420 348 Z",
35
+ },
36
+ "type": "Path",
37
+ },
38
+ ],
39
+ "props": {
40
+ "fill": "#0A0A0A",
41
+ "height": 24,
42
+ "viewBox": "0 0 512 512",
43
+ "width": 24,
44
+ },
45
+ "type": "Svg",
46
+ }
47
+ `;
@@ -2,3 +2,4 @@ export * from "./MobileIcon";
2
2
  export * from "./OfflineIcon";
3
3
  export * from "./OnlineIcon";
4
4
  export * from "./OutOfficeIcon";
5
+ export * from "./SparklesIcon";
@@ -1,5 +1,5 @@
1
1
  import {describe, expect, it} from "bun:test";
2
- import {fireEvent} from "@testing-library/react-native";
2
+ import {act, fireEvent} from "@testing-library/react-native";
3
3
  import {renderWithTheme} from "../test-utils";
4
4
  import {TableBadge} from "./TableBadge";
5
5
 
@@ -55,10 +55,10 @@ describe("TableBadge", () => {
55
55
  it("renders badge when editing is enabled but options are missing", () => {
56
56
  const {getByText, queryByTestId} = renderWithTheme(<TableBadge isEditing value="Pending" />);
57
57
  expect(getByText("Pending")).toBeTruthy();
58
- expect(queryByTestId("ios_picker")).toBeNull();
58
+ expect(queryByTestId("web_picker")).toBeNull();
59
59
  });
60
60
 
61
- it("updates selected value when select field changes to a non-empty option", () => {
61
+ it("updates selected value when select field changes to a non-empty option", async () => {
62
62
  const editingOptions = [
63
63
  {label: "Option A", value: "a"},
64
64
  {label: "Option B", value: "b"},
@@ -66,14 +66,18 @@ describe("TableBadge", () => {
66
66
  const {getByTestId} = renderWithTheme(
67
67
  <TableBadge editingOptions={editingOptions} isEditing value="a" />
68
68
  );
69
- const picker = getByTestId("ios_picker");
70
69
 
71
- expect(picker.props.selectedValue).toBe("a");
72
- fireEvent(picker, "onValueChange", "b", 2);
73
- expect(getByTestId("ios_picker").props.selectedValue).toBe("b");
70
+ expect(getByTestId("text_input").props.children).toBe("Option A");
71
+ await act(async () => {
72
+ fireEvent.press(getByTestId("web_picker"));
73
+ });
74
+ await act(async () => {
75
+ fireEvent.press(getByTestId("web_dropdown_option_b"));
76
+ });
77
+ expect(getByTestId("text_input").props.children).toBe("Option B");
74
78
  });
75
79
 
76
- it("clears selected value when select field changes to an empty value", () => {
80
+ it("clears selected value when select field changes to an empty value", async () => {
77
81
  const editingOptions = [
78
82
  {label: "Option A", value: "a"},
79
83
  {label: "Option B", value: "b"},
@@ -81,9 +85,13 @@ describe("TableBadge", () => {
81
85
  const {getByTestId} = renderWithTheme(
82
86
  <TableBadge editingOptions={editingOptions} isEditing value="a" />
83
87
  );
84
- const picker = getByTestId("ios_picker");
85
88
 
86
- fireEvent(picker, "onValueChange", "", 0);
87
- expect(getByTestId("ios_picker").props.selectedValue).toBe("");
89
+ await act(async () => {
90
+ fireEvent.press(getByTestId("web_picker"));
91
+ });
92
+ await act(async () => {
93
+ fireEvent.press(getByTestId("web_dropdown_option_"));
94
+ });
95
+ expect(getByTestId("text_input").props.children).toBe("Please select an option.");
88
96
  });
89
97
  });