@newlogic-digital/stimulus-components 1.1.1 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newlogic-digital/stimulus-components",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "eslint": "eslint '**/*.js'",
@@ -7,53 +7,83 @@
7
7
  }
8
8
 
9
9
  & :where(div[aria-hidden]) {
10
+ border-radius: var(--x-control-select-picker-border-radius);
11
+ border:
12
+ var(--x-control-select-picker-border-width) solid
13
+ color-mix(
14
+ in var(--x-control-select-picker-border-color-space, srgb),
15
+ var(--x-control-select-picker-border-color) var(--x-control-select-picker-border-color-opacity, 15%),
16
+ var(--x-control-select-picker-border-color-mix, transparent)
17
+ );
18
+ background-color: var(--x-control-select-picker-background-color);
19
+ margin-block: var(--x-control-select-picker-margin-block);
20
+ padding-block: var(--x-control-select-picker-padding-block);
21
+ padding-inline: var(--x-control-select-picker-padding-inline);
22
+ gap: var(--x-control-select-picker-gap);
23
+ scrollbar-color: var(--x-control-select-picker-scrollbar-color);
24
+ transition-property: var(--x-control-select-picker-transition-property, var(--default-transition-property));
25
+ transition-duration: var(--x-control-select-picker-transition-duration, var(--default-transition-duration));
26
+ transition-timing-function: var(--x-control-select-picker-transition-timing-function, var(--ease-in-out));
27
+ transition-behavior: allow-discrete;
28
+ will-change: var(--x-control-select-picker-will-change, transform, opacity);
29
+ opacity: var(--x-control-select-picker-closed-opacity, 0);
30
+ transform: var(--x-control-select-picker-closed-transform, scale(0.9));
31
+ display: flex;
32
+ flex-direction: column;
33
+ cursor: auto;
34
+ transform-origin: top center;
35
+ scrollbar-width: thin;
10
36
  grid-area: x-control;
11
- will-change: transform;
12
- border-radius: inherit;
13
37
  position: absolute;
14
- background-color: var(--color-body-primary);
15
38
  z-index: var(--z-index-10);
16
39
  inset-inline: 0;
17
40
  top: 100%;
18
- margin-block-start: 0.5rem;
19
- border: 1px solid color-mix(in srgb, currentcolor 10%, transparent);
20
- transform: scaleY(0.75);
21
- opacity: 0;
22
- transition-property: var(--default-transition-property);
23
- transition-timing-function: var(--ease-in-out);
24
- transition-duration: var(--default-transition-duration);
25
41
  backface-visibility: hidden;
26
- transform-origin: center top;
27
42
  user-select: none;
28
43
  max-height: 12rem;
29
44
  overflow-y: auto;
30
- box-shadow: 0 0.15em 1.5em 0 color-mix(in srgb, var(--color-dark) 5%, transparent), 0 0 1em 0 color-mix(in srgb, var(--color-dark) 5%, transparent);
31
- padding: 0.375rem;
32
- color: currentcolor;
33
- cursor: default;
34
45
  visibility: hidden;
35
46
 
36
47
  & [data-option] {
37
- padding: calc(var(--x-control-padding-inline) / 1.5) var(--x-control-padding-inline);
48
+ padding-block: var(--x-control-select-option-padding-block);
49
+ padding-inline: var(--x-control-select-option-padding-inline);
50
+ font-size: var(--x-control-select-option-font-size);
51
+ font-weight: var(--x-control-select-option-font-weight);
52
+ line-height: var(--x-control-select-option-line-height);
53
+ border-radius: var(--x-control-select-option-border-radius);
54
+ transition: var(--transition-background), var(--transition-color);
38
55
  cursor: pointer;
39
- transition: var(--transition-background);
40
- font-size: var(--x-control-font-size);
41
- border-radius: inherit;
42
56
 
43
57
  &[data-disabled] {
44
58
  opacity: 0.5;
45
59
  pointer-events: none;
46
60
  }
47
61
 
48
- &:is(:hover, :focus) {
49
- background-color: color-mix(in srgb, var(--color-accent) 10%, transparent);
62
+ &[data-active] {
63
+ color: var(--x-control-select-option-checked-color, var(--color-accent));
64
+ background-color:
65
+ color-mix(
66
+ in var(--x-control-select-option-checked-background-color-space, srgb),
67
+ var(--x-control-select-option-checked-background-color, var(--color-accent)) var(--x-control-select-option-checked-background-color-opacity, 10%),
68
+ var(--x-control-select-option-checked-background-color-mix, transparent)
69
+ );
70
+ }
71
+
72
+ &:hover {
73
+ background-color: var(--x-control-select-option-hocus-background-color);
50
74
  }
51
75
  }
52
76
  }
53
77
 
54
- &:focus-within select ~ div[aria-hidden] {
55
- opacity: 1;
56
- transform: none;
57
- visibility: visible;
78
+ &:focus-within:not(:has(:focus-visible)) {
79
+ &::after {
80
+ transform: var(--x-control-select-open-icon-transform, rotate(180deg));
81
+ }
82
+
83
+ select ~ div[aria-hidden] {
84
+ opacity: 1;
85
+ transform: none;
86
+ visibility: visible;
87
+ }
58
88
  }
59
- }
89
+ }
@@ -4,17 +4,15 @@ import { dataset, dispatchCustomEvent } from '@newlogic-digital/utils-js'
4
4
  export class ControlSelect extends Controller {
5
5
  connect() {
6
6
  this.select = this.element.querySelector('select')
7
- const option = this.element.querySelectorAll('[data-option]')
7
+ this.options = this.element.querySelectorAll('[data-option]')
8
8
 
9
- if (option[0]) {
10
- option.forEach((option) => {
11
- if (option.dataset.disabled) {
12
- return
13
- }
9
+ dataset(this.select, 'action').add('change->x-control-select#active')
14
10
 
15
- dataset(option, 'action').add('click->x-control-select#choose', 'keydown.enter->x-control-select#choose')
16
- })
17
- }
11
+ this.options.forEach((option) => {
12
+ if (option.dataset.disabled) return
13
+
14
+ dataset(option, 'action').add('click->x-control-select#choose')
15
+ })
18
16
  }
19
17
 
20
18
  choose({ currentTarget }) {
@@ -22,4 +20,9 @@ export class ControlSelect extends Controller {
22
20
  dispatchCustomEvent(this.select)
23
21
  document.activeElement.blur()
24
22
  }
23
+
24
+ active() {
25
+ this.options.forEach(option => option.removeAttribute('data-active'))
26
+ this.element.querySelector(`[data-option="${this.select.value}"]`).setAttribute('data-active', '')
27
+ }
25
28
  }