@synerise/ds-mocks 0.1.12 → 0.1.14

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 (62) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/Button/index.js +5 -1
  3. package/dist/Button/jest.d.ts +1 -1
  4. package/dist/Button/jest.js +25 -36
  5. package/dist/Button/vi.d.ts +3 -4
  6. package/dist/Button/vi.js +19 -50
  7. package/dist/Cruds/index.js +5 -1
  8. package/dist/Cruds/jest.d.ts +1 -1
  9. package/dist/Cruds/jest.js +33 -52
  10. package/dist/Cruds/vi.d.ts +3 -4
  11. package/dist/Cruds/vi.js +27 -66
  12. package/dist/Dropdown/index.js +5 -1
  13. package/dist/Dropdown/jest.d.ts +1 -1
  14. package/dist/Dropdown/jest.js +31 -38
  15. package/dist/Dropdown/vi.d.ts +3 -4
  16. package/dist/Dropdown/vi.js +25 -52
  17. package/dist/Form/index.js +5 -1
  18. package/dist/Form/jest.d.ts +2 -2
  19. package/dist/Form/jest.js +58 -75
  20. package/dist/Form/vi.d.ts +6 -16
  21. package/dist/Form/vi.js +56 -93
  22. package/dist/Icon/index.js +6 -1
  23. package/dist/Icon/jest.d.ts +1 -1
  24. package/dist/Icon/jest.js +34 -75
  25. package/dist/Icon/vi.d.ts +4 -5
  26. package/dist/Icon/vi.js +26 -69
  27. package/dist/Input/index.js +5 -1
  28. package/dist/Input/jest.d.ts +1 -1
  29. package/dist/Input/jest.js +35 -58
  30. package/dist/Input/vi.d.ts +5 -6
  31. package/dist/Input/vi.js +29 -72
  32. package/dist/Modal/index.js +5 -1
  33. package/dist/Modal/jest.d.ts +1 -1
  34. package/dist/Modal/jest.js +52 -66
  35. package/dist/Modal/vi.d.ts +3 -4
  36. package/dist/Modal/vi.js +46 -80
  37. package/dist/Scrollbar/index.js +4 -1
  38. package/dist/Scrollbar/vi.d.ts +1 -1
  39. package/dist/Scrollbar/vi.js +10 -22
  40. package/dist/Select/index.js +5 -1
  41. package/dist/Select/jest.d.ts +1 -1
  42. package/dist/Select/jest.js +48 -66
  43. package/dist/Select/vi.d.ts +5 -9
  44. package/dist/Select/vi.js +42 -80
  45. package/dist/Table/index.js +5 -1
  46. package/dist/Table/jest.d.ts +1 -1
  47. package/dist/Table/jest.js +85 -105
  48. package/dist/Table/vi.d.ts +3 -4
  49. package/dist/Table/vi.js +79 -120
  50. package/dist/Tabs/index.js +5 -1
  51. package/dist/Tabs/jest.d.ts +1 -1
  52. package/dist/Tabs/jest.js +29 -45
  53. package/dist/Tabs/vi.d.ts +3 -4
  54. package/dist/Tabs/vi.js +23 -59
  55. package/dist/Tooltip/index.js +5 -1
  56. package/dist/Tooltip/jest.d.ts +1 -1
  57. package/dist/Tooltip/jest.js +33 -39
  58. package/dist/Tooltip/vi.d.ts +3 -4
  59. package/dist/Tooltip/vi.js +27 -55
  60. package/dist/index.js +40 -14
  61. package/dist/jest.js +36 -11
  62. package/package.json +119 -119
@@ -1,68 +1,50 @@
1
- import React from 'react';
2
- export var mockSelect = function mockSelect() {
3
- jest.mock('@synerise/ds-select', function () {
4
- return {
5
- __esModule: true,
6
- "default": jest.fn(function (_ref) {
7
- var value = _ref.value,
8
- defaultValue = _ref.defaultValue,
9
- _onChange = _ref.onChange,
10
- onSelect = _ref.onSelect,
11
- placeholder = _ref.placeholder,
12
- disabled = _ref.disabled,
13
- error = _ref.error,
14
- options = _ref.options,
15
- children = _ref.children,
16
- className = _ref.className,
17
- dataTestId = _ref['data-testid'];
18
- return /*#__PURE__*/React.createElement("select", {
19
- className: "ds-select " + (className || ''),
20
- "data-testid": dataTestId || 'ds-select',
21
- "data-error": error,
22
- value: value,
23
- defaultValue: defaultValue,
24
- onChange: function onChange(e) {
25
- _onChange == null || _onChange(e.target.value, {
26
- value: e.target.value,
27
- label: e.target.value
28
- });
29
- onSelect == null || onSelect(e.target.value, {
30
- value: e.target.value,
31
- label: e.target.value
32
- });
33
- },
34
- disabled: disabled
35
- }, placeholder && /*#__PURE__*/React.createElement("option", {
36
- value: ""
37
- }, placeholder), options == null ? void 0 : options.map(
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ const mockSelect = () => {
3
+ jest.mock("@synerise/ds-select", () => ({
4
+ __esModule: true,
5
+ default: jest.fn(({
6
+ value,
7
+ defaultValue,
8
+ onChange,
9
+ onSelect,
10
+ placeholder,
11
+ disabled,
12
+ error,
13
+ options,
14
+ children,
15
+ className,
16
+ "data-testid": dataTestId
17
+ }) => /* @__PURE__ */ jsxs("select", { className: `ds-select ${className || ""}`, "data-testid": dataTestId || "ds-select", "data-error": error, value, defaultValue, onChange: (e) => {
18
+ onChange?.(e.target.value, {
19
+ value: e.target.value,
20
+ label: e.target.value
21
+ });
22
+ onSelect?.(e.target.value, {
23
+ value: e.target.value,
24
+ label: e.target.value
25
+ });
26
+ }, disabled, children: [
27
+ placeholder && /* @__PURE__ */ jsx("option", { value: "", children: placeholder }),
28
+ options?.map(
38
29
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
- function (opt, idx) {
40
- return /*#__PURE__*/React.createElement("option", {
41
- key: idx,
42
- value: String(opt.value)
43
- }, opt.label);
44
- }), children);
45
- }),
46
- Option: jest.fn(function (_ref2) {
47
- var value = _ref2.value,
48
- children = _ref2.children;
49
- return /*#__PURE__*/React.createElement("option", {
50
- value: String(value)
51
- }, children);
52
- })
53
- };
54
- });
30
+ (opt, idx) => /* @__PURE__ */ jsx("option", { value: String(opt.value), children: opt.label }, idx)
31
+ ),
32
+ children
33
+ ] })),
34
+ Option: jest.fn(({
35
+ value,
36
+ children
37
+ }) => /* @__PURE__ */ jsx("option", { value: String(value), children }))
38
+ }));
39
+ };
40
+ const mockSelectMinimal = () => {
41
+ jest.mock("@synerise/ds-select", () => ({
42
+ __esModule: true,
43
+ default: jest.fn(() => null),
44
+ Option: jest.fn(() => null)
45
+ }));
46
+ };
47
+ export {
48
+ mockSelect,
49
+ mockSelectMinimal
55
50
  };
56
- export var mockSelectMinimal = function mockSelectMinimal() {
57
- jest.mock('@synerise/ds-select', function () {
58
- return {
59
- __esModule: true,
60
- "default": jest.fn(function () {
61
- return null;
62
- }),
63
- Option: jest.fn(function () {
64
- return null;
65
- })
66
- };
67
- });
68
- };
@@ -1,5 +1,4 @@
1
- import React, { type ReactNode } from 'react';
2
- import type { SelectProps } from '@synerise/ds-select';
1
+ import { SelectProps } from '@synerise/ds-select';
3
2
  export type MockSelectProps = SelectProps & {
4
3
  'data-testid'?: string;
5
4
  };
@@ -15,11 +14,8 @@ export type MockSelectProps = SelectProps & {
15
14
  * ```
16
15
  */
17
16
  export declare const selectMockFactory: () => {
18
- default: import("vitest").Mock<({ value, defaultValue, onChange, onSelect, placeholder, disabled, error, options, children, className, "data-testid": dataTestId, }: MockSelectProps) => React.JSX.Element>;
19
- Option: import("vitest").Mock<({ value, children }: {
20
- value: unknown;
21
- children: ReactNode;
22
- }) => React.JSX.Element>;
17
+ default: any;
18
+ Option: any;
23
19
  };
24
20
  /**
25
21
  * Factory function for minimal Select mock.
@@ -30,6 +26,6 @@ export declare const selectMockFactory: () => {
30
26
  * ```
31
27
  */
32
28
  export declare const selectMinimalMockFactory: () => {
33
- default: import("vitest").Mock<() => null>;
34
- Option: import("vitest").Mock<() => null>;
29
+ default: any;
30
+ Option: any;
35
31
  };
package/dist/Select/vi.js CHANGED
@@ -1,82 +1,44 @@
1
- import React from 'react';
2
- /**
3
- * Factory function for Select mock.
4
- * Use directly with vi.mock() to avoid hoisting issues.
5
- *
6
- * @example
7
- * ```typescript
8
- * import { selectMockFactory } from '@synerise/ds-mocks/Select/vi';
9
- *
10
- * vi.mock('@synerise/ds-select', selectMockFactory);
11
- * ```
12
- */
13
- export var selectMockFactory = function selectMockFactory() {
14
- return {
15
- "default": vi.fn(function (_ref) {
16
- var value = _ref.value,
17
- defaultValue = _ref.defaultValue,
18
- _onChange = _ref.onChange,
19
- onSelect = _ref.onSelect,
20
- placeholder = _ref.placeholder,
21
- disabled = _ref.disabled,
22
- error = _ref.error,
23
- options = _ref.options,
24
- children = _ref.children,
25
- className = _ref.className,
26
- dataTestId = _ref['data-testid'];
27
- return /*#__PURE__*/React.createElement("select", {
28
- className: "ds-select " + (className || ''),
29
- "data-testid": dataTestId || 'ds-select',
30
- "data-error": error,
31
- value: value,
32
- defaultValue: defaultValue,
33
- onChange: function onChange(e) {
34
- _onChange == null || _onChange(e.target.value, {
35
- value: e.target.value,
36
- label: e.target.value
37
- });
38
- onSelect == null || onSelect(e.target.value, {
39
- value: e.target.value,
40
- label: e.target.value
41
- });
42
- },
43
- disabled: disabled
44
- }, placeholder && /*#__PURE__*/React.createElement("option", {
45
- value: ""
46
- }, placeholder), options == null ? void 0 : options.map(
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ const selectMockFactory = () => ({
3
+ default: vi.fn(({
4
+ value,
5
+ defaultValue,
6
+ onChange,
7
+ onSelect,
8
+ placeholder,
9
+ disabled,
10
+ error,
11
+ options,
12
+ children,
13
+ className,
14
+ "data-testid": dataTestId
15
+ }) => /* @__PURE__ */ jsxs("select", { className: `ds-select ${className || ""}`, "data-testid": dataTestId || "ds-select", "data-error": error, value, defaultValue, onChange: (e) => {
16
+ onChange?.(e.target.value, {
17
+ value: e.target.value,
18
+ label: e.target.value
19
+ });
20
+ onSelect?.(e.target.value, {
21
+ value: e.target.value,
22
+ label: e.target.value
23
+ });
24
+ }, disabled, children: [
25
+ placeholder && /* @__PURE__ */ jsx("option", { value: "", children: placeholder }),
26
+ options?.map(
47
27
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- function (opt, idx) {
49
- return /*#__PURE__*/React.createElement("option", {
50
- key: idx,
51
- value: String(opt.value)
52
- }, opt.label);
53
- }), children);
54
- }),
55
- Option: vi.fn(function (_ref2) {
56
- var value = _ref2.value,
57
- children = _ref2.children;
58
- return /*#__PURE__*/React.createElement("option", {
59
- value: String(value)
60
- }, children);
61
- })
62
- };
28
+ (opt, idx) => /* @__PURE__ */ jsx("option", { value: String(opt.value), children: opt.label }, idx)
29
+ ),
30
+ children
31
+ ] })),
32
+ Option: vi.fn(({
33
+ value,
34
+ children
35
+ }) => /* @__PURE__ */ jsx("option", { value: String(value), children }))
36
+ });
37
+ const selectMinimalMockFactory = () => ({
38
+ default: vi.fn(() => null),
39
+ Option: vi.fn(() => null)
40
+ });
41
+ export {
42
+ selectMinimalMockFactory,
43
+ selectMockFactory
63
44
  };
64
-
65
- /**
66
- * Factory function for minimal Select mock.
67
- *
68
- * @example
69
- * ```typescript
70
- * vi.mock('@synerise/ds-select', selectMinimalMockFactory);
71
- * ```
72
- */
73
- export var selectMinimalMockFactory = function selectMinimalMockFactory() {
74
- return {
75
- "default": vi.fn(function () {
76
- return null;
77
- }),
78
- Option: vi.fn(function () {
79
- return null;
80
- })
81
- };
82
- };
@@ -1 +1,5 @@
1
- export * from './vi';
1
+ import { tableMinimalMockFactory, tableMockFactory } from "./vi.js";
2
+ export {
3
+ tableMinimalMockFactory,
4
+ tableMockFactory
5
+ };
@@ -1,4 +1,4 @@
1
- import type { DSTableProps } from '@synerise/ds-table';
1
+ import { DSTableProps } from '@synerise/ds-table';
2
2
  export type MockTableProps = DSTableProps<Record<string, unknown>> & {
3
3
  'data-testid'?: string;
4
4
  };
@@ -1,111 +1,91 @@
1
- import React from 'react';
2
- var getDataIndex = function getDataIndex(dataIndex) {
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ const getDataIndex = (dataIndex) => {
3
3
  if (Array.isArray(dataIndex)) {
4
- return dataIndex.join('.');
4
+ return dataIndex.join(".");
5
5
  }
6
- return String(dataIndex != null ? dataIndex : '');
6
+ return String(dataIndex ?? "");
7
7
  };
8
- export var mockTable = function mockTable() {
9
- jest.mock('@synerise/ds-table', function () {
10
- return {
11
- __esModule: true,
12
- "default": jest.fn(function (_ref) {
13
- var _ref$dataSource = _ref.dataSource,
14
- dataSource = _ref$dataSource === void 0 ? [] : _ref$dataSource,
15
- _ref$columns = _ref.columns,
16
- columns = _ref$columns === void 0 ? [] : _ref$columns,
17
- loading = _ref.loading,
18
- _ref$rowKey = _ref.rowKey,
19
- rowKey = _ref$rowKey === void 0 ? 'key' : _ref$rowKey,
20
- onRow = _ref.onRow,
21
- rowSelection = _ref.rowSelection,
22
- title = _ref.title,
23
- dataTestId = _ref['data-testid'];
24
- var testId = dataTestId || 'ds-table';
25
- var getRowKey = function getRowKey(record, index) {
26
- var _record$rowKey;
27
- if (typeof rowKey === 'function') {
28
- return rowKey(record);
29
- }
30
- return String((_record$rowKey = record[rowKey]) != null ? _record$rowKey : index);
31
- };
32
- var renderTitle = function renderTitle(t) {
33
- if (typeof t === 'function') {
34
- return null;
35
- }
36
- return t;
37
- };
38
- var renderColumnTitle = function renderColumnTitle(colTitle) {
39
- if (typeof colTitle === 'function') {
40
- return null;
41
- }
42
- return colTitle;
43
- };
44
- return /*#__PURE__*/React.createElement("div", {
45
- "data-testid": testId,
46
- className: "ds-table",
47
- "data-loading": loading
48
- }, title && /*#__PURE__*/React.createElement("div", {
49
- "data-testid": testId + "-title"
50
- }, renderTitle(title)), loading ? /*#__PURE__*/React.createElement("div", {
51
- "data-testid": testId + "-loading"
52
- }, "Loading...") : /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", {
53
- "data-testid": testId + "-header"
54
- }, rowSelection && /*#__PURE__*/React.createElement("th", null, "Select"), columns.map(
55
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
- function (col, idx) {
57
- return /*#__PURE__*/React.createElement("th", {
58
- key: col.key || idx,
59
- "data-testid": testId + "-header-" + (getDataIndex(col.dataIndex) || idx)
60
- }, renderColumnTitle(col.title));
61
- }))), /*#__PURE__*/React.createElement("tbody", null, dataSource.map(
62
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
- function (record, rowIndex) {
64
- var _rowSelection$selecte;
65
- var key = getRowKey(record, rowIndex);
66
- var rowProps = onRow == null ? void 0 : onRow(record, rowIndex);
67
- return /*#__PURE__*/React.createElement("tr", {
68
- key: key,
69
- "data-testid": testId + "-row-" + rowIndex,
70
- onClick: rowProps == null ? void 0 : rowProps.onClick
71
- }, rowSelection && /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("input", {
72
- type: "checkbox",
73
- "data-testid": testId + "-checkbox-" + rowIndex,
74
- checked: (_rowSelection$selecte = rowSelection.selectedRowKeys) == null ? void 0 : _rowSelection$selecte.includes(key),
75
- onChange: function onChange() {
76
- var _rowSelection$selecte2;
77
- var newKeys = (_rowSelection$selecte2 = rowSelection.selectedRowKeys) != null && _rowSelection$selecte2.includes(key) ? rowSelection.selectedRowKeys.filter(
8
+ const mockTable = () => {
9
+ jest.mock("@synerise/ds-table", () => ({
10
+ __esModule: true,
11
+ default: jest.fn(({
12
+ dataSource = [],
13
+ columns = [],
14
+ loading,
15
+ rowKey = "key",
16
+ onRow,
17
+ rowSelection,
18
+ title,
19
+ "data-testid": dataTestId
20
+ }) => {
21
+ const testId = dataTestId || "ds-table";
22
+ const getRowKey = (record, index) => {
23
+ if (typeof rowKey === "function") {
24
+ return rowKey(record);
25
+ }
26
+ return String(record[rowKey] ?? index);
27
+ };
28
+ const renderTitle = (t) => {
29
+ if (typeof t === "function") {
30
+ return null;
31
+ }
32
+ return t;
33
+ };
34
+ const renderColumnTitle = (colTitle) => {
35
+ if (typeof colTitle === "function") {
36
+ return null;
37
+ }
38
+ return colTitle;
39
+ };
40
+ return /* @__PURE__ */ jsxs("div", { "data-testid": testId, className: "ds-table", "data-loading": loading, children: [
41
+ title && /* @__PURE__ */ jsx("div", { "data-testid": `${testId}-title`, children: renderTitle(title) }),
42
+ loading ? /* @__PURE__ */ jsx("div", { "data-testid": `${testId}-loading`, children: "Loading..." }) : /* @__PURE__ */ jsxs("table", { children: [
43
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { "data-testid": `${testId}-header`, children: [
44
+ rowSelection && /* @__PURE__ */ jsx("th", { children: "Select" }),
45
+ columns.map(
78
46
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
- function (k) {
80
- return k !== key;
81
- }) : [].concat(rowSelection.selectedRowKeys || [], [key]);
82
- rowSelection.onChange == null || rowSelection.onChange(newKeys, [], {
83
- type: 'all'
84
- });
47
+ (col, idx) => /* @__PURE__ */ jsx("th", { "data-testid": `${testId}-header-${getDataIndex(col.dataIndex) || idx}`, children: renderColumnTitle(col.title) }, col.key || idx)
48
+ )
49
+ ] }) }),
50
+ /* @__PURE__ */ jsx("tbody", { children: dataSource.map(
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ (record, rowIndex) => {
53
+ const key = getRowKey(record, rowIndex);
54
+ const rowProps = onRow?.(record, rowIndex);
55
+ return /* @__PURE__ */ jsxs("tr", { "data-testid": `${testId}-row-${rowIndex}`, onClick: rowProps?.onClick, children: [
56
+ rowSelection && /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("input", { type: "checkbox", "data-testid": `${testId}-checkbox-${rowIndex}`, checked: rowSelection.selectedRowKeys?.includes(key), onChange: () => {
57
+ const newKeys = rowSelection.selectedRowKeys?.includes(key) ? rowSelection.selectedRowKeys.filter(
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ (k) => k !== key
60
+ ) : [...rowSelection.selectedRowKeys || [], key];
61
+ rowSelection.onChange?.(newKeys, [], {
62
+ type: "all"
63
+ });
64
+ } }) }),
65
+ columns.map(
66
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
+ (col, colIndex) => {
68
+ const dataIdx = getDataIndex(col.dataIndex);
69
+ const cellValue = record[dataIdx];
70
+ const rendered = col.render ? col.render(cellValue, record, rowIndex) : cellValue;
71
+ return /* @__PURE__ */ jsx("td", { "data-testid": `${testId}-cell-${rowIndex}-${colIndex}`, children: String(rendered ?? "") }, col.key || colIndex);
72
+ }
73
+ )
74
+ ] }, key);
85
75
  }
86
- })), columns.map(
87
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
- function (col, colIndex) {
89
- var dataIdx = getDataIndex(col.dataIndex);
90
- var cellValue = record[dataIdx];
91
- var rendered = col.render ? col.render(cellValue, record, rowIndex) : cellValue;
92
- return /*#__PURE__*/React.createElement("td", {
93
- key: col.key || colIndex,
94
- "data-testid": testId + "-cell-" + rowIndex + "-" + colIndex
95
- }, String(rendered != null ? rendered : ''));
96
- }));
97
- }))));
98
- })
99
- };
100
- });
76
+ ) })
77
+ ] })
78
+ ] });
79
+ })
80
+ }));
81
+ };
82
+ const mockTableMinimal = () => {
83
+ jest.mock("@synerise/ds-table", () => ({
84
+ __esModule: true,
85
+ default: jest.fn(() => null)
86
+ }));
87
+ };
88
+ export {
89
+ mockTable,
90
+ mockTableMinimal
101
91
  };
102
- export var mockTableMinimal = function mockTableMinimal() {
103
- jest.mock('@synerise/ds-table', function () {
104
- return {
105
- __esModule: true,
106
- "default": jest.fn(function () {
107
- return null;
108
- })
109
- };
110
- });
111
- };
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import type { DSTableProps } from '@synerise/ds-table';
1
+ import { DSTableProps } from '@synerise/ds-table';
3
2
  export type MockTableProps = DSTableProps<Record<string, unknown>> & {
4
3
  'data-testid'?: string;
5
4
  };
@@ -15,7 +14,7 @@ export type MockTableProps = DSTableProps<Record<string, unknown>> & {
15
14
  * ```
16
15
  */
17
16
  export declare const tableMockFactory: () => {
18
- default: import("vitest").Mock<({ dataSource, columns, loading, rowKey, onRow, rowSelection, title, "data-testid": dataTestId, }: MockTableProps) => React.JSX.Element>;
17
+ default: any;
19
18
  };
20
19
  /**
21
20
  * Factory function for minimal Table mock.
@@ -26,5 +25,5 @@ export declare const tableMockFactory: () => {
26
25
  * ```
27
26
  */
28
27
  export declare const tableMinimalMockFactory: () => {
29
- default: import("vitest").Mock<() => null>;
28
+ default: any;
30
29
  };