@ciwergrp/nuxid 1.16.2 → 1.16.5

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/README.md CHANGED
@@ -31,7 +31,7 @@ export default defineNuxtConfig({
31
31
  - `alias` (`Array<[from, to]>`)
32
32
  - **Validator helpers** (enabled by default): Element Plus friendly `createValidationRules` plus `ValidationRule` and `ValidationOptions` types. Auto-imported when enabled.
33
33
  - **Form composable** (enabled by default): `useHttp` wraps `$fetch`, handles `processing`, `errors`, `response`, and builds `FormData` automatically (or always when `alwaysFormData: true`). Auto-imported when enabled.
34
- - **Helper utilities** (enabled by default): array/object/number/string/date helpers with configurable factory (`number().abbreviate()`) or prefixed (`NumberAbbreviate()`) styles, locale lookups, currency defaults, and timezone source configuration (`query`/`cookie`/`localStorage`/`static`).
34
+ - **Helper utilities** (enabled by default): array/object/number/string/date helpers with configurable factory (`number().abbreviate()`, `string().normalizeValue()`) or prefixed (`NumberAbbreviate()`) styles, locale lookups, currency defaults, and timezone source configuration (`query`/`cookie`/`localStorage`/`static`).
35
35
  - **Cursor fetch composable** (enabled by default): `useCursorFetch` wraps `$fetch`, supports cursor pagination, polling, reactive params, custom fetchers, and configurable cursor/meta keys. Auto-imported when enabled.
36
36
  - **Pinia integration** (enabled by default): injects Pinia, auto-imports core helpers (`defineStore`, `storeToRefs`, etc.), and auto-imports stores from `stores` by default.
37
37
  - **Icon defaults** (disabled by default): installs `@nuxt/icon` with default component name `KIcon`, size `1.25em`, base class `align-middle inline-block text-current`, mode `svg`. Configure via `nuxid.icon.config`.
@@ -74,6 +74,7 @@ if (form.errors) {
74
74
  ```ts
75
75
  const price = number().currency(4200)
76
76
  const slug = string().slug('Hello World')
77
+ const label = string().normalizeValue('')
77
78
  ```
78
79
 
79
80
  **Cursor fetch example**
package/dist/module.d.mts CHANGED
@@ -55,8 +55,13 @@ interface ValidatorOptions {
55
55
  type ValidatorFeatureInput = boolean | Partial<ValidatorOptions> | undefined;
56
56
 
57
57
  interface IconOptionClientBundle {
58
- scan?: boolean;
58
+ scan?: boolean | {
59
+ globInclude?: string[];
60
+ globExclude?: string[];
61
+ };
59
62
  icons?: string[];
63
+ includeCustomCollections?: boolean;
64
+ sizeLimitKb?: number;
60
65
  }
61
66
  interface IconOptionConfig {
62
67
  /**
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ciwergrp/nuxid",
3
3
  "configKey": "nuxid",
4
- "version": "1.16.2",
4
+ "version": "1.16.5",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -311,6 +311,7 @@ function registerHelperFeature(options, { from, plugin }) {
311
311
  "lcfirst",
312
312
  "length",
313
313
  "lower",
314
+ "normalizeValue",
314
315
  "padBoth",
315
316
  "padLeft",
316
317
  "padRight",
@@ -3,6 +3,7 @@ import { length, ltrim, rtrim, start, finish } from './basic.js';
3
3
  import { camel, kebab, lcfirst, lower, snake, studly, title, ucfirst, upper } from './case.js';
4
4
  import { contains, containsAll, endsWith, startsWith } from './match.js';
5
5
  import { defaultLocale, useLocale, withLocale } from './locale.js';
6
+ import { normalizeValue } from './normalizeValue.js';
6
7
  import { padBoth, padLeft, padRight } from './pad.js';
7
8
  import { remove, replace, replaceFirst, replaceLast } from './replace.js';
8
9
  import { slug } from './slug.js';
@@ -27,6 +28,7 @@ export interface StringHelper {
27
28
  length: typeof length;
28
29
  lower: typeof lower;
29
30
  ltrim: typeof ltrim;
31
+ normalizeValue: typeof normalizeValue;
30
32
  padBoth: typeof padBoth;
31
33
  padLeft: typeof padLeft;
32
34
  padRight: typeof padRight;
@@ -50,4 +52,4 @@ export interface StringHelper {
50
52
  withLocale: typeof withLocale;
51
53
  }
52
54
  export declare function string(): StringHelper;
53
- export { after, afterLast, ascii, before, beforeLast, between, betweenFirst, defaultLocale, camel, contains, containsAll, endsWith, finish, kebab, lcfirst, length, lower, padBoth, padLeft, padRight, remove, replace, replaceFirst, replaceLast, rtrim, slug, snake, start, startsWith, studly, title, transliterate, ucfirst, upper, wordCount, words, useLocale, withLocale, };
55
+ export { after, afterLast, ascii, before, beforeLast, between, betweenFirst, defaultLocale, camel, contains, containsAll, endsWith, finish, kebab, lcfirst, length, lower, normalizeValue, padBoth, padLeft, padRight, remove, replace, replaceFirst, replaceLast, rtrim, slug, snake, start, startsWith, studly, title, transliterate, ucfirst, upper, wordCount, words, useLocale, withLocale, };
@@ -3,6 +3,7 @@ import { length, ltrim, rtrim, start, finish } from "./basic.js";
3
3
  import { camel, kebab, lcfirst, lower, snake, studly, title, ucfirst, upper } from "./case.js";
4
4
  import { contains, containsAll, endsWith, startsWith } from "./match.js";
5
5
  import { defaultLocale, useLocale, withLocale } from "./locale.js";
6
+ import { normalizeValue } from "./normalizeValue.js";
6
7
  import { padBoth, padLeft, padRight } from "./pad.js";
7
8
  import { remove, replace, replaceFirst, replaceLast } from "./replace.js";
8
9
  import { slug } from "./slug.js";
@@ -28,6 +29,7 @@ export function string() {
28
29
  length,
29
30
  lower,
30
31
  ltrim,
32
+ normalizeValue,
31
33
  padBoth,
32
34
  padLeft,
33
35
  padRight,
@@ -69,6 +71,7 @@ export {
69
71
  lcfirst,
70
72
  length,
71
73
  lower,
74
+ normalizeValue,
72
75
  padBoth,
73
76
  padLeft,
74
77
  padRight,
@@ -0,0 +1,2 @@
1
+ export type EmptyValue = null | undefined | string | readonly unknown[] | Map<unknown, unknown> | Set<unknown> | Record<PropertyKey, unknown>;
2
+ export declare function normalizeValue(value: unknown, newValue?: unknown): unknown;
@@ -0,0 +1,39 @@
1
+ function isEmpty(value) {
2
+ if (value == null)
3
+ return true;
4
+ if (typeof value.length === "number") {
5
+ return value.length === 0;
6
+ }
7
+ const tag = Object.prototype.toString.call(value);
8
+ if (tag === "[object Map]" || tag === "[object Set]") {
9
+ return value.size === 0;
10
+ }
11
+ const type = typeof value;
12
+ if (type !== "object" && type !== "function") {
13
+ return true;
14
+ }
15
+ const proto = Object.getPrototypeOf(value);
16
+ const isPlainish = proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null;
17
+ if (!isPlainish && tag !== "[object Object]") {
18
+ return true;
19
+ }
20
+ return Object.keys(value).length === 0;
21
+ }
22
+ export function normalizeValue(value, newValue) {
23
+ if (typeof value === "boolean") {
24
+ return value;
25
+ }
26
+ if (typeof value === "number") {
27
+ return value.toLocaleString();
28
+ }
29
+ if (newValue) {
30
+ return newValue;
31
+ }
32
+ if (!isEmpty(value)) {
33
+ return value;
34
+ }
35
+ if (typeof value === "string" && value === "") {
36
+ return "-";
37
+ }
38
+ return "-";
39
+ }
@@ -5,7 +5,7 @@ outline: [2, 3]
5
5
 
6
6
  # String Helpers
7
7
 
8
- String helpers cover casing, trimming, matching, and slug formatting.
8
+ String helpers cover casing, trimming, matching, slug formatting, and value normalization.
9
9
 
10
10
  Factory style:
11
11
 
@@ -140,6 +140,13 @@ Parameters: `value` (string).
140
140
  - Simple usage: `string().lower('Hello')` = `'hello'`
141
141
  - Advanced usage: `string().lower('HELLO WORLD')` = `'hello world'`
142
142
 
143
+ ### normalizeValue
144
+ Summary: Normalizes empty values to `-`, preserves booleans, and formats numbers with locale separators.
145
+ Parameters: `value` (unknown), `newValue` (unknown, optional).
146
+ - Returns: `unknown`.
147
+ - Simple usage: `string().normalizeValue('')` = `'-'`
148
+ - Advanced usage: `string().normalizeValue(12000)` = `'12,000'`
149
+
143
150
  ### ltrim
144
151
  Summary: Trims left side using `trimStart` or a mask regex.
145
152
  Parameters: `value` (string), `mask` (string, optional).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ciwergrp/nuxid",
3
- "version": "1.16.2",
3
+ "version": "1.16.5",
4
4
  "description": "All-in-one essential modules for Nuxt",
5
5
  "repository": {
6
6
  "type": "git",