@massimo-cassandro/minimo 1.20.1 → 1.20.3

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.
@@ -128,6 +128,86 @@
128
128
  "fg": {
129
129
  "$type": "color",
130
130
  "$value": "#fff"
131
+ },
132
+ "btn": {
133
+ "bg": {
134
+ "$type": "color",
135
+ "$value": "{malert.confirm.bg}"
136
+ },
137
+ "fg": {
138
+ "$type": "color",
139
+ "$value": "{malert.confirm.fg}"
140
+ },
141
+ "border": {
142
+ "color": {
143
+ "$type": "color",
144
+ "$value": "{malert.confirm.bg}"
145
+ }
146
+ },
147
+ "focus": {
148
+ "outline": {
149
+ "color": {
150
+ "$type": "color",
151
+ "$value": "color-mix(in srgb, {malert.confirm.bg} 60%, transparent)"
152
+ },
153
+ "width": {
154
+ "$type": "dimension",
155
+ "$value": "{btn.focus.outline.width}"
156
+ }
157
+ }
158
+ },
159
+ "hover": {
160
+ "bg": {
161
+ "$type": "color",
162
+ "$value": "{malert.confirm.fg}"
163
+ },
164
+ "fg": {
165
+ "$type": "color",
166
+ "$value": "{malert.confirm.bg}"
167
+ },
168
+ "border": {
169
+ "color": {
170
+ "$type": "color",
171
+ "$value": "{malert.confirm.btn.hover.fg}"
172
+ }
173
+ }
174
+ },
175
+ "active": {
176
+ "bg": {
177
+ "$type": "color",
178
+ "$value": "color-mix(in srgb, {malert.confirm.bg} 60%, #000)"
179
+ },
180
+ "fg": {
181
+ "$type": "color",
182
+ "$value": "{malert.confirm.fg}"
183
+ },
184
+ "border": {
185
+ "color": {
186
+ "$type": "color",
187
+ "$value": "{malert.confirm.btn.active.bg}"
188
+ }
189
+ }
190
+ },
191
+ "hollow": {
192
+ "bg": {
193
+ "$type": "color",
194
+ "$value": "{malert.confirm.fg}"
195
+ },
196
+ "fg": {
197
+ "$type": "color",
198
+ "$value": "{malert.confirm.bg}"
199
+ },
200
+ "hover": {
201
+ "bg": {
202
+ "$type": "color",
203
+ "$value": "{malert.confirm.bg}"
204
+ },
205
+ "fg": {
206
+ "$type": "color",
207
+ "$value": "{malert.confirm.fg}"
208
+ }
209
+ }
210
+ }
131
211
  }
132
212
  },
