@azure-net/kit 4.0.0-0 → 4.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Pixel1917
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -183,29 +183,30 @@ export const createRules = (validationMessages) => {
183
183
  const { message } = { ...params, message: params?.message ?? validationMessages.phone };
184
184
  return ({ val }) => {
185
185
  if (checkVal(val)) {
186
- // eslint-disable-next-line
187
- const cleanedVal = String(val).replace(/[\s\-\(\)\.]/g, '');
188
- if (!cleanedVal) {
186
+ const rawVal = String(val).trim();
187
+ if (!rawVal) {
189
188
  return message();
190
189
  }
191
- if (!/^\+?\d+$/.test(cleanedVal)) {
190
+ if (!/^[\d+\s().-]+$/.test(rawVal)) {
192
191
  return message();
193
192
  }
194
- if (cleanedVal.length < 7 || cleanedVal.length > 16) {
193
+ const normalized = rawVal.replace(/[\s().-]/g, '');
194
+ if (!normalized) {
195
195
  return message();
196
196
  }
197
- let hasValidCountryCode = false;
198
- if (cleanedVal.startsWith('8')) {
199
- if (cleanedVal.length === 11) {
200
- hasValidCountryCode = true;
201
- }
197
+ const plusCount = (normalized.match(/\+/g) ?? []).length;
198
+ if (plusCount > 1 || (plusCount === 1 && !normalized.startsWith('+'))) {
199
+ return message();
202
200
  }
203
- else if (/^\d+$/.test(cleanedVal)) {
204
- if (!hasValidCountryCode && cleanedVal.length >= 6 && cleanedVal.length <= 16) {
205
- hasValidCountryCode = true;
206
- }
201
+ const hasInternationalPrefix = normalized.startsWith('+');
202
+ const digitsOnly = hasInternationalPrefix ? normalized.slice(1) : normalized;
203
+ if (!/^\d+$/.test(digitsOnly)) {
204
+ return message();
205
+ }
206
+ if (hasInternationalPrefix) {
207
+ return /^[1-9]\d{6,14}$/.test(digitsOnly) ? undefined : message();
207
208
  }
208
- return hasValidCountryCode ? undefined : message();
209
+ return /^\d{7,15}$/.test(digitsOnly) ? undefined : message();
209
210
  }
210
211
  return undefined;
211
212
  };
@@ -12,6 +12,7 @@ export interface CreateQueryOptions<T extends Record<string, unknown>> {
12
12
  }
13
13
  export interface QueryController<T extends Record<string, unknown>> {
14
14
  data: T;
15
+ patch: (value: Partial<T>) => void;
15
16
  reset: () => void;
16
17
  snapshot: () => T;
17
18
  initial: () => T;
@@ -56,6 +56,9 @@ export const createQuery = (initialValue, options) => {
56
56
  const reset = () => {
57
57
  data = ObjectUtil.deepClone(baseInitial);
58
58
  };
59
+ const patch = (value) => {
60
+ data = { ...data, ...value };
61
+ };
59
62
  const snapshot = () => ObjectUtil.deepClone(data);
60
63
  const initial = () => ObjectUtil.deepClone(baseInitial);
61
64
  return {
@@ -65,6 +68,7 @@ export const createQuery = (initialValue, options) => {
65
68
  set data(value) {
66
69
  data = value;
67
70
  },
71
+ patch,
68
72
  reset,
69
73
  snapshot,
70
74
  initial
package/package.json CHANGED
@@ -1,6 +1,22 @@
1
1
  {
2
2
  "name": "@azure-net/kit",
3
- "version": "4.0.0-0",
3
+ "version": "4.0.0",
4
+ "license": "MIT",
5
+ "author": "Pixel1917",
6
+ "description": "Universal toolkit and library collection, developed as part of the Azure-net ecosystem",
7
+ "homepage": "https://github.com/Pixel1917/azure-net-kit",
8
+ "bugs": {
9
+ "url": "https://github.com/Pixel1917/azure-net-kit/issues",
10
+ "email": "sank195951@gmail.com"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/Pixel1917/azure-net-kit.git"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
4
20
  "files": [
5
21
  "dist",
6
22
  "!dist/**/*.test.*",
@@ -78,7 +94,6 @@
78
94
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
79
95
  "@testing-library/jest-dom": "^6.9.1",
80
96
  "@testing-library/svelte": "^5.3.1",
81
- "commander": "^13.1.0",
82
97
  "commitizen": "^4.3.1",
83
98
  "eslint": "^10.2.1",
84
99
  "eslint-config-prettier": "^10.1.8",
@@ -103,12 +118,19 @@
103
118
  }
104
119
  },
105
120
  "keywords": [
106
- "svelte"
121
+ "sveltekit",
122
+ "svelte",
123
+ "toolkit",
124
+ "library",
125
+ "azure-net",
126
+ "store",
127
+ "i18n",
128
+ "utils"
107
129
  ],
108
130
  "dependencies": {
109
- "@azure-net/edges": "^1.2.2",
110
- "@azure-net/edges-translations": "^1.2.2",
111
- "@azure-net/tools": "^1.2.2"
131
+ "@azure-net/edges": "^1.2.5",
132
+ "@azure-net/edges-translations": "^1.2.5",
133
+ "@azure-net/tools": "^1.2.5"
112
134
  },
113
135
  "scripts": {
114
136
  "dev": "vite dev",