@massimo-cassandro/minimo 1.21.0 → 1.21.2
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/design-tokens/tokens-config-sample.mjs +5 -0
- package/design-tokens/utilities/build-tokens-src/config.mjs +5 -0
- package/design-tokens/utilities/build-tokens-src/formats/css.mjs +7 -1
- package/design-tokens/utilities/build-tokens-src/platforms.mjs +3 -0
- package/design-tokens/utilities/build-tokens.mjs +2 -0
- package/index.js +1 -1
- package/package.json +3 -3
- package/src/minimo.css +1 -1
- package/src/utilities/dom-builder-helpers/form-tags.js +72 -0
|
@@ -63,6 +63,11 @@ const config = {
|
|
|
63
63
|
// Comments at the end of custom properties are preserved, while full-line ones will be lost.
|
|
64
64
|
mergeCustomProps: false,
|
|
65
65
|
|
|
66
|
+
// Wraps the generated custom properties inside a CSS `@layer` at-rule,
|
|
67
|
+
// e.g. addLayer: 'project' -> `@layer project { :root { ... } }`.
|
|
68
|
+
// Set to null, undefined or false (default) to emit no layer.
|
|
69
|
+
addLayer: false,
|
|
70
|
+
|
|
66
71
|
// Named groups of custom properties. Properties whose first hyphen-separated
|
|
67
72
|
// name segment matches one of a group's `prefixes` are pulled out, labelled
|
|
68
73
|
// with the group's `name` and placed at the beginning of the output CSS
|
|
@@ -87,6 +87,11 @@ export const pxToRem = buildConfig.pxToRem !== false;
|
|
|
87
87
|
// build-tokens-src/merge-css.mjs). Default: false.
|
|
88
88
|
export const mergeCustomProps = buildConfig.mergeCustomProps === true;
|
|
89
89
|
|
|
90
|
+
// addLayer: wraps the generated custom properties inside a CSS `@layer`
|
|
91
|
+
// at-rule (see formats/css.mjs), e.g. `@layer project { :root { ... } }`.
|
|
92
|
+
// Set to null, undefined or false (default) to emit no layer.
|
|
93
|
+
export const addLayer = buildConfig.addLayer ? String(buildConfig.addLayer).trim() : null;
|
|
94
|
+
|
|
90
95
|
// customPropsGroups: custom properties whose first hyphen-separated name
|
|
91
96
|
// segment matches one of a group's prefixes are pulled out, labelled with
|
|
92
97
|
// that group's name and moved to the beginning of the generated CSS file, in
|
|
@@ -324,6 +324,12 @@ StyleDictionary.registerFormat({
|
|
|
324
324
|
appendBlock(restProps);
|
|
325
325
|
|
|
326
326
|
customPropsCount = sortedProps.length;
|
|
327
|
-
|
|
327
|
+
const block = `${selector} {\n${outLines.join('\n')}\n}\n`;
|
|
328
|
+
|
|
329
|
+
// addLayer: wraps the whole block inside `@layer <name> { ... }`.
|
|
330
|
+
// Indentation is left to stylelint's fix step (run right after the build).
|
|
331
|
+
return options.addLayer
|
|
332
|
+
? `@layer ${options.addLayer} {\n\n${block}}\n`
|
|
333
|
+
: block;
|
|
328
334
|
},
|
|
329
335
|
});
|
|
@@ -47,6 +47,7 @@ const JSON_TRANSFORMS = [
|
|
|
47
47
|
* @param {'keep'|'calc'|'resolve'} opts.jsonExpression How to handle math expressions in dimension tokens.
|
|
48
48
|
* @param {{name: string, prefixes: string[]}[]} opts.customPropsGroups Named groups of name prefixes, moved to the top of the CSS output in list order.
|
|
49
49
|
* @param {boolean} opts.pxToRem If false, skips the px→rem transform on the CSS platform. Default: true.
|
|
50
|
+
* @param {string|null} opts.addLayer Wraps the generated custom properties inside `@layer <addLayer> { ... }`. null = no layer.
|
|
50
51
|
* @returns {Record<string, PlatformConfig>} platforms object ready for Style Dictionary config
|
|
51
52
|
*/
|
|
52
53
|
export const buildPlatforms = ({
|
|
@@ -59,6 +60,7 @@ export const buildPlatforms = ({
|
|
|
59
60
|
concreteFilePaths = [],
|
|
60
61
|
customPropsGroups = [],
|
|
61
62
|
pxToRem = true,
|
|
63
|
+
addLayer = null,
|
|
62
64
|
}) => {
|
|
63
65
|
const cssTransforms = pxToRem
|
|
64
66
|
? CSS_TRANSFORMS
|
|
@@ -77,6 +79,7 @@ export const buildPlatforms = ({
|
|
|
77
79
|
outputReferences: true,
|
|
78
80
|
showFileHeader: true,
|
|
79
81
|
customPropsGroups,
|
|
82
|
+
addLayer,
|
|
80
83
|
},
|
|
81
84
|
},
|
|
82
85
|
],
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
mergeCustomProps,
|
|
35
35
|
customPropsGroups,
|
|
36
36
|
pxToRem,
|
|
37
|
+
addLayer,
|
|
37
38
|
} from './build-tokens-src/config.mjs';
|
|
38
39
|
|
|
39
40
|
// ── 2. Custom transforms ─────────────────────────────────────────────────────
|
|
@@ -107,6 +108,7 @@ const sd = new StyleDictionary({
|
|
|
107
108
|
concreteFilePaths,
|
|
108
109
|
customPropsGroups,
|
|
109
110
|
pxToRem,
|
|
111
|
+
addLayer,
|
|
110
112
|
}),
|
|
111
113
|
});
|
|
112
114
|
|
package/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export { ValidationError } from './src/utilities/validation-error-class.js';
|
|
|
20
20
|
|
|
21
21
|
// domBuilder helpers
|
|
22
22
|
export { buildPictureTag } from './src/utilities/dom-builder-helpers/picture-tag.js';
|
|
23
|
-
export { buildInput, buildCheckbox, buildTextarea, buildFakeField } from './src/utilities/dom-builder-helpers/form-tags.js';
|
|
23
|
+
export { buildInput, buildCheckbox, buildTextarea, buildFakeField, buildSelect } from './src/utilities/dom-builder-helpers/form-tags.js';
|
|
24
24
|
|
|
25
25
|
// components
|
|
26
26
|
export { dismissAlerts } from './src/components/dismiss-alerts.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@massimo-cassandro/minimo",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.2",
|
|
4
4
|
"description": "Light css framework & utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -90,9 +90,9 @@
|
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@massimo-cassandro/eslint-config": "^3.0.13",
|
|
92
92
|
"@massimo-cassandro/stylelint-config": "^2.3.13",
|
|
93
|
-
"@types/node": "^26.
|
|
93
|
+
"@types/node": "^26.2.0",
|
|
94
94
|
"jsdom": "^29.1.1",
|
|
95
|
-
"style-dictionary": "^5.5.
|
|
95
|
+
"style-dictionary": "^5.5.1"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@inquirer/input": "^5.1.2",
|
package/src/minimo.css
CHANGED
|
@@ -92,6 +92,78 @@ export function buildInput({
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* select tag builder
|
|
97
|
+
*
|
|
98
|
+
* @param {Object} args
|
|
99
|
+
* @param {string} args.label - select label.
|
|
100
|
+
* @param {string | null} args.name - select `name` attribute.
|
|
101
|
+
* @param {string | number | null} args.selectedValue - selected value
|
|
102
|
+
* @param {Array<[string|number, string]> | Record<string, string> | null} args.options - options value/text pairs, as an array of two-element `[value, text]` arrays or as a `{value: text, ...}` object
|
|
103
|
+
* @param {boolean} [args.addEmptyOption=true] - When true, and empty option tag is added at top
|
|
104
|
+
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper.
|
|
105
|
+
* @param {string | null} [args.className=null] - optional class to be added to the `input`.
|
|
106
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
107
|
+
* @param {string | HTMLElement | null} args.help - Optional help text.
|
|
108
|
+
* @param {(function(HTMLElement): void) | null} args.callback - Optional callback function.
|
|
109
|
+
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object.
|
|
110
|
+
* @returns {DomBuilderItem|null} The `input` domBuilder item, or `null` when `condition` is false.
|
|
111
|
+
*/
|
|
112
|
+
export function buildSelect({
|
|
113
|
+
label,
|
|
114
|
+
name,
|
|
115
|
+
selectedValue = null,
|
|
116
|
+
options = null,
|
|
117
|
+
addEmptyOption = true,
|
|
118
|
+
wrapperClass = null,
|
|
119
|
+
className = null,
|
|
120
|
+
condition = true,
|
|
121
|
+
help = null,
|
|
122
|
+
attrs = {},
|
|
123
|
+
callback = null
|
|
124
|
+
}){
|
|
125
|
+
|
|
126
|
+
const id = randomId();
|
|
127
|
+
|
|
128
|
+
// normalizing option as an array
|
|
129
|
+
if(options && !Array.isArray(options)) {
|
|
130
|
+
options = Object.entries(options);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return buildFormGroup({
|
|
134
|
+
condition,
|
|
135
|
+
wrapperClass,
|
|
136
|
+
help,
|
|
137
|
+
children: [
|
|
138
|
+
`label.form-label[for:${id}] ${label}`,
|
|
139
|
+
{
|
|
140
|
+
tag: 'select',
|
|
141
|
+
className: classnames('form-control', className, attrs?.class),
|
|
142
|
+
id: id,
|
|
143
|
+
attrs: {
|
|
144
|
+
...(attrs??{}),
|
|
145
|
+
name: name,
|
|
146
|
+
},
|
|
147
|
+
children: [
|
|
148
|
+
...(addEmptyOption? ['option[value=""]'] : []),
|
|
149
|
+
...(options
|
|
150
|
+
? options.map(([value, text]) => ({
|
|
151
|
+
tag: 'option',
|
|
152
|
+
attrs: {
|
|
153
|
+
value: value,
|
|
154
|
+
selected: value === selectedValue
|
|
155
|
+
},
|
|
156
|
+
content: text
|
|
157
|
+
}))
|
|
158
|
+
: []
|
|
159
|
+
)
|
|
160
|
+
],
|
|
161
|
+
callback: callback
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
95
167
|
|
|
96
168
|
/**
|
|
97
169
|
* Checkbox tag builder
|