@fvc/utils 3.0.1 → 3.0.2-next-ec65dfb844e6183b3d7f417eee613cfe5ecfd997

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 (2) hide show
  1. package/README.md +112 -0
  2. package/package.json +11 -1
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # @fvc/utils
2
+
3
+ `@fvc/utils` provides shared utility functions used across the FE-VIS component library. It includes locale-aware text transformation with Azerbaijani character support, CSS custom property resolution for typography props, numeric validation, and a value clamping helper.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @fvc/utils
9
+ ```
10
+
11
+ ## Peer Dependencies
12
+
13
+ The package expects these dependencies to be available in the consuming application:
14
+
15
+ ```bash
16
+ bun add react
17
+ ```
18
+
19
+ ## Import
20
+
21
+ ```tsx
22
+ import { clamp, cssVarResolver, isNumeric, transformText } from '@fvc/utils';
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ```tsx
28
+ import { transformText, clamp, cssVarResolver, isNumeric } from '@fvc/utils';
29
+
30
+ transformText('salam', 'uppercase', 'az'); // 'SALAM'
31
+ clamp({ value: 150, min: 0, max: 100 }); // 100
32
+ cssVarResolver(16); // '16px'
33
+ isNumeric('42'); // true
34
+ ```
35
+
36
+ ## API
37
+
38
+ ### `transformText`
39
+
40
+ Transforms a string with locale-aware casing. Has built-in character mappings for Azerbaijani (`az`) to correctly handle `i ↔ İ` and `ı ↔ I` conversions.
41
+
42
+ ```ts
43
+ transformText(text: string, transformType: TextTransform, locale?: string): string
44
+ ```
45
+
46
+ | Parameter | Type | Default | Description |
47
+ | --------------- | --------------- | ------- | --------------------------------------------------------- |
48
+ | `text` | `string` | — | The input string to transform. |
49
+ | `transformType` | `TextTransform` | — | `'uppercase'`, `'lowercase'`, `'capitalize'`, `'integer'` |
50
+ | `locale` | `string` | `'az'` | BCP 47 locale tag used for case mapping. |
51
+
52
+ ```tsx
53
+ transformText('istanbul', 'uppercase', 'az'); // 'İSTANBUL'
54
+ transformText('İstanbul', 'lowercase', 'az'); // 'istanbul'
55
+ transformText('hello world', 'capitalize'); // 'Hello World'
56
+ transformText('3.14', 'integer'); // '3'
57
+ ```
58
+
59
+ ### `clamp`
60
+
61
+ Clamps a numeric value between a minimum and maximum.
62
+
63
+ ```ts
64
+ clamp({ value: number, min: number, max: number }): number
65
+ ```
66
+
67
+ ```tsx
68
+ clamp({ value: -5, min: 0, max: 100 }); // 0
69
+ clamp({ value: 50, min: 0, max: 100 }); // 50
70
+ clamp({ value: 200, min: 0, max: 100 }); // 100
71
+ ```
72
+
73
+ ### `cssVarResolver`
74
+
75
+ Converts a `size` or `weight` value to a CSS-compatible string. Numbers are suffixed with `px`; strings are returned as-is.
76
+
77
+ ```ts
78
+ cssVarResolver(value?: string | number): string | undefined
79
+ ```
80
+
81
+ ```tsx
82
+ cssVarResolver(16); // '16px'
83
+ cssVarResolver('1.5rem'); // '1.5rem'
84
+ cssVarResolver(undefined); // undefined
85
+ ```
86
+
87
+ ### `isNumeric`
88
+
89
+ Returns `true` when the value consists entirely of digit characters (`0–9`).
90
+
91
+ ```ts
92
+ isNumeric(value?: string | number): boolean
93
+ ```
94
+
95
+ ```tsx
96
+ isNumeric('100'); // true
97
+ isNumeric('10.5'); // false — decimal point is not a digit
98
+ isNumeric(''); // false
99
+ ```
100
+
101
+ ## TypeScript
102
+
103
+ The package ships with type definitions. No `@types/` install needed.
104
+
105
+ ## Development
106
+
107
+ ```bash
108
+ bun run lint
109
+ bun run type-check
110
+ bun run test
111
+ bun run build
112
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fvc/utils",
3
- "version": "3.0.1",
3
+ "version": "3.0.2-next-ec65dfb844e6183b3d7f417eee613cfe5ecfd997",
4
4
  "main": "./dist/lib/index.js",
5
5
  "types": "./dist/lib/utils/src/index.d.ts",
6
6
  "exports": {
@@ -24,6 +24,16 @@
24
24
  "type-check": "tsc --noEmit",
25
25
  "test": "bun test --preload ../../tests/happydom.ts --preload ../../tests/testing-library.tsx"
26
26
  },
27
+ "keywords": [
28
+ "react",
29
+ "react-component",
30
+ "fvc",
31
+ "fe-vis-core",
32
+ "utils",
33
+ "utilities",
34
+ "helpers",
35
+ "design-system"
36
+ ],
27
37
  "peerDependencies": {
28
38
  "react": "^18.0.0"
29
39
  }