133
213
  "heading": {
@@ -63,14 +63,19 @@ async function run() {
63
63
  /** @type {RegExp[]} */
64
64
  const exclude = config.excludePattern ?? [];
65
65
 
66
- // Collect all .css files in the scan directory, excluding the token file itself
67
- // and any file under a directory whose name starts with "TODO" (work-in-progress folders)
66
+ // Collect all .css files in the scan directory, excluding any file under a
67
+ // directory whose name starts with "TODO" (work-in-progress folders).
68
+ // The token file itself (custom_prop_filename) is intentionally included:
69
+ // custom properties are often composed from other custom properties
70
+ // (e.g. `--malert-box-shadow: ... var(--malert-box-shadow-color) ...`)
71
+ // and those internal var() references must count as usage, otherwise the
72
+ // referenced property is wrongly reported as unused.
68
73
  const files = [];
69
74
  for await (const entry of glob(path.join(checkdir, '/**/*.css'))) {
70
75
  const relDirSegments = path.relative(checkdir, path.dirname(entry)).split(path.sep);
71
76
  const isInTodoDir = relDirSegments.some(segment => /^todo/i.test(segment));
72
77
 
73
- if (!entry.endsWith(custom_prop_filename) && !isInTodoDir) {
78
+ if (!isInTodoDir) {
74
79
  files.push(entry);
75
80
  }
76
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "1.20.1",
3
+ "version": "1.20.3",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -87,8 +87,8 @@ const defaults = {
87
87
  okBtnText: 'OK',
88
88
  cancelBtnText: 'Annulla',
89
89
  cancelBtnFocus: true, // false to give focus to the ok button
90
- okBtnClass: 'btn btn-primary',
91
- cancelBtnClass: 'btn btn-primary btn-hollow',
90
+ okBtnClass: classnames('btn', styles.btnConfirm),
91
+ cancelBtnClass: classnames('btn', styles.btnConfirm, styles.btnHollow),
92
92
  icon: confirmIcon,
93
93
  altIcon: warningIcon,
94
94
  useAltIcon: false // when true, uses altIcon (warning) instead of the default confirm icon
@@ -130,7 +130,32 @@ const defaults = {
130
130
  * `ok_btn_class`, `cancel_btn_text`, `cancel_btn_class`, `cancel_focus`, `use_warning_icon`)
131
131
  * are still accepted and internally mapped to their camelCase equivalent, see `legacyParamNames`.
132
132
  *
133
- * @param {ModalAlertParams} params - Dialog parameters (merged with defaults by type).
133
+ * The base param type below is intentionally `object` (not `ModalAlertParams`): TypeScript only
134
+ * expands dotted `@param` properties (needed for editor IntelliSense to list each property) when
135
+ * the base type is the literal `object`; a named typedef there would error (TS8032).
136
+ * @param {object} [params] - Dialog parameters (merged with defaults by type).
137
+ * @param {string} [params.type] - Dialog type: `success`, `error`, `warning`, `info`, or `confirm`.
138
+ * @param {string | null} [params.extraClass] - optional dialog extra class
139
+ * @param {(() => void) | null} [params.onOpen] - optional callback on dialog open
140
+ * @param {(() => void) | null} [params.onClose] - optional callback on dialog close
141
+ * @param {boolean} [params.animation] - if true, dialog will be animated
142
+ * @param {boolean} [params.showMarks] - if true, mark icons will be showed
143
+ * @param {((arg?: *) => void) | null} [params.callback] - optional callback dialog after user choice
144
+ * @param {number | null} [params.timer] - timer for autoclose (ms). `null` for disable
145
+ * @param {string | null} [params.title] - title text
146
+ * @param {string | null} [params.mes] - text message (plain or html)
147
+ * @param {string | null} [params.headingClass] - optional extra class for heading
148
+ * @param {string | null} [params.textClass] - optional extra class for text
149
+ * @param {string | null} [params.icon] - Icon markup used for the dialog; defaults to the type's icon.
150
+ * @param {string | null} [params.altIcon] - Alternate icon markup, used instead of `icon` when `useAltIcon` is `true`.
151
+ * @param {boolean} [params.useAltIcon] - When `true`, uses `altIcon` instead of `icon` (e.g. the `danger` icon on a `warning` dialog, or the `warning` icon on a `confirm` dialog).
152
+ * @param {DomBuilderItem | null} [params.extraBtn] - optional extra button (as domBuilder object)
153
+ * @param {boolean} [params.extraBtnFocus] - true if the extra button should be focused when the dialog box opens (overrides any focus assigned to the 'cancel' button)
154
+ * @param {string} [params.okBtnText] - text for 'ok' button
155
+ * @param {string} [params.okBtnClass] - alternative class for 'ok' button. It replaces the default one
156
+ * @param {string} [params.cancelBtnText] - text for 'cancel' button
157
+ * @param {string} [params.cancelBtnClass] - alternative class for 'cancel' button. It replaces the default one
158
+ * @param {boolean} [params.cancelBtnFocus] - true if the cancel button should be focused when the dialog box opens. It has no effect if an extraBtn is set
134
159
  * @returns {Promise<string | boolean | undefined>} Resolves when the dialog closes. If the
135
160
  * dismissing button has a `data-malert-result` attribute, that string is used; otherwise, for
136
161
  * `confirm` dialogs, resolves `true`/`false` for the OK/Cancel button; otherwise `undefined`.
@@ -116,6 +116,7 @@ export default {
116
116
  $value: '{status.danger.fg}'
117
117
  }
118
118
  },
119
+
119
120
  confirm: {
120
121
  bg: {
121
122
  $type: 'color',
@@ -124,7 +125,99 @@ export default {
124
125
  fg: {
125
126
  $type: 'color',
126
127
  $value: '#fff'
127
- }
128
+ },
129
+
130
+ // =>> settings for confirm button
131
+ btn: {
132
+ bg: {
133
+ $value: '{malert.confirm.bg}',
134
+ $type: 'color'
135
+ },
136
+ fg: {
137
+ $value: '{malert.confirm.fg}',
138
+ $type: 'color'
139
+ },
140
+
141
+ border: {
142
+ color: {
143
+ $value: '{malert.confirm.bg}',
144
+ $type: 'color'
145
+ }
146
+ },
147
+
148
+ focus: {
149
+ outline: {
150
+ color: {
151
+ $value: 'color-mix(in srgb, {malert.confirm.bg} 60%, transparent)',
152
+ $type: 'color'
153
+ },
154
+ width: {
155
+ $type: 'dimension',
156
+ $value: '{btn.focus.outline.width}'
157
+ }
158
+ }
159
+ },
160
+
161
+ hover: {
162
+ bg: {
163
+ $value: '{malert.confirm.fg}',
164
+ $type: 'color'
165
+ },
166
+ fg: {
167
+ $value: '{malert.confirm.bg}',
168
+ $type: 'color'
169
+ },
170
+
171
+ border: {
172
+ color: {
173
+ $value: '{malert.confirm.btn.hover.fg}',
174
+ $type: 'color'
175
+ }
176
+ }
177
+ },
178
+
179
+ active: {
180
+ bg: {
181
+ $value: 'color-mix(in srgb, {malert.confirm.bg} 60%, #000)',
182
+ $type: 'color'
183
+ },
184
+ fg: {
185
+ $value: '{malert.confirm.fg}',
186
+ $type: 'color'
187
+ },
188
+
189
+ border: {
190
+ color: {
191
+ $value: '{malert.confirm.btn.active.bg}',
192
+ $type: 'color'
193
+ }
194
+ },
195
+ },
196
+
197
+ hollow: {
198
+ bg: {
199
+ $value: '{malert.confirm.fg}',
200
+ $type: 'color'
201
+ },
202
+ fg: {
203
+ $value: '{malert.confirm.bg}',
204
+ $type: 'color'
205
+ },
206
+
207
+ hover: {
208
+ bg: {
209
+ $value: '{malert.confirm.bg}',
210
+ $type: 'color'
211
+ },
212
+ fg: {
213
+ $value: '{malert.confirm.fg}',
214
+ $type: 'color'
215
+ }
216
+
217
+ },
218
+ } // end hollow
219
+ } // end confirm button
220
+
128
221
  },
129
222
 
130
223
  heading: {
@@ -158,7 +251,7 @@ export default {
158
251
  $value: '{font.size.base}'
159
252
  },
160
253
  }
161
- }
254
+ },
162
255
  }
163
256
  };
164
257
 
@@ -146,3 +146,54 @@
146
146
  transform: translateY(0);
147
147
  }
