@otl-core/cms-utils 1.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 +13 -0
- package/README.md +58 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright (c) 2025 OTL Core
|
|
2
|
+
|
|
3
|
+
Licensed under the PolyForm Shield License, Version 1.0.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may
|
|
5
|
+
obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
https://polyformproject.org/licenses/shield/1.0.0/
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
11
|
+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
12
|
+
License for the specific language governing permissions and limitations
|
|
13
|
+
under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @otl-core/cms-utils
|
|
2
|
+
|
|
3
|
+
Shared utility functions for OTL CMS that work with types from `@otl-core/cms-types`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @otl-core/cms-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Responsive Utilities
|
|
14
|
+
|
|
15
|
+
Utility functions for working with responsive values:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import {
|
|
19
|
+
isResponsiveConfig,
|
|
20
|
+
getBreakpointValue,
|
|
21
|
+
getDefinedBreakpoints,
|
|
22
|
+
toResponsiveConfig,
|
|
23
|
+
fromResponsiveConfig,
|
|
24
|
+
} from "@otl-core/cms-utils";
|
|
25
|
+
import type { ResponsiveValue } from "@otl-core/cms-types";
|
|
26
|
+
|
|
27
|
+
// Check if a value is responsive
|
|
28
|
+
const value: ResponsiveValue<string> = { base: "16px", md: "20px" };
|
|
29
|
+
if (isResponsiveConfig(value)) {
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Get value for a specific breakpoint
|
|
33
|
+
const mdValue = getBreakpointValue(value, "md"); // '20px'
|
|
34
|
+
const xlValue = getBreakpointValue(value, "xl"); // '16px' (falls back to base)
|
|
35
|
+
|
|
36
|
+
// Get all defined breakpoints
|
|
37
|
+
const breakpoints = getDefinedBreakpoints(value); // ['base', 'md']
|
|
38
|
+
|
|
39
|
+
// Convert to responsive config
|
|
40
|
+
const config = toResponsiveConfig({
|
|
41
|
+
base: "1rem",
|
|
42
|
+
lg: "1.5rem",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Convert from responsive config
|
|
46
|
+
const flat = fromResponsiveConfig(config);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Separation of Concerns
|
|
50
|
+
|
|
51
|
+
- **@otl-core/cms-types**: Type definitions only (no runtime code)
|
|
52
|
+
- **@otl-core/cms-utils**: Runtime utility functions that work with the types
|
|
53
|
+
|
|
54
|
+
This separation ensures:
|
|
55
|
+
|
|
56
|
+
- Types can be shared without bundling unnecessary code
|
|
57
|
+
- Utilities can be tree-shaken if not used
|
|
58
|
+
- Clear distinction between compile-time and runtime dependencies
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@otl-core/cms-utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Shared utility functions for OTL CMS",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup",
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"rebuild": "npm run clean && npm run build",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:watch": "vitest",
|
|
25
|
+
"test:ui": "vitest --ui"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"utils",
|
|
29
|
+
"utilities",
|
|
30
|
+
"typescript",
|
|
31
|
+
"cms",
|
|
32
|
+
"responsive"
|
|
33
|
+
],
|
|
34
|
+
"author": "OTL Core",
|
|
35
|
+
"license": "PolyForm-Shield-1.0.0",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/otl-core/cms-utils.git"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@otl-core/cms-types": "^1.0.0",
|
|
42
|
+
"clsx": "^2.1.1",
|
|
43
|
+
"nanoid": "^5.0.0",
|
|
44
|
+
"tailwind-merge": "^3.3.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@vitest/ui": "^4.0.0",
|
|
48
|
+
"tsup": "^8.0.0",
|
|
49
|
+
"typescript": "^5.0.0",
|
|
50
|
+
"vitest": "^4.0.0"
|
|
51
|
+
}
|
|
52
|
+
}
|