prom-pal-ui 1.1.0 → 1.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.
Files changed (31) hide show
  1. package/build/function/cjs/index.js +131 -0
  2. package/build/function/esm/index.js +129 -0
  3. package/build/types/components/index.d.ts +5 -0
  4. package/build/types/{ui → components/ui}/button.d.ts +2 -2
  5. package/build/types/index.d.ts +1 -7
  6. package/build/{cjs → ui/cjs}/index.js +1008 -1056
  7. package/build/{esm → ui/esm}/index.js +952 -998
  8. package/package.json +17 -2
  9. package/build/min/index.js +0 -29
  10. package/build/types/ui/fields/switch.d.ts +0 -9
  11. package/build/types/ui/form.d.ts +0 -35
  12. package/build/types/ui/input.d.ts +0 -8
  13. package/build/types/ui/label.d.ts +0 -4
  14. package/build/types/ui/textarea.d.ts +0 -8
  15. /package/build/types/{lib → components/lib}/form/rules/index.d.ts +0 -0
  16. /package/build/types/{lib → components/lib}/form/rules/schema-msg.d.ts +0 -0
  17. /package/build/types/{lib → components/lib}/form/rules/schema.d.ts +0 -0
  18. /package/build/types/{lib → components/lib}/index.d.ts +0 -0
  19. /package/build/types/{lib → components/lib}/utils.d.ts +0 -0
  20. /package/build/types/{ui → components/ui}/fields/form.d.ts +0 -0
  21. /package/build/types/{ui → components/ui}/fields/index.d.ts +0 -0
  22. /package/build/types/{ui → components/ui}/fields/input.d.ts +0 -0
  23. /package/build/types/{ui → components/ui}/fields/label.d.ts +0 -0
  24. /package/build/types/{ui → components/ui}/fields/select-field.d.ts +0 -0
  25. /package/build/types/{ui → components/ui}/fields/switch-field.d.ts +0 -0
  26. /package/build/types/{ui → components/ui}/fields/textarea.d.ts +0 -0
  27. /package/build/types/{ui → components/ui}/select.d.ts +0 -0
  28. /package/build/types/{ui → components/ui}/skeleton.d.ts +0 -0
  29. /package/build/types/{ui → components/ui}/switch.d.ts +0 -0
  30. /package/build/types/{ui → components/ui}/test.d.ts +0 -0
  31. /package/build/types/{ui → components/ui}/types.d.ts +0 -0
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+
5
+ /******************************************************************************
6
+ Copyright (c) Microsoft Corporation.
7
+
8
+ Permission to use, copy, modify, and/or distribute this software for any
9
+ purpose with or without fee is hereby granted.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ ***************************************************************************** */
19
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
20
+
21
+
22
+ function __awaiter(thisArg, _arguments, P, generator) {
23
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
24
+ return new (P || (P = Promise))(function (resolve, reject) {
25
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
26
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
27
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
28
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
29
+ });
30
+ }
31
+
32
+ function __generator(thisArg, body) {
33
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
34
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
35
+ function verb(n) { return function (v) { return step([n, v]); }; }
36
+ function step(op) {
37
+ if (f) throw new TypeError("Generator is already executing.");
38
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
39
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
40
+ if (y = 0, t) op = [op[0] & 2, t.value];
41
+ switch (op[0]) {
42
+ case 0: case 1: t = op; break;
43
+ case 4: _.label++; return { value: op[1], done: false };
44
+ case 5: _.label++; y = op[1]; op = [0]; continue;
45
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
46
+ default:
47
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
48
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
49
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
50
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
51
+ if (t[2]) _.ops.pop();
52
+ _.trys.pop(); continue;
53
+ }
54
+ op = body.call(thisArg, _);
55
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
56
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
57
+ }
58
+ }
59
+
60
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
61
+ var e = new Error(message);
62
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
63
+ };
64
+
65
+ var usePromPromiseQuery = function (fetchFn) {
66
+ var _a = react.useState(null), data = _a[0], setData = _a[1];
67
+ var _b = react.useState(true), loading = _b[0], setLoading = _b[1];
68
+ var _c = react.useState(null), error = _c[0], setError = _c[1];
69
+ var lastFnRef = react.useRef(undefined);
70
+ var execute = react.useCallback(function (fn) { return __awaiter(void 0, void 0, void 0, function () {
71
+ var functionToExecute, result, err_1;
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
74
+ case 0:
75
+ setLoading(true);
76
+ setError(null);
77
+ _a.label = 1;
78
+ case 1:
79
+ _a.trys.push([1, 3, 4, 5]);
80
+ functionToExecute = fn || lastFnRef.current;
81
+ if (fn)
82
+ lastFnRef.current = fn;
83
+ if (!functionToExecute) {
84
+ setLoading(false);
85
+ throw new Error("No function to refetch");
86
+ }
87
+ return [4 /*yield*/, functionToExecute()];
88
+ case 2:
89
+ result = _a.sent();
90
+ setData(result);
91
+ console.log("НЕЕЕЕЕТ");
92
+ return [2 /*return*/, result];
93
+ case 3:
94
+ err_1 = _a.sent();
95
+ setError(err_1);
96
+ throw err_1;
97
+ case 4:
98
+ setLoading(false);
99
+ return [7 /*endfinally*/];
100
+ case 5: return [2 /*return*/];
101
+ }
102
+ });
103
+ }); }, []);
104
+ react.useEffect(function () {
105
+ if (fetchFn) {
106
+ execute(fetchFn);
107
+ }
108
+ }, []);
109
+ var onRefetch = react.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
110
+ return __generator(this, function (_a) {
111
+ switch (_a.label) {
112
+ case 0:
113
+ if (!lastFnRef.current) {
114
+ console.warn("No function to refetch");
115
+ return [2 /*return*/, null];
116
+ }
117
+ return [4 /*yield*/, execute(lastFnRef.current)];
118
+ case 1: return [2 /*return*/, _a.sent()];
119
+ }
120
+ });
121
+ }); }, [execute]);
122
+ return {
123
+ data: data,
124
+ error: error,
125
+ execute: execute,
126
+ loading: loading,
127
+ onRefetch: onRefetch,
128
+ };
129
+ };
130
+
131
+ exports.usePromPromiseQuery = usePromPromiseQuery;
@@ -0,0 +1,129 @@
1
+ import { useState, useRef, useCallback, useEffect } from 'react';
2
+
3
+ /******************************************************************************
4
+ Copyright (c) Microsoft Corporation.
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
16
+ ***************************************************************************** */
17
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
18
+
19
+
20
+ function __awaiter(thisArg, _arguments, P, generator) {
21
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
22
+ return new (P || (P = Promise))(function (resolve, reject) {
23
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
25
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
26
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
27
+ });
28
+ }
29
+
30
+ function __generator(thisArg, body) {
31
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
32
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
33
+ function verb(n) { return function (v) { return step([n, v]); }; }
34
+ function step(op) {
35
+ if (f) throw new TypeError("Generator is already executing.");
36
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
37
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
38
+ if (y = 0, t) op = [op[0] & 2, t.value];
39
+ switch (op[0]) {
40
+ case 0: case 1: t = op; break;
41
+ case 4: _.label++; return { value: op[1], done: false };
42
+ case 5: _.label++; y = op[1]; op = [0]; continue;
43
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
44
+ default:
45
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
46
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
47
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
48
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
49
+ if (t[2]) _.ops.pop();
50
+ _.trys.pop(); continue;
51
+ }
52
+ op = body.call(thisArg, _);
53
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
54
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
55
+ }
56
+ }
57
+
58
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
59
+ var e = new Error(message);
60
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
61
+ };
62
+
63
+ var usePromPromiseQuery = function (fetchFn) {
64
+ var _a = useState(null), data = _a[0], setData = _a[1];
65
+ var _b = useState(true), loading = _b[0], setLoading = _b[1];
66
+ var _c = useState(null), error = _c[0], setError = _c[1];
67
+ var lastFnRef = useRef(undefined);
68
+ var execute = useCallback(function (fn) { return __awaiter(void 0, void 0, void 0, function () {
69
+ var functionToExecute, result, err_1;
70
+ return __generator(this, function (_a) {
71
+ switch (_a.label) {
72
+ case 0:
73
+ setLoading(true);
74
+ setError(null);
75
+ _a.label = 1;
76
+ case 1:
77
+ _a.trys.push([1, 3, 4, 5]);
78
+ functionToExecute = fn || lastFnRef.current;
79
+ if (fn)
80
+ lastFnRef.current = fn;
81
+ if (!functionToExecute) {
82
+ setLoading(false);
83
+ throw new Error("No function to refetch");
84
+ }
85
+ return [4 /*yield*/, functionToExecute()];
86
+ case 2:
87
+ result = _a.sent();
88
+ setData(result);
89
+ console.log("НЕЕЕЕЕТ");
90
+ return [2 /*return*/, result];
91
+ case 3:
92
+ err_1 = _a.sent();
93
+ setError(err_1);
94
+ throw err_1;
95
+ case 4:
96
+ setLoading(false);
97
+ return [7 /*endfinally*/];
98
+ case 5: return [2 /*return*/];
99
+ }
100
+ });
101
+ }); }, []);
102
+ useEffect(function () {
103
+ if (fetchFn) {
104
+ execute(fetchFn);
105
+ }
106
+ }, []);
107
+ var onRefetch = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
108
+ return __generator(this, function (_a) {
109
+ switch (_a.label) {
110
+ case 0:
111
+ if (!lastFnRef.current) {
112
+ console.warn("No function to refetch");
113
+ return [2 /*return*/, null];
114
+ }
115
+ return [4 /*yield*/, execute(lastFnRef.current)];
116
+ case 1: return [2 /*return*/, _a.sent()];
117
+ }
118
+ });
119
+ }); }, [execute]);
120
+ return {
121
+ data: data,
122
+ error: error,
123
+ execute: execute,
124
+ loading: loading,
125
+ onRefetch: onRefetch,
126
+ };
127
+ };
128
+
129
+ export { usePromPromiseQuery };
@@ -0,0 +1,5 @@
1
+ export * from "./ui/button";
2
+ export * from "./ui/select";
3
+ export * from "./ui/fields";
4
+ export * from "./ui/skeleton";
5
+ export * from "./lib/index";
@@ -2,11 +2,11 @@ import { type VariantProps } from "class-variance-authority";
2
2
  import * as React from "react";
3
3
  import { CommonPromComponentProps } from "./types";
4
4
  declare const buttonVariants: (props?: {
5
- variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
5
+ variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost";
6
6
  size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg";
7
7
  } & import("class-variance-authority/dist/types").ClassProp) => string;
8
8
  declare const skeletonVariants: (props?: {
9
- variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
9
+ variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost";
10
10
  size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg";
11
11
  } & import("class-variance-authority/dist/types").ClassProp) => string;
12
12
  interface PromButtonProps extends React.ComponentProps<"button">, VariantProps<typeof buttonVariants>, CommonPromComponentProps {
@@ -1,8 +1,2 @@
1
- export * from "./ui/button";
2
- export * from "./ui/select";
3
- export * from "./ui/fields";
4
- export * from "./ui/skeleton";
5
- import "./styles/tailwind.css";
6
- export * from "./lib/index";
7
1
  export * from "./function";
8
- export * from "./ui/test";
2
+ export * from "./components";