@azure-net/kit 3.9.3 → 4.0.0-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.
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.
@@ -1,4 +1,3 @@
1
- import { masks } from '../../../constants/masks.js';
2
1
  /**
3
2
  *
4
3
  * @param validationMessages - BaseValidationMessages
@@ -180,61 +179,34 @@ export const createRules = (validationMessages) => {
180
179
  * @returns ValidationRuleResult<T, D>
181
180
  * @description Checks if the value is a phone number and if it is valid.
182
181
  */
183
- const countryCodes = new Set(Object.values(masks).map((country) => country.cc)).add('8');
184
182
  const phone = (params) => {
185
183
  const { message } = { ...params, message: params?.message ?? validationMessages.phone };
186
184
  return ({ val }) => {
187
185
  if (checkVal(val)) {
188
- // eslint-disable-next-line
189
- const cleanedVal = String(val).replace(/[\s\-\(\)\.]/g, '');
190
- if (!cleanedVal) {
186
+ const rawVal = String(val).trim();
187
+ if (!rawVal) {
191
188
  return message();
192
189
  }
193
- if (!/^\+?\d+$/.test(cleanedVal)) {
190
+ if (!/^[\d+\s().-]+$/.test(rawVal)) {
194
191
  return message();
195
192
  }
196
- if (cleanedVal.length < 7 || cleanedVal.length > 16) {
193
+ const normalized = rawVal.replace(/[\s().-]/g, '');
194
+ if (!normalized) {
197
195
  return message();
198
196
  }
199
- let hasValidCountryCode = false;
200
- if (cleanedVal.startsWith('+')) {
201
- const sortedCodes = Array.from(countryCodes)
202
- .filter((code) => code.startsWith('+'))
203
- .sort((a, b) => b.length - a.length);
204
- for (const code of sortedCodes) {
205
- if (cleanedVal.startsWith(code)) {
206
- const remainingDigits = cleanedVal.slice(code.length);
207
- if (remainingDigits.length >= 4) {
208
- hasValidCountryCode = true;
209
- break;
210
- }
211
- }
212
- }
197
+ const plusCount = (normalized.match(/\+/g) ?? []).length;
198
+ if (plusCount > 1 || (plusCount === 1 && !normalized.startsWith('+'))) {
199
+ return message();
213
200
  }
214
- else if (cleanedVal.startsWith('8')) {
215
- if (cleanedVal.length === 11) {
216
- hasValidCountryCode = true;
217
- }
201
+ const hasInternationalPrefix = normalized.startsWith('+');
202
+ const digitsOnly = hasInternationalPrefix ? normalized.slice(1) : normalized;
203
+ if (!/^\d+$/.test(digitsOnly)) {
204
+ return message();
218
205
  }
219
- else if (/^\d+$/.test(cleanedVal)) {
220
- const codesWithoutPlus = Array.from(countryCodes)
221
- .filter((code) => !code.startsWith('+') && code !== 'N/A')
222
- .map((code) => code.replace('+', ''))
223
- .sort((a, b) => b.length - a.length);
224
- for (const code of codesWithoutPlus) {
225
- if (cleanedVal.startsWith(code)) {
226
- const remainingDigits = cleanedVal.slice(code.length);
227
- if (remainingDigits.length >= 4) {
228
- hasValidCountryCode = true;
229
- break;
230
- }
231
- }
232
- }
233
- if (!hasValidCountryCode && cleanedVal.length >= 7 && cleanedVal.length <= 10) {
234
- hasValidCountryCode = true;
235
- }
206
+ if (hasInternationalPrefix) {
207
+ return /^[1-9]\d{6,14}$/.test(digitsOnly) ? undefined : message();
236
208
  }
237
- return hasValidCountryCode ? undefined : message();
209
+ return /^\d{7,15}$/.test(digitsOnly) ? undefined : message();
238
210
  }
239
211
  return undefined;
240
212
  };
@@ -1,4 +1,3 @@
1
- export { event, stop, prevent, once, immediate, type EventHandler, onClickOutside, scrollTo, Mask, masked } from './ui/index.js';
2
1
  export { createQuery, createAsyncSignal, createActiveForm, refreshAsyncSignal, refreshAllAsyncSignals, type AsyncSignalOptions, type AsyncSignalSvelte, type QueryController, type CreateQueryOptions, type AsyncSignalSource, type AsyncStatus } from './svelte/index.js';
3
2
  export { createMiddlewareManager, type IMiddleware } from './shared/middleware/index.js';
4
3
  export { ClassMirror } from './shared/classMirror/index.js';
@@ -1,4 +1,3 @@
1
- export { event, stop, prevent, once, immediate, onClickOutside, scrollTo, Mask, masked } from './ui/index.js';
2
1
  export { createQuery, createAsyncSignal, createActiveForm, refreshAsyncSignal, refreshAllAsyncSignals } from './svelte/index.js';
3
2
  export { createMiddlewareManager } from './shared/middleware/index.js';
4
3
  export { ClassMirror } from './shared/classMirror/index.js';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export * from './core/index.js';
2
- export * from './edges/index.js';
2
+ export { __withEdgesUniversalLoad } from './edges/index.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export * from './core/index.js';
2
- export * from './edges/index.js';
2
+ export { __withEdgesUniversalLoad } from './edges/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/kit",
3
- "version": "3.9.3",
3
+ "version": "4.0.0-1",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",
@@ -17,10 +17,6 @@
17
17
  "types": "./dist/index.d.ts",
18
18
  "svelte": "./dist/index.js"
19
19
  },
20
- "./constants": {
21
- "types": "./dist/core/constants/index.d.ts",
22
- "svelte": "./dist/core/constants/index.js"
23
- },
24
20
  "./infra": {
25
21
  "types": "./dist/core/infra.d.ts",
26
22
  "svelte": "./dist/core/infra.js"
@@ -82,7 +78,6 @@
82
78
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
83
79
  "@testing-library/jest-dom": "^6.9.1",
84
80
  "@testing-library/svelte": "^5.3.1",
85
- "commander": "^13.1.0",
86
81
  "commitizen": "^4.3.1",
87
82
  "eslint": "^10.2.1",
88
83
  "eslint-config-prettier": "^10.1.8",
@@ -1 +0,0 @@
1
- export * from './masks.js';
@@ -1 +0,0 @@
1
- export * from './masks.js';