@ismailnakkar/ui-behaviours 0.4.0 → 0.5.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/README.md +13 -90
- package/package.json +1 -1
- package/src/range-picker.css +16 -24
package/README.md
CHANGED
|
@@ -494,10 +494,8 @@ any rule of yours wins; the ones defaulting to another property follow it.
|
|
|
494
494
|
| `--range-picker-text-color` | `#1c2130` | The popover's text, the days, the month and year, the summary's range name, and a custom range's days on the button |
|
|
495
495
|
| `--range-picker-muted-color` | `#687086` | The button's days and the summary |
|
|
496
496
|
| `--range-picker-preset-color` | `--range-picker-muted-color` | The presets |
|
|
497
|
-
| `--range-picker-preset-hover-
|
|
498
|
-
| `--range-picker-preset-hover-background` | `--range-picker-hover-background` | Its ground |
|
|
497
|
+
| `--range-picker-preset-hover-background` | `--range-picker-hover-background` | A preset under the pointer |
|
|
499
498
|
| `--range-picker-arrow-color` | `--range-picker-muted-color` | Cally's previous and next buttons |
|
|
500
|
-
| `--range-picker-arrow-hover-color` | `--range-picker-text-color` | An arrow under the pointer |
|
|
501
499
|
| `--range-picker-weekday-color` | `--range-picker-muted-color` | The weekday names |
|
|
502
500
|
| `--range-picker-background` | `#fff` | The popover, the arrows and the year select |
|
|
503
501
|
| `--range-picker-hover-background` | `#f4f6fb` | A day, an arrow and the year select under the pointer, and the button while the popover is open |
|
|
@@ -517,19 +515,10 @@ any rule of yours wins; the ones defaulting to another property follow it.
|
|
|
517
515
|
| `--range-picker-disabled-end-color` | `--range-picker-text-color` | Its text |
|
|
518
516
|
| `--range-picker-radius` | `0.75rem` | The popover's corners |
|
|
519
517
|
| `--range-picker-control-radius` | `0.5rem` | The presets', the days', the arrows' and the year select's corners |
|
|
520
|
-
| `--range-picker-shadow` | `0 16px 40px -8px rgb(16 24 40 / 0.22)` | The popover's shadow |
|
|
521
|
-
| `--range-picker-font-size` | `0.875rem` | The popover's text size |
|
|
522
518
|
| `--range-picker-padding` | `1.25rem` | The popover's padding: set a smaller one under your phone width |
|
|
523
|
-
| `--range-picker-window-gap` | `0.75rem` | The least room the popover leaves to the window's edges |
|
|
524
|
-
| `--range-picker-offset` | `0.375rem` | The gap between the anchored popover and its button |
|
|
525
|
-
| `--range-picker-anchored-max-height` | `calc(100% - 2 * var(--range-picker-offset))` | The anchored popover's height limit, against the room on the side it opens toward |
|
|
526
|
-
| `--range-picker-position-try-order` | `most-height` | Which side the anchored popover prefers: the roomier one by default; `normal` keeps the order below, then above |
|
|
527
|
-
| `--range-picker-day-size` | `2.5rem` | A day's width and height |
|
|
528
|
-
| `--range-picker-preset-height` | `2.5rem` | A preset's least height |
|
|
529
|
-
| `--range-picker-chip-height` | `--range-picker-preset-height` | A chip's least height, where the presets are chips |
|
|
530
519
|
|
|
531
|
-
The weights and the text sizes are the stylesheet's
|
|
532
|
-
|
|
520
|
+
The weights and the text sizes are the stylesheet's: the popover's text is `0.875rem`, the year select's `1rem`, the
|
|
521
|
+
button's days `0.8125rem` and the weekday names `0.75rem`.
|
|
533
522
|
|
|
534
523
|
The colours are light; a dark page sets its own under its dark selector. The stylesheet uses no `light-dark()`:
|
|
535
524
|
Lightning CSS (in Vite and Tailwind v4) lowers it to variables it sets only where the same stylesheet declares
|
|
@@ -612,90 +601,24 @@ Run this package's suite with `npm test`.
|
|
|
612
601
|
|
|
613
602
|
## Upgrading
|
|
614
603
|
|
|
604
|
+
### From 0.4
|
|
605
|
+
|
|
606
|
+
- The stylesheet no longer reads `--range-picker-shadow`, `--range-picker-font-size`, `--range-picker-window-gap`,
|
|
607
|
+
`--range-picker-offset`, `--range-picker-anchored-max-height`, `--range-picker-position-try-order`,
|
|
608
|
+
`--range-picker-day-size`, `--range-picker-preset-height`, `--range-picker-chip-height`,
|
|
609
|
+
`--range-picker-preset-hover-color` or `--range-picker-arrow-hover-color`: it draws their old defaults. A page that
|
|
610
|
+
set one gets the default instead.
|
|
611
|
+
|
|
615
612
|
### From 0.3
|
|
616
613
|
|
|
617
614
|
Nothing changes for a page on 0.3: copy buttons without `data-copy-status` and radios work as before, a select or a
|
|
618
615
|
checkbox changes nothing unless a `data-show-if` names its field, and only a field marked `data-submit-on-change`
|
|
619
|
-
submits.
|
|
620
|
-
|
|
621
|
-
- **cuty, the Full Page Script copy** (`resources/js/members/tools/fps.js`, `members/tools/fps.blade.php`). Delete the
|
|
622
|
-
`MutationObserver` at the end of `fps.js` with its `COPIED` and `status` constants, give the Copy button
|
|
623
|
-
`data-copy-status="fps-copy-status"`, and give the `.copy-status` span that id; its `data-copied-text` stays. Add a
|
|
624
|
-
`data-copy-failed-text` to say a refusal too.
|
|
625
|
-
- **exe, both shorten forms' copy** (`resources/js/site/shorten.ts` and `shorten.test.ts`, the home page's form in
|
|
626
|
-
`public/home.blade.php` and the nav dialog's in `layouts/member.blade.php`: one `bind()` serves every
|
|
627
|
-
`form[data-shorten]`). In each form, give the `data-shorten-copy` button `data-copy` naming the form's link
|
|
628
|
-
(`shorten-link`, `shorten-dialog-link`) and `data-copy-status` naming its `data-shorten-status` paragraph, give that
|
|
629
|
-
paragraph the id (`shorten-status`, `shorten-dialog-status`), rename its `data-copied` to `data-copied-text`, and add
|
|
630
|
-
a `data-copy-failed-text` holding the `general.shorten.copy-blocked` words.
|
|
631
|
-
- Restyle each form from the button's own marks, as `x-ui.copy-button` does: the button becomes a `group`,
|
|
632
|
-
`group-data-[copy-state=done]:` becomes `data-copied:` on it (hover repeats included) and `group-data-copied:` on
|
|
633
|
-
its labels, `=failed` the same with `data-copy-failed`, and the copy-blocked line shows with
|
|
634
|
-
`group-has-[[data-copy-failed]]:block`.
|
|
635
|
-
- Delete the copy state machine from `shorten.ts`: the `CopyState` and `Timer` types, `copyState` and its calls, the
|
|
636
|
-
`copied` timer, `copyLink()` and the copy listener. Drop the `failed` hook and the `data-shorten-copy-failed`
|
|
637
|
-
attribute of both copy-blocked lines in the same change: `hooks()` binds nothing while a hook it asks for is
|
|
638
|
-
missing. `copy` and `copyUrl` stay: `showResult()` focuses the one and fills the other.
|
|
639
|
-
- In `shorten.test.ts`, drop `data-shorten-copy-failed` and `data-copied` from the markup, delete "selects the link
|
|
640
|
-
when the clipboard refuses" (this package's tests select a refused copy), and keep "clears a Copied state when a
|
|
641
|
-
new link arrives" as "shows a new link and says it is ready": its submit and answer, without the copy click and the
|
|
642
|
-
`copyState` assertions.
|
|
643
|
-
- Both marks then last 1.5 seconds, as on exe's other copy buttons. Today a copy shows for 2 seconds, a refusal and
|
|
644
|
-
its copy-blocked line stay until the next copy or submit, and a new link clears either at once.
|
|
645
|
-
- **upfiles, the admin's conditional fields** (`resources/js/admin/conditional-fields.js`, its
|
|
646
|
-
`tests/js/conditional-fields.test.mjs`, the `initConditionalFields()` call in `resources/js/admin/index.js`). Delete
|
|
647
|
-
the three, and turn each `data-cond-field="x" data-cond-value="v"` into `data-show-if="x=v"`
|
|
648
|
-
(`admin/delete.blade.php`, `components/storages/form.blade.php`). The storages form now draws its first state on the
|
|
649
|
-
server: each role hint and driver section `hidden` unless it is the role or driver its select shows (`old()`, else the
|
|
650
|
-
storage's, else the default role or the first driver), as the CSAM origin field already is.
|
|
651
|
-
- **upfiles, the auto-submitting select** (`resources/js/lib/form-affordances.js`, called from
|
|
652
|
-
`resources/js/admin/index.js` and `resources/js/member/index.js`). Delete it and its two calls, and rename
|
|
653
|
-
`data-autosubmit` to `data-submit-on-change` (`admin/moderation/index.blade.php`); both bundles already call
|
|
654
|
-
`installUiBehaviours()`. Rename it in the two `assertDontSee('data-autosubmit', false)` of
|
|
655
|
-
`tests/Feature/StatisticsDashboardsTest.php` too, or they pass whatever the month pickers carry.
|
|
656
|
-
- **centratag, the dashboard's select** (`resources/js/dashboard.ts`). Add `@ismailnakkar/ui-behaviours` and replace the
|
|
657
|
-
file's change listener with `installUiBehaviours()`; `data-submit-on-change` in `tags/show.blade.php` stays as it is.
|
|
616
|
+
submits.
|
|
658
617
|
|
|
659
618
|
### From 0.2
|
|
660
619
|
|
|
661
620
|
Nothing changes for a page on 0.2: the stepper, `data-show-if` and `data-clear-on` read only attributes of their own,
|
|
662
|
-
and the stylesheet loads only when imported.
|
|
663
|
-
|
|
664
|
-
- **The two-factor stepper.** Delete the app's stepper script, its steps module and their tests, then in the dialog:
|
|
665
|
-
- add `data-steps` to the dialog;
|
|
666
|
-
- replace `data-email-code-sent` with `data-open-at-step="2"`, the email step;
|
|
667
|
-
- rename `data-step-turn-on` to `data-step-submit` (`data-step`, `data-step-back` and `data-step-next` stay);
|
|
668
|
-
- on the progress bars, rename `data-progress-step="n"` to `data-step-mark="n"`, draw mark 1 with
|
|
669
|
-
`data-step-state="current"`, and style `[data-step-state="done"]` and `[data-step-state="current"]` in place of the
|
|
670
|
-
`is-done` and `is-current` classes (or `data-state`);
|
|
671
|
-
- on the progress line's spans, rename `data-progress-step="n"` to `data-step-label="n"`;
|
|
672
|
-
- give each field the server refused `aria-invalid="true"`: the stepper reads no error class (`.validation-error`,
|
|
673
|
-
`.invalid-feedback`).
|
|
674
|
-
- **The payout destination form.** Delete the app's destination script, drop `data-destination-form`, add
|
|
675
|
-
`data-clear-on="method"` to the account field, and turn each `data-method-hint="paypal"` into
|
|
676
|
-
`data-show-if="method=paypal"`.
|
|
677
|
-
- **The range picker's look.** Import `range-picker.css` and set the custom properties from the app's palette and
|
|
678
|
-
sizes, with a smaller `--range-picker-padding` under the app's phone width (`1rem` for a popover that had 16px). In
|
|
679
|
-
the markup, `r-range-button` becomes `range-picker-button`, `r-range-panel` `range-picker-panel`, `r-presets`
|
|
680
|
-
`range-picker-presets`, `r-preset` `range-picker-preset`, `r-months` `range-picker-months`, `r-range-foot`
|
|
681
|
-
`range-picker-foot`, `r-range-sum` `range-picker-summary` and `r-pick-end` `range-picker-pick-end`; `r-range`,
|
|
682
|
-
`r-calendar`, `r-range-name` and `r-range-dates` go, as the stylesheet styles `[data-range-picker]`, its
|
|
683
|
-
`calendar-range`, `[data-range-name]` and `[data-range-dates]`. Utility classes that restyle the popover (border,
|
|
684
|
-
background, padding, shadow, text colour) go too; an opening animation stays.
|
|
685
|
-
|
|
686
|
-
Then delete the app's own picker rules, except those that draw the app's controls and icons, which the stylesheet
|
|
687
|
-
leaves to the app. Keep these, under the new class names:
|
|
688
|
-
- the range button's control: its height, padding, border, corners, background, text colour and size, hover and
|
|
689
|
-
transition, its icons' size and colour, and the chevron's `margin-inline-start: auto` (cuty's `.r-range-button`
|
|
690
|
-
and its desktop font size, upfiles' `.r-range-button > i`; exe draws it with utility classes);
|
|
691
|
-
- the arrows' icons in Cally's slots, both nested in `.r-calendar`, so move them out before deleting that block:
|
|
692
|
-
their size (cuty's `[slot] > svg`, as `[data-range-picker] [slot] > svg`) and their mirror on a right-to-left
|
|
693
|
-
page (upfiles' `.r-flip:dir(rtl)`; cuty's `flip-rtl` and exe's `rtl:-scale-x-100` sit outside the picker's
|
|
694
|
-
rules);
|
|
695
|
-
- a preset's icon size (cuty's `.r-preset svg`);
|
|
696
|
-
- the Set button: cuty's `.r-range-foot button` (height, padding, size, weight), and its full width on a phone,
|
|
697
|
-
cuty's `.r-range-foot button { flex: 1 }` and upfiles' `.r-range-foot .btn` (exe's `max-sm:flex-1` is in the
|
|
698
|
-
markup).
|
|
621
|
+
and the stylesheet loads only when imported.
|
|
699
622
|
|
|
700
623
|
### From 0.1
|
|
701
624
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ismailnakkar/ui-behaviours",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Page behaviours from plain HTML attributes (copy with a spoken result, confirm, submit once or on a change, native dialogs, steps, show by a radio, checkbox or select, check all, autoselect), and a date range picker over Cally with an optional stylesheet.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"clipboard",
|
package/src/range-picker.css
CHANGED
|
@@ -21,14 +21,7 @@
|
|
|
21
21
|
--range-picker-disabled-color: #aeb5c6;
|
|
22
22
|
--range-picker-radius: 0.75rem;
|
|
23
23
|
--range-picker-control-radius: 0.5rem;
|
|
24
|
-
--range-picker-shadow: 0 16px 40px -8px rgb(16 24 40 / 0.22);
|
|
25
|
-
--range-picker-font-size: 0.875rem;
|
|
26
24
|
--range-picker-padding: 1.25rem;
|
|
27
|
-
--range-picker-window-gap: 0.75rem;
|
|
28
|
-
--range-picker-offset: 0.375rem;
|
|
29
|
-
--range-picker-day-size: 2.5rem;
|
|
30
|
-
--range-picker-preset-height: 2.5rem;
|
|
31
|
-
--range-picker-position-try-order: most-height;
|
|
32
25
|
}
|
|
33
26
|
|
|
34
27
|
/* The button: the app draws the control; this lays out its icon, name and days. */
|
|
@@ -88,15 +81,15 @@
|
|
|
88
81
|
[data-range-picker] {
|
|
89
82
|
margin: auto;
|
|
90
83
|
width: max-content;
|
|
91
|
-
max-width: calc(100vw -
|
|
92
|
-
max-height: calc(100dvh -
|
|
84
|
+
max-width: calc(100vw - 1.5rem);
|
|
85
|
+
max-height: calc(100dvh - 1.5rem);
|
|
93
86
|
padding: var(--range-picker-padding);
|
|
94
87
|
border: 1px solid var(--range-picker-border-color);
|
|
95
88
|
border-radius: var(--range-picker-radius);
|
|
96
89
|
background: var(--range-picker-background);
|
|
97
|
-
box-shadow:
|
|
90
|
+
box-shadow: 0 16px 40px -8px rgb(16 24 40 / 0.22);
|
|
98
91
|
color: var(--range-picker-text-color);
|
|
99
|
-
font-size:
|
|
92
|
+
font-size: 0.875rem;
|
|
100
93
|
}
|
|
101
94
|
|
|
102
95
|
.range-picker-panel {
|
|
@@ -118,7 +111,7 @@
|
|
|
118
111
|
display: flex;
|
|
119
112
|
align-items: center;
|
|
120
113
|
gap: 0.625rem;
|
|
121
|
-
min-block-size:
|
|
114
|
+
min-block-size: 2.5rem;
|
|
122
115
|
margin: 0;
|
|
123
116
|
padding-inline: 0.75rem;
|
|
124
117
|
border-radius: var(--range-picker-control-radius);
|
|
@@ -130,7 +123,7 @@
|
|
|
130
123
|
|
|
131
124
|
.range-picker-preset:hover {
|
|
132
125
|
background: var(--range-picker-preset-hover-background, var(--range-picker-hover-background));
|
|
133
|
-
color: var(--range-picker-
|
|
126
|
+
color: var(--range-picker-text-color);
|
|
134
127
|
}
|
|
135
128
|
|
|
136
129
|
.range-picker-preset input {
|
|
@@ -181,7 +174,7 @@
|
|
|
181
174
|
|
|
182
175
|
[data-range-picker] calendar-range::part(button):hover {
|
|
183
176
|
background: var(--range-picker-hover-background);
|
|
184
|
-
color: var(--range-picker-
|
|
177
|
+
color: var(--range-picker-text-color);
|
|
185
178
|
}
|
|
186
179
|
|
|
187
180
|
[data-range-picker] calendar-range::part(button):focus-visible {
|
|
@@ -238,7 +231,7 @@
|
|
|
238
231
|
}
|
|
239
232
|
|
|
240
233
|
[data-range-picker] calendar-month::part(th) {
|
|
241
|
-
inline-size:
|
|
234
|
+
inline-size: 2.5rem;
|
|
242
235
|
block-size: 1.75rem;
|
|
243
236
|
color: var(--range-picker-weekday-color, var(--range-picker-muted-color));
|
|
244
237
|
font-size: 0.75rem;
|
|
@@ -246,8 +239,8 @@
|
|
|
246
239
|
}
|
|
247
240
|
|
|
248
241
|
[data-range-picker] calendar-month::part(day) {
|
|
249
|
-
inline-size:
|
|
250
|
-
block-size:
|
|
242
|
+
inline-size: 2.5rem;
|
|
243
|
+
block-size: 2.5rem;
|
|
251
244
|
border-radius: var(--range-picker-control-radius);
|
|
252
245
|
color: var(--range-picker-text-color);
|
|
253
246
|
}
|
|
@@ -377,7 +370,6 @@
|
|
|
377
370
|
}
|
|
378
371
|
|
|
379
372
|
.range-picker-preset {
|
|
380
|
-
min-block-size: var(--range-picker-chip-height, var(--range-picker-preset-height));
|
|
381
373
|
border: 1px solid var(--range-picker-control-border-color);
|
|
382
374
|
border-radius: 999px;
|
|
383
375
|
}
|
|
@@ -392,15 +384,15 @@
|
|
|
392
384
|
@supports (position-area: bottom) {
|
|
393
385
|
[data-range-picker] {
|
|
394
386
|
inset: auto;
|
|
395
|
-
margin-block:
|
|
396
|
-
margin-inline: 0
|
|
387
|
+
margin-block: 0.375rem;
|
|
388
|
+
margin-inline: 0 0.75rem;
|
|
397
389
|
position-anchor: --range-picker;
|
|
398
390
|
position-area: bottom span-right;
|
|
399
391
|
position-try-fallbacks: flip-inline, flip-block, flip-block flip-inline;
|
|
400
|
-
/* No taller than the room on the side it opens toward, which is the roomier one
|
|
401
|
-
|
|
402
|
-
max-height:
|
|
403
|
-
position-try-order:
|
|
392
|
+
/* No taller than the room on the side it opens toward, which is the roomier one: a short window scrolls it
|
|
393
|
+
inside, so its Set button stays reachable. */
|
|
394
|
+
max-height: calc(100% - 0.75rem);
|
|
395
|
+
position-try-order: most-height;
|
|
404
396
|
}
|
|
405
397
|
|
|
406
398
|
[data-range-picker]:dir(rtl) {
|