148
148
  }
149
+
150
+
151
+ /* confirm button */
152
+
153
+
154
+ .btnConfirm {
155
+ --_button-bg-color: var(--malert-confirm-btn-bg);
156
+ --_button-fg-color: var(--malert-confirm-btn-fg);
157
+ --_button-border-color: var(--malert-confirm-btn-border-color);
158
+
159
+ @media (hover: hover) {
160
+ &:hover {
161
+ --_button-bg-color: var(--malert-confirm-btn-hover-bg);
162
+ --_button-fg-color: var(--malert-confirm-btn-hover-fg);
163
+ --_button-border-color: var(--malert-confirm-btn-hover-border-color);
164
+ }
165
+ }
166
+ &:focus {
167
+ outline: none;
168
+ }
169
+
170
+ &:focus-visible, &:active {
171
+ outline: var(--malert-confirm-btn-focus-outline-width) solid var(--malert-confirm-btn-focus-outline-color);
172
+ /* outline-offset: 4px; */
173
+ }
174
+
175
+ &:active {
176
+ --_button-bg-color: var(--malert-confirm-btn-active-bg);
177
+ --_button-fg-color: var(--malert-confirm-btn-active-fg);
178
+ --_button-border-color: var(--malert-confirm-btn-active-border-color);
179
+ }
180
+
181
+
182
+ &.btnHollow {
183
+
184
+ --_button-bg-color: var(--malert-confirm-btn-hollow-bg);
185
+ --_button-fg-color: var(--malert-confirm-btn-hollow-fg);
186
+ /* --_button-border-color: var(--__btn-o-primary-border-color); */
187
+
188
+
189
+ @media (hover: hover) {
190
+ &:hover {
191
+ --_button-bg-color: var(--malert-confirm-btn-hollow-hover-bg);
192
+ --_button-fg-color: var(--malert-confirm-btn-hollow-hover-fg);
193
+ /* --_button-border-color: var(--__btn-o-primary-hover-border-color); */
194
+ }
195
+ }
196
+
197
+ }
198
+
199
+ } /* end btnConfirm */
@@ -55,6 +55,11 @@ import * as styles from './slide-up-down-toggle.module.css';
55
55
  * if omitted the CSS value is used
56
56
  * callback {() => void|null} default null — invoked after the transition ends
57
57
  *
58
+ * Kept here for reference: the three exported functions below re-declare these same properties
59
+ * as dotted `@param` entries with base type `object` instead of `SlideOptions`, since TypeScript
60
+ * only expands dotted `@param` properties (needed for editor IntelliSense to list each property)
61
+ * when the base type is the literal `object`; a named typedef there would error (TS8032).
62
+ *
58
63
  * ─── Return value ─────────────────────────────────────────────────────────────
59
64
  *
60
65
  * All three functions return a Promise<void> that resolves when the transition ends.
@@ -194,7 +199,10 @@ export function disposeSliding(target) {
194
199
  * CSS animates height to 0, then snaps display to none.
195
200
  *
196
201
  * @param {HTMLElement} target
197
- * @param {SlideOptions} [options]
202
+ * @param {object} [options]
203
+ * @param {boolean} [options.wrap=true] - auto-generates a wrapper `<div class="slide">` around `target` (see module docs above); when `false`, the `.slide` class is added directly to `target`.
204
+ * @param {number} [options.duration] - overrides the `--slide-duration` CSS var (ms); if omitted, the CSS value is used.
205
+ * @param {(() => void) | null} [options.callback] - invoked after the transition ends.
198
206
  * @returns {Promise<void>}
199
207
  */
200
208
  export async function slideUp(target, options = {}) {
@@ -210,7 +218,10 @@ export async function slideUp(target, options = {}) {
210
218
  * display snaps to block, then CSS animates height from 0 (via @starting-style) to auto.
211
219
  *
212
220
  * @param {HTMLElement} target
213
- * @param {SlideOptions} [options]
221
+ * @param {object} [options]
222
+ * @param {boolean} [options.wrap=true] - auto-generates a wrapper `<div class="slide">` around `target` (see module docs above); when `false`, the `.slide` class is added directly to `target`.
223
+ * @param {number} [options.duration] - overrides the `--slide-duration` CSS var (ms); if omitted, the CSS value is used.
224
+ * @param {(() => void) | null} [options.callback] - invoked after the transition ends.
214
225
  * @returns {Promise<void>}
215
226
  */
216
227
  export async function slideDown(target, options = {}) {
@@ -226,7 +237,10 @@ export async function slideDown(target, options = {}) {
226
237
  * Reads the current data-slide value on the slide element to decide direction.
227
238
  *
228
239
  * @param {HTMLElement} target
229
- * @param {SlideOptions} [options]
240
+ * @param {object} [options]
241
+ * @param {boolean} [options.wrap=true] - auto-generates a wrapper `<div class="slide">` around `target` (see module docs above); when `false`, the `.slide` class is added directly to `target`.
242
+ * @param {number} [options.duration] - overrides the `--slide-duration` CSS var (ms); if omitted, the CSS value is used.
243
+ * @param {(() => void) | null} [options.callback] - invoked after the transition ends.
230
244
  * @returns {Promise<void>}
231
245
  */
232
246
  export async function slideToggle(target, options = {}) {
@@ -231,6 +231,21 @@
231
231
  --malert-box-shadow: 0 .025rem .25rem 0 color-mix(in srgb, var(--malert-box-shadow-color) 15%, transparent), -.01875rem .1875rem .20625rem -.03125rem color-mix(in srgb, var(--malert-box-shadow-color) 15%, transparent), -.03125rem .38125rem .4125rem -.05625rem color-mix(in srgb, var(--malert-box-shadow-color) 14%, transparent), -.05625rem .7rem .75625rem -.0875rem color-mix(in srgb, var(--malert-box-shadow-color) 14%, transparent), -.1rem 1.21875rem 1.31875rem -.11875rem color-mix(in srgb, var(--malert-box-shadow-color) 13%, transparent), -.16875rem 2.04375rem 2.2125rem -.14375rem color-mix(in srgb, var(--malert-box-shadow-color) 13%, transparent), -.26875rem 3.25rem 3.525rem -.175rem color-mix(in srgb, var(--malert-box-shadow-color) 12%, transparent);
232
232
  --malert-box-shadow-color: #000;
233
233
  --malert-confirm-bg: hsl(277deg 72% 45%);
234
+ --malert-confirm-btn-active-bg: color-mix(in srgb, var(--malert-confirm-bg) 60%, #000);
235
+ --malert-confirm-btn-active-border-color: var(--malert-confirm-btn-active-bg);
236
+ --malert-confirm-btn-active-fg: var(--malert-confirm-fg);
237
+ --malert-confirm-btn-bg: var(--malert-confirm-bg);
238
+ --malert-confirm-btn-border-color: var(--malert-confirm-bg);
239
+ --malert-confirm-btn-fg: var(--malert-confirm-fg);
240
+ --malert-confirm-btn-focus-outline-color: color-mix(in srgb, var(--malert-confirm-bg) 60%, transparent);
241
+ --malert-confirm-btn-focus-outline-width: var(--btn-focus-outline-width);
242
+ --malert-confirm-btn-hollow-bg: var(--malert-confirm-fg);
243
+ --malert-confirm-btn-hollow-fg: var(--malert-confirm-bg);
244
+ --malert-confirm-btn-hollow-hover-bg: var(--malert-confirm-bg);
245
+ --malert-confirm-btn-hollow-hover-fg: var(--malert-confirm-fg);
246
+ --malert-confirm-btn-hover-bg: var(--malert-confirm-fg);
247
+ --malert-confirm-btn-hover-border-color: var(--malert-confirm-btn-hover-fg);
248
+ --malert-confirm-btn-hover-fg: var(--malert-confirm-bg);
234
249
  --malert-confirm-fg: #fff;
235
250
  --malert-error-bg: var(--status-danger-background-color);
236
251
  --malert-error-fg: var(--status-danger-fg);
@@ -23,8 +23,22 @@
23
23
  * Returns an HTML `<time>` element string displaying the date in relative or absolute form.
24
24
  * Relative dates are auto-refreshed every minute via a shared `setInterval`.
25
25
  *
26
+ * The base param type below is intentionally `object` (not `RelativeDateOptions`): TypeScript only
27
+ * expands dotted `@param` properties (needed for editor IntelliSense to list each property) when
28
+ * the base type is the literal `object`; a named typedef there would error (TS8032).
26
29
  * @param {Date | string} date - Date to display (Date object or ISO string)
27
- * @param {RelativeDateOptions} [options={}]
30
+ * @param {object} [options={}]
31
+ * @param {boolean} [options.useRelativeTime=true] - Show times near the date as "in xx minutes" (before) or "now" (within `relativeTimeMinutesAfter`)
32
+ * @param {string} [options.nowString] - String to display when the date is right now
33
+ * @param {number} [options.relativeTimeMinutesBefore] - Minutes before the date within which to show "in xx minutes"
34
+ * @param {number} [options.relativeTimeMinutesAfter] - Minutes after the date within which to show the now string
35
+ * @param {boolean} [options.relativeTimeShowTime] - Show the actual time alongside relative date labels
36
+ * @param {string} [options.relativeTimeShowTimeMarkup] - HTML markup for the time portion; `@@time@@` is replaced with the localized time string
37
+ * @param {boolean} [options.firstLetterUpperCase] - Capitalize the first letter of the returned string
38
+ * @param {Intl.DateTimeFormatOptions} [options.dateFormat] - Format for non-relative dates (beyond day after tomorrow)
39
+ * @param {Intl.DateTimeFormatOptions} [options.timeFormat] - Format for time displayed in relative date labels
40
+ * @param {string[]} [options.relativeStrings] - Labels for yesterday / today / tomorrow / day after tomorrow (in chronological order)
41
+ * @param {string} [options.locale] - Locale string for date/time formatting
28
42
  * @returns {string} HTML `<time>` element as a string
29
43
  *
30
44
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat