@massimo-cassandro/minimo 1.19.8 → 1.19.10
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 +29 -21
- package/design-tokens/utilities/build-tokens-src/config.mjs +7 -0
- package/design-tokens/utilities/build-tokens-src/formats/css.mjs +41 -6
- package/design-tokens/utilities/build-tokens-src/platforms.mjs +3 -0
- package/design-tokens/utilities/build-tokens.mjs +2 -0
- package/dev-tools/starter-kit/webpack-template.ejs +1 -0
- package/dev-tools/starter-kit/webpack.config.mjs +1 -0
- package/index.js +2 -1
- package/package.json +1 -1
- package/src/css/forms/forms.css +2 -0
- package/src/css/text.css +0 -36
- package/src/custom-properties.css +12 -9
- package/src/minimo.css +1 -1
- package/src/utilities/dom-builder-helpers/README.md +2 -0
- package/src/utilities/dom-builder-helpers/form-tags.js +134 -0
- package/src/utilities/{build-picture-tag.js → dom-builder-helpers/picture-tag.js} +1 -3
|
@@ -18,7 +18,7 @@ const minimo_path = '../../node_modules/@massimo-cassandro/minimo';
|
|
|
18
18
|
const config = {
|
|
19
19
|
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
|
-
//
|
|
21
|
+
// BUILD-TOKENS & STYLE-DICTIONARY SETTINGS
|
|
22
22
|
// ---------------------------------------------------------------------------
|
|
23
23
|
|
|
24
24
|
// Path to the stylelint config used to lint the generated CSS file
|
|
@@ -30,7 +30,7 @@ const config = {
|
|
|
30
30
|
// Output filename for the generated CSS file
|
|
31
31
|
destFile: 'custom-properties.css',
|
|
32
32
|
|
|
33
|
-
// Source token files —
|
|
33
|
+
// Source token files — accept paths, globs, or a mix of both.
|
|
34
34
|
// Supported formats: .json, .jsonc, .mjs (must export a DTCG-compliant default object)
|
|
35
35
|
//
|
|
36
36
|
// WARNING: do not use path.join() to build glob patterns — it may corrupt
|
|
@@ -49,11 +49,35 @@ const config = {
|
|
|
49
49
|
|
|
50
50
|
],
|
|
51
51
|
|
|
52
|
+
// If true, custom properties already present in the CSS destination file
|
|
53
|
+
// (destFile, from a previous build) take priority over the ones generated
|
|
54
|
+
// by this build. Properties found only in the pre-existing file (no longer
|
|
55
|
+
// generated) are kept too. Useful to preserve manual overrides/additions
|
|
56
|
+
// made directly in the compiled CSS across rebuilds. Ignored on the first
|
|
57
|
+
// build, when destFile does not exist yet. Default: false.
|
|
58
|
+
// Comments at the end of custom properties are preserved, while full-line ones will be lost.
|
|
59
|
+
mergeCustomProps: false,
|
|
60
|
+
|
|
61
|
+
// Properties whose names begin with one of the following strings are grouped
|
|
62
|
+
// and placed at the beginning of the output CSS file
|
|
63
|
+
colorPropertiesPrefixes: ['accent', 'primary', 'secondary', 'neutral'],
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
// PENPOT / FIGMA
|
|
52
68
|
// ---------------------------------------------------------------------------
|
|
53
69
|
// Optional design tokens output
|
|
54
70
|
// Generates one or more json(c) files in addition to the CSS output file, for use
|
|
55
71
|
// in Penpot or Figma projects or as an alternative to the .mjs source files
|
|
56
72
|
// ---------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
// How to handle math expressions in dimension token $values (e.g. "{size.base} * .25"):
|
|
75
|
+
// 'keep' write the expression unchanged
|
|
76
|
+
// 'calc' — wrap in CSS calc(): "calc({size.base} * .25)"
|
|
77
|
+
// 'resolve' — (default) evaluate numerically, inheriting the unit from the first referenced token
|
|
78
|
+
// e.g. {size.base} = 16px, "{size.base} * .25" -> "4px"
|
|
79
|
+
penpotExpressions: 'resolve',
|
|
80
|
+
|
|
57
81
|
// Output format for Penpot token files: 'jsonc' or 'json'
|
|
58
82
|
// 'jsonc' -> adds a generated-file disclaimer header, uses .jsonc extension
|
|
59
83
|
// 'json' -> plain JSON, no disclaimer
|
|
@@ -61,32 +85,16 @@ const config = {
|
|
|
61
85
|
|
|
62
86
|
// Output directory for the Penpot design token files.
|
|
63
87
|
// Set to null (or omit) to disable json output entirely.
|
|
64
|
-
penpotBuildPath: null
|
|
88
|
+
penpotBuildPath: null, // or './path/to/generated/design-tokens-dir',
|
|
65
89
|
|
|
66
90
|
// Base name (without extension) for the aggregated Penpot output file.
|
|
67
91
|
// The extension is added automatically based on penpotFormat.
|
|
68
92
|
// Set to null (or omit) to generate one file per .mjs source file instead.
|
|
69
|
-
penpotDestFile: null
|
|
70
|
-
|
|
71
|
-
// How to handle math expressions in dimension token $values (e.g. "{size.base} * .25"):
|
|
72
|
-
// 'keep' write the expression unchanged
|
|
73
|
-
// 'calc' — wrap in CSS calc(): "calc({size.base} * .25)"
|
|
74
|
-
// 'resolve' — (default) evaluate numerically, inheriting the unit from the first referenced token
|
|
75
|
-
// e.g. {size.base} = 16px, "{size.base} * .25" -> "4px"
|
|
76
|
-
penpotExpressions: 'resolve',
|
|
77
|
-
|
|
78
|
-
// If true, custom properties already present in the CSS destination file
|
|
79
|
-
// (destFile, from a previous build) take priority over the ones generated
|
|
80
|
-
// by this build. Properties found only in the pre-existing file (no longer
|
|
81
|
-
// generated) are kept too. Useful to preserve manual overrides/additions
|
|
82
|
-
// made directly in the compiled CSS across rebuilds. Ignored on the first
|
|
83
|
-
// build, when destFile does not exist yet. Default: false.
|
|
84
|
-
mergeCustomProps: false,
|
|
85
|
-
|
|
93
|
+
penpotDestFile: null, // or 'tokens' (or else),
|
|
86
94
|
|
|
87
95
|
|
|
88
96
|
// ---------------------------------------------------------------------------
|
|
89
|
-
//
|
|
97
|
+
// CHECK-UNRESOLVED-CUSTOM-PROPS SETTINGS
|
|
90
98
|
// ---------------------------------------------------------------------------
|
|
91
99
|
|
|
92
100
|
// If true, also reports custom properties that are defined (in destFile or
|
|
@@ -81,6 +81,13 @@ export const penpotExpressions = VALID_EXPR_MODES.includes(buildConfig.penpotExp
|
|
|
81
81
|
// build-tokens-src/merge-css.mjs). Default: false.
|
|
82
82
|
export const mergeCustomProps = buildConfig.mergeCustomProps === true;
|
|
83
83
|
|
|
84
|
+
// colorPropertiesPrefixes: custom properties whose first hyphen-separated
|
|
85
|
+
// name segment matches one of these prefixes are grouped together and moved
|
|
86
|
+
// to the beginning of the generated CSS file (see formats/css.mjs). Default: [].
|
|
87
|
+
export const colorPropertiesPrefixes = Array.isArray(buildConfig.colorPropertiesPrefixes)
|
|
88
|
+
? buildConfig.colorPropertiesPrefixes
|
|
89
|
+
: [];
|
|
90
|
+
|
|
84
91
|
// ---------------------------------------------------------------------------
|
|
85
92
|
// Source: resolve patterns relative to the config directory and normalise to
|
|
86
93
|
// forward-slash absolute paths (fast-glob, used internally by Style Dictionary,
|
|
@@ -239,19 +239,54 @@ StyleDictionary.registerFormat({
|
|
|
239
239
|
const sortedProps = Object.entries(finalProps)
|
|
240
240
|
.sort(([a], [b]) => a.localeCompare(b, 'en', { numeric: true, sensitivity: 'base' }));
|
|
241
241
|
|
|
242
|
+
// colorPropertiesPrefixes: properties whose first hyphen-separated name
|
|
243
|
+
// segment matches one of these prefixes are pulled out and placed, in
|
|
244
|
+
// prefix-list order, at the beginning of the output file.
|
|
245
|
+
const colorPropertiesPrefixes = options.colorPropertiesPrefixes ?? [];
|
|
246
|
+
const colorProps = [];
|
|
247
|
+
const restProps = [];
|
|
248
|
+
for (const entry of sortedProps) {
|
|
249
|
+
const prefix = entry[0].split('-')[0];
|
|
250
|
+
if (colorPropertiesPrefixes.includes(prefix)) {
|
|
251
|
+
colorProps.push(entry);
|
|
252
|
+
} else {
|
|
253
|
+
restProps.push(entry);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
colorProps.sort(([a], [b]) => {
|
|
257
|
+
const prefixA = a.split('-')[0];
|
|
258
|
+
const prefixB = b.split('-')[0];
|
|
259
|
+
const idxA = colorPropertiesPrefixes.indexOf(prefixA);
|
|
260
|
+
const idxB = colorPropertiesPrefixes.indexOf(prefixB);
|
|
261
|
+
if (idxA !== idxB) return idxA - idxB;
|
|
262
|
+
return a.localeCompare(b, 'en', { numeric: true, sensitivity: 'base' });
|
|
263
|
+
});
|
|
264
|
+
|
|
242
265
|
// A blank line is inserted between blocks of properties sharing the same
|
|
243
266
|
// first hyphen-separated segment (e.g. all `btn-*` together), to visually
|
|
244
267
|
// group related custom properties in the generated file.
|
|
245
268
|
const outLines = [];
|
|
246
269
|
let prevPrefix = null;
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
270
|
+
const appendBlock = (props) => {
|
|
271
|
+
for (const [name, tail] of props) {
|
|
272
|
+
const prefix = name.split('-')[0];
|
|
273
|
+
if (prevPrefix !== null && prefix !== prevPrefix) {
|
|
274
|
+
outLines.push('');
|
|
275
|
+
}
|
|
276
|
+
outLines.push(` --${name}: ${tail}`);
|
|
277
|
+
prevPrefix = prefix;
|
|
251
278
|
}
|
|
252
|
-
|
|
253
|
-
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
if (colorProps.length) {
|
|
282
|
+
outLines.push(' /** COLORS **/');
|
|
283
|
+
}
|
|
284
|
+
appendBlock(colorProps);
|
|
285
|
+
if (colorProps.length && restProps.length) {
|
|
286
|
+
outLines.push('', ' /* ---------------------- */', '');
|
|
287
|
+
prevPrefix = null;
|
|
254
288
|
}
|
|
289
|
+
appendBlock(restProps);
|
|
255
290
|
|
|
256
291
|
customPropsCount = sortedProps.length;
|
|
257
292
|
return `${selector} {\n${outLines.join('\n')}\n}\n`;
|
|
@@ -44,6 +44,7 @@ const PENPOT_TRANSFORMS = [
|
|
|
44
44
|
* Collected from sd.allTokens after SD initialisation.
|
|
45
45
|
* Ignored when penpotDestFile is set.
|
|
46
46
|
* @param {'keep'|'calc'|'resolve'} opts.penpotExpressions How to handle math expressions in dimension tokens.
|
|
47
|
+
* @param {string[]} opts.colorPropertiesPrefixes Name prefixes grouped at the top of the CSS output.
|
|
47
48
|
* @returns {Record<string, PlatformConfig>} platforms object ready for Style Dictionary config
|
|
48
49
|
*/
|
|
49
50
|
export const buildPlatforms = ({
|
|
@@ -54,6 +55,7 @@ export const buildPlatforms = ({
|
|
|
54
55
|
penpotFormat,
|
|
55
56
|
penpotExpressions = 'keep',
|
|
56
57
|
concreteFilePaths = [],
|
|
58
|
+
colorPropertiesPrefixes = [],
|
|
57
59
|
}) => {
|
|
58
60
|
/** @type {Record<string, PlatformConfig>} */
|
|
59
61
|
const platforms = {
|
|
@@ -67,6 +69,7 @@ export const buildPlatforms = ({
|
|
|
67
69
|
options: {
|
|
68
70
|
outputReferences: true,
|
|
69
71
|
showFileHeader: true,
|
|
72
|
+
colorPropertiesPrefixes,
|
|
70
73
|
},
|
|
71
74
|
},
|
|
72
75
|
],
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
penpotExpressions,
|
|
33
33
|
source,
|
|
34
34
|
mergeCustomProps,
|
|
35
|
+
colorPropertiesPrefixes,
|
|
35
36
|
} from './build-tokens-src/config.mjs';
|
|
36
37
|
|
|
37
38
|
// ── 2. Custom transforms ─────────────────────────────────────────────────────
|
|
@@ -95,6 +96,7 @@ const sd = new StyleDictionary({
|
|
|
95
96
|
penpotFormat,
|
|
96
97
|
penpotExpressions,
|
|
97
98
|
concreteFilePaths,
|
|
99
|
+
colorPropertiesPrefixes,
|
|
98
100
|
}),
|
|
99
101
|
});
|
|
100
102
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<!-- <%= require('./frontend/favicons/output/favicons.incl.ejs')({}) %> -->
|
|
12
12
|
|
|
13
13
|
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
14
|
+
<!-- <base href="<%= htmlWebpackPlugin.options.base %>"> -->
|
|
14
15
|
<%= htmlWebpackPlugin.tags.headTags %> <!-- opzionale, param `inject: false` -->
|
|
15
16
|
</head>
|
|
16
17
|
<body>
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// utilities
|
|
2
2
|
export { betterText } from './src/utilities/better-text.js';
|
|
3
|
-
export { buildPictureTag } from './src/utilities/
|
|
3
|
+
export { buildPictureTag } from './src/utilities/dom-builder-helpers/picture-tag.js';
|
|
4
|
+
export { buildInputTag, buildCheckboxTag, buildTextareaTag } from './src/utilities/dom-builder-helpers/form-tags.js';
|
|
4
5
|
export { classnames, classnamesNull } from './src/utilities/classnames.js';
|
|
5
6
|
export { createId } from './src/utilities/create-id.js';
|
|
6
7
|
export { disableBtnsOnSubmit } from './src/utilities/disable-btns-on-submit.js';
|
package/package.json
CHANGED
package/src/css/forms/forms.css
CHANGED
|
@@ -120,6 +120,8 @@ input[type='checkbox'] {
|
|
|
120
120
|
/* da bs5 */
|
|
121
121
|
/* versione con label a destra */
|
|
122
122
|
/* TODO rivedere. sostituire float con flex? */
|
|
123
|
+
/* TODO eliminare necessità di stare dentro un `.form-group` */
|
|
124
|
+
/* TODO aggiungere esempi di uso */
|
|
123
125
|
.form-check {
|
|
124
126
|
display: block;
|
|
125
127
|
padding-left: 1.5em;
|
package/src/css/text.css
CHANGED
|
@@ -3,42 +3,6 @@ p {
|
|
|
3
3
|
margin: 0 0 var(--size-sm);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
a:link, .btn-link {
|
|
7
|
-
/* TODO rivedere, forse più complicato del necessario */
|
|
8
|
-
&:not(.btn) {
|
|
9
|
-
font-weight: var(--font-weight-semibold);
|
|
10
|
-
color: var(--link-color);
|
|
11
|
-
text-decoration: none;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
a {
|
|
16
|
-
&:visited {
|
|
17
|
-
color: var(--link-visited-color);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
a, .btn-link {
|
|
22
|
-
&:focus {
|
|
23
|
-
outline: none;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&:focus-visible {
|
|
27
|
-
outline: 1px solid color-mix(in srgb, var(--link-color) 60%, transparent);
|
|
28
|
-
outline-offset: 2px;
|
|
29
|
-
}
|
|
30
|
-
&:hover {
|
|
31
|
-
text-decoration: underline;
|
|
32
|
-
text-underline-offset: 2px;
|
|
33
|
-
}
|
|
34
|
-
&:active {
|
|
35
|
-
color: var(--body-background-color);
|
|
36
|
-
outline: 2px solid var(--link-color);
|
|
37
|
-
background-color: var(--link-color);
|
|
38
|
-
offset: 0;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
6
|
strong, b {
|
|
43
7
|
font-weight: 700;
|
|
44
8
|
}
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
:root {
|
|
2
|
+
/** COLORS **/
|
|
2
3
|
--accent: #567d0d;
|
|
3
4
|
--accent-fg: #fff;
|
|
4
5
|
|
|
6
|
+
--primary-100: #083865;
|
|
7
|
+
--primary-100-fg: #fff;
|
|
8
|
+
|
|
9
|
+
--secondary-100: #650853;
|
|
10
|
+
--secondary-100-fg: #fff;
|
|
11
|
+
|
|
12
|
+
--neutral-100: #666;
|
|
13
|
+
--neutral-100-fg: #fff;
|
|
14
|
+
|
|
15
|
+
/* ---------------------- */
|
|
16
|
+
|
|
5
17
|
--alert-border-radius: var(--radius-sm);
|
|
6
18
|
--alert-box-shadow: 0 0 .5rem 0 oklch(0% 0 0 / .5);
|
|
7
19
|
|
|
@@ -252,14 +264,8 @@
|
|
|
252
264
|
--mpopup-min-width: 25rem;
|
|
253
265
|
--mpopup-width: max-content;
|
|
254
266
|
|
|
255
|
-
--neutral-100: #666;
|
|
256
|
-
--neutral-100-fg: #fff;
|
|
257
|
-
|
|
258
267
|
--overlay-color: rgb(0 0 0 / .6);
|
|
259
268
|
|
|
260
|
-
--primary-100: #083865;
|
|
261
|
-
--primary-100-fg: #fff;
|
|
262
|
-
|
|
263
269
|
--radius-base: var(--size-base);
|
|
264
270
|
--radius-lg: var(--size-lg);
|
|
265
271
|
--radius-md: var(--size-md);
|
|
@@ -276,9 +282,6 @@
|
|
|
276
282
|
--sdt-pagination-padding-inline: var(--size-xs);
|
|
277
283
|
--sdt-thead-hover-background-color: color-mix(in srgb, var(--table-thead-background-color) 90%, var(--accent));
|
|
278
284
|
|
|
279
|
-
--secondary-100: #650853;
|
|
280
|
-
--secondary-100-fg: #fff;
|
|
281
|
-
|
|
282
285
|
--sf-macro-btn-close-background-color: var(--btn-close-background-color);
|
|
283
286
|
--sf-macro-btn-close-position-bottom: auto;
|
|
284
287
|
--sf-macro-btn-close-position-left: auto;
|
package/src/minimo.css
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
@import '@minimo/css/dimensions.css';
|
|
38
38
|
@import '@minimo/css/display.css';
|
|
39
39
|
@import '@minimo/css/margin-padding.css';
|
|
40
|
-
/* @import '@minimo/css/margin-padding-media.css'; responsive
|
|
40
|
+
/* @import '@minimo/css/margin-padding-media.css'; responsive version */
|
|
41
41
|
/* alternative boostrap naming
|
|
42
42
|
@import '@minimo/css/margin-padding-bootstrap.css';
|
|
43
43
|
@import '@minimo/css/margin-padding-bootsrap-media.css';
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { classnames } from '../classnames.js';
|
|
2
|
+
import { randomId } from '../random-id.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Input tag builder
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} args
|
|
8
|
+
* @param {string} args.label - input label.
|
|
9
|
+
* @param {string | null} args.name - input `name` attribute.
|
|
10
|
+
* @param {string | number | null} args.defaultValue - input `value` attribute.
|
|
11
|
+
* @param {string | null} [args.type='text'] - input `type` attribute.
|
|
12
|
+
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper.
|
|
13
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
14
|
+
* @returns {DomBuilderItem|null} The `input` domBuilder item, or `null` when `condition` is false.
|
|
15
|
+
*/
|
|
16
|
+
export function buildInputTag({
|
|
17
|
+
label,
|
|
18
|
+
name,
|
|
19
|
+
defaultValue,
|
|
20
|
+
type = 'text',
|
|
21
|
+
wrapperClass = null,
|
|
22
|
+
condition = true
|
|
23
|
+
}){
|
|
24
|
+
|
|
25
|
+
if(!condition) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const id = randomId();
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
className: classnames('form-group', wrapperClass),
|
|
33
|
+
children: [
|
|
34
|
+
`label.form-label[for:${id}] ${label}`,
|
|
35
|
+
`input#${id}.form-control[type: ${type}, name: ${name}, value: ${defaultValue}]`
|
|
36
|
+
]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Checkbox tag builder
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} args
|
|
45
|
+
* @param {string} args.label - checkbox label.
|
|
46
|
+
* @param {string | null} args.name - checkbox `name` attribute.
|
|
47
|
+
* @param {string | number | null} args.value - checkbox `value` attribute.
|
|
48
|
+
* @param {boolean} [args.checked=false] - checkbox `checked` attribute.
|
|
49
|
+
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper (used only when `addFormGroup` is true).
|
|
50
|
+
* @param {boolean} [args.addFormGroup=true] - When true, wraps the checkbox in a `.form-group` element.
|
|
51
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
52
|
+
* @returns {DomBuilderItem|null} The `.form-check` (or `.form-group`-wrapped) domBuilder item, or `null` when `condition` is false.
|
|
53
|
+
*/
|
|
54
|
+
export function buildCheckboxTag({
|
|
55
|
+
label,
|
|
56
|
+
name,
|
|
57
|
+
value,
|
|
58
|
+
checked = false,
|
|
59
|
+
wrapperClass = null,
|
|
60
|
+
addFormGroup = true,
|
|
61
|
+
condition = true
|
|
62
|
+
}) {
|
|
63
|
+
|
|
64
|
+
if(!condition) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const id = randomId();
|
|
69
|
+
|
|
70
|
+
const tag = {
|
|
71
|
+
className: classnames('form-check', !addFormGroup && wrapperClass),
|
|
72
|
+
children: [
|
|
73
|
+
`label.form-label[for:${id}] ${label}`,
|
|
74
|
+
{
|
|
75
|
+
tag: 'input',
|
|
76
|
+
className: 'form-control',
|
|
77
|
+
id: id,
|
|
78
|
+
attrs: {
|
|
79
|
+
type: 'checkbox',
|
|
80
|
+
value: value,
|
|
81
|
+
name: name,
|
|
82
|
+
checked: checked
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
if(addFormGroup) {
|
|
89
|
+
return {
|
|
90
|
+
className: classnames('form-group', wrapperClass),
|
|
91
|
+
children: [ tag ]
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
} else {
|
|
95
|
+
return tag;
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Textarea tag builder
|
|
104
|
+
*
|
|
105
|
+
* @param {Object} args
|
|
106
|
+
* @param {string} args.label - textarea label.
|
|
107
|
+
* @param {string | null} args.name - textarea `name` attribute.
|
|
108
|
+
* @param {string | number | null} args.defaultValue - textarea content.
|
|
109
|
+
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper.
|
|
110
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
111
|
+
* @returns {DomBuilderItem|null} The `textarea` domBuilder item, or `null` when `condition` is false.
|
|
112
|
+
*/
|
|
113
|
+
export function buildTextareaTag({
|
|
114
|
+
label,
|
|
115
|
+
name,
|
|
116
|
+
defaultValue,
|
|
117
|
+
wrapperClass = null,
|
|
118
|
+
condition = true
|
|
119
|
+
}) {
|
|
120
|
+
|
|
121
|
+
if(!condition) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const id = randomId();
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
className: classnames('form-group', wrapperClass),
|
|
129
|
+
children: [
|
|
130
|
+
`label.form-label[for:${id}] ${label}`,
|
|
131
|
+
`textarea#${id}.form-control[name: ${name}] ${defaultValue}`
|
|
132
|
+
]
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/*! minimo - buildPictureTag */
|
|
2
|
-
import { classnames } from '
|
|
3
|
-
|
|
4
|
-
/** @typedef {import('./dom-builder/dom-builder.js').DomBuilderItem} DomBuilderItem */
|
|
2
|
+
import { classnames } from '../classnames.js';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* @typedef {Object} PictureSizeEntry
|