@radix-ng/primitives 0.1.0 → 0.1.1

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.
Files changed (132) hide show
  1. package/README.md +2 -4
  2. package/checkbox/src/checkbox-indicator.directive.d.ts +6 -0
  3. package/checkbox/src/checkbox.directive.d.ts +71 -0
  4. package/checkbox/src/checkbox.token.d.ts +4 -0
  5. package/esm2022/checkbox/index.mjs +4 -0
  6. package/esm2022/checkbox/radix-ng-primitives-checkbox.mjs +5 -0
  7. package/esm2022/checkbox/src/checkbox-indicator.directive.mjs +23 -0
  8. package/esm2022/checkbox/src/checkbox.directive.mjs +135 -0
  9. package/esm2022/checkbox/src/checkbox.token.mjs +6 -0
  10. package/esm2022/index.mjs +2 -0
  11. package/esm2022/label/index.mjs +2 -0
  12. package/esm2022/label/radix-ng-primitives-label.mjs +5 -0
  13. package/esm2022/label/src/label.directive.mjs +46 -0
  14. package/esm2022/progress/index.mjs +3 -0
  15. package/esm2022/progress/radix-ng-primitives-progress.mjs +5 -0
  16. package/esm2022/progress/src/progress-indicator.directive.mjs +23 -0
  17. package/esm2022/progress/src/progress.directive.mjs +62 -0
  18. package/esm2022/progress/src/progress.token.mjs +6 -0
  19. package/esm2022/radix-ng-primitives.mjs +5 -0
  20. package/esm2022/roving-focus/index.mjs +5 -0
  21. package/esm2022/roving-focus/radix-ng-primitives-roving-focus.mjs +5 -0
  22. package/esm2022/roving-focus/src/roving-focus-group.directive.mjs +115 -0
  23. package/esm2022/roving-focus/src/roving-focus-group.token.mjs +9 -0
  24. package/esm2022/roving-focus/src/roving-focus-item.directive.mjs +91 -0
  25. package/esm2022/roving-focus/src/roving-focus-item.token.mjs +6 -0
  26. package/esm2022/separator/index.mjs +2 -0
  27. package/esm2022/separator/radix-ng-primitives-separator.mjs +5 -0
  28. package/esm2022/separator/src/separator.directive.mjs +37 -0
  29. package/esm2022/switch/index.mjs +4 -0
  30. package/esm2022/switch/radix-ng-primitives-switch.mjs +5 -0
  31. package/esm2022/switch/src/switch-thumb.directive.mjs +25 -0
  32. package/esm2022/switch/src/switch.directive.mjs +125 -0
  33. package/esm2022/switch/src/switch.token.mjs +6 -0
  34. package/esm2022/visually-hidden/index.mjs +2 -0
  35. package/esm2022/visually-hidden/radix-ng-primitives-visually-hidden.mjs +5 -0
  36. package/esm2022/visually-hidden/src/visually-hidden.directive.mjs +42 -0
  37. package/fesm2022/radix-ng-primitives-checkbox.mjs +166 -0
  38. package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -0
  39. package/fesm2022/radix-ng-primitives-label.mjs +53 -0
  40. package/fesm2022/radix-ng-primitives-label.mjs.map +1 -0
  41. package/fesm2022/radix-ng-primitives-progress.mjs +93 -0
  42. package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -0
  43. package/fesm2022/radix-ng-primitives-roving-focus.mjs +220 -0
  44. package/fesm2022/radix-ng-primitives-roving-focus.mjs.map +1 -0
  45. package/fesm2022/radix-ng-primitives-separator.mjs +44 -0
  46. package/fesm2022/radix-ng-primitives-separator.mjs.map +1 -0
  47. package/fesm2022/radix-ng-primitives-switch.mjs +158 -0
  48. package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -0
  49. package/fesm2022/radix-ng-primitives-visually-hidden.mjs +49 -0
  50. package/fesm2022/radix-ng-primitives-visually-hidden.mjs.map +1 -0
  51. package/fesm2022/radix-ng-primitives.mjs +4 -0
  52. package/fesm2022/radix-ng-primitives.mjs.map +1 -0
  53. package/label/src/label.directive.d.ts +14 -0
  54. package/package.json +82 -24
  55. package/progress/src/progress-indicator.directive.d.ts +6 -0
  56. package/progress/src/progress.directive.d.ts +26 -0
  57. package/progress/src/progress.token.d.ts +4 -0
  58. package/roving-focus/src/roving-focus-group.directive.d.ts +55 -0
  59. package/roving-focus/src/roving-focus-group.token.d.ts +7 -0
  60. package/roving-focus/src/roving-focus-item.directive.d.ts +52 -0
  61. package/roving-focus/src/roving-focus-item.token.d.ts +4 -0
  62. package/separator/src/separator.directive.d.ts +16 -0
  63. package/switch/src/switch-thumb.directive.d.ts +9 -0
  64. package/switch/src/switch.directive.d.ts +73 -0
  65. package/switch/src/switch.token.d.ts +4 -0
  66. package/visually-hidden/src/visually-hidden.directive.d.ts +11 -0
  67. package/.docs/overview/accessibility.docs.mdx +0 -45
  68. package/.docs/overview/installation.docs.mdx +0 -15
  69. package/.docs/overview/introduction.docs.mdx +0 -59
  70. package/.docs/utils/storybook.ts +0 -30
  71. package/.eslintrc.json +0 -56
  72. package/.storybook/helpers/bages-config.ts +0 -43
  73. package/.storybook/main.ts +0 -24
  74. package/.storybook/manager-head.html +0 -76
  75. package/.storybook/manager.ts +0 -6
  76. package/.storybook/preview.ts +0 -58
  77. package/.storybook/rdxTheme.ts +0 -8
  78. package/.storybook/tsconfig.json +0 -20
  79. package/CHANGELOG.md +0 -6
  80. package/checkbox/ng-package.json +0 -5
  81. package/checkbox/src/checkbox-indicator.directive.ts +0 -15
  82. package/checkbox/src/checkbox.directive.ts +0 -138
  83. package/checkbox/src/checkbox.token.ts +0 -8
  84. package/checkbox/stories/checkbox.component.ts +0 -50
  85. package/checkbox/stories/checkbox.stories.ts +0 -29
  86. package/checkbox/stories/style.css +0 -265
  87. package/jest.config.ts +0 -22
  88. package/label/ng-package.json +0 -5
  89. package/label/src/label.directive.ts +0 -36
  90. package/label/stories/label.docs.mdx +0 -40
  91. package/label/stories/label.stories.ts +0 -63
  92. package/ng-package.json +0 -7
  93. package/progress/ng-package.json +0 -5
  94. package/progress/src/progress-indicator.directive.ts +0 -15
  95. package/progress/src/progress.directive.ts +0 -51
  96. package/progress/src/progress.token.ts +0 -8
  97. package/progress/stories/progress.docs.mdx +0 -66
  98. package/progress/stories/progress.stories.ts +0 -61
  99. package/project.json +0 -90
  100. package/roving-focus/ng-package.json +0 -5
  101. package/roving-focus/src/roving-focus-group.directive.ts +0 -135
  102. package/roving-focus/src/roving-focus-group.token.ts +0 -13
  103. package/roving-focus/src/roving-focus-item.directive.ts +0 -98
  104. package/roving-focus/src/roving-focus-item.token.ts +0 -10
  105. package/separator/ng-package.json +0 -5
  106. package/separator/src/separator.directive.spec.ts +0 -59
  107. package/separator/src/separator.directive.ts +0 -24
  108. package/separator/stories/separator.docs.mdx +0 -38
  109. package/separator/stories/separator.stories.ts +0 -91
  110. package/switch/ng-package.json +0 -5
  111. package/switch/src/switch-thumb.directive.ts +0 -17
  112. package/switch/src/switch.directive.ts +0 -132
  113. package/switch/src/switch.token.ts +0 -8
  114. package/switch/stories/switch.docs.mdx +0 -74
  115. package/switch/stories/switch.stories.ts +0 -76
  116. package/test-setup.ts +0 -8
  117. package/tsconfig.json +0 -32
  118. package/tsconfig.lib.json +0 -19
  119. package/tsconfig.lib.prod.json +0 -9
  120. package/tsconfig.spec.json +0 -21
  121. package/visually-hidden/ng-package.json +0 -5
  122. package/visually-hidden/src/visually-hidden.directive.spec.ts +0 -48
  123. package/visually-hidden/src/visually-hidden.directive.ts +0 -35
  124. package/visually-hidden/stories/visually-hidden.docs.mdx +0 -35
  125. /package/checkbox/{index.ts → index.d.ts} +0 -0
  126. /package/{index.ts → index.d.ts} +0 -0
  127. /package/label/{index.ts → index.d.ts} +0 -0
  128. /package/progress/{index.ts → index.d.ts} +0 -0
  129. /package/roving-focus/{index.ts → index.d.ts} +0 -0
  130. /package/separator/{index.ts → index.d.ts} +0 -0
  131. /package/switch/{index.ts → index.d.ts} +0 -0
  132. /package/visually-hidden/{index.ts → index.d.ts} +0 -0
@@ -1,138 +0,0 @@
1
- import {
2
- Directive,
3
- EventEmitter,
4
- HostListener,
5
- Input,
6
- Output,
7
- booleanAttribute
8
- } from '@angular/core';
9
- import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
10
- import { CheckboxToken } from './checkbox.token';
11
-
12
- @Directive({
13
- selector: 'button[rdxCheckbox]',
14
- standalone: true,
15
- providers: [
16
- { provide: CheckboxToken, useExisting: CheckboxDirective },
17
- { provide: NG_VALUE_ACCESSOR, useExisting: CheckboxDirective, multi: true }
18
- ],
19
- host: {
20
- type: 'button',
21
- role: 'checkbox',
22
- '[disabled]': 'disabled',
23
- '[attr.aria-checked]': 'indeterminate ? "mixed" : checked',
24
- '[attr.data-disabled]': 'disabled ? "" : null',
25
- '[attr.data-state]': 'state'
26
- }
27
- })
28
- export class CheckboxDirective implements ControlValueAccessor {
29
- /**
30
- * Defines whether the checkbox is checked.
31
- */
32
- @Input({ transform: booleanAttribute }) checked = false;
33
-
34
- /**
35
- * Defines whether the checkbox is indeterminate.
36
- */
37
- @Input({ transform: booleanAttribute })
38
- indeterminate = false;
39
-
40
- /**
41
- * Defines whether the checkbox is disabled.
42
- */
43
- @Input({ transform: booleanAttribute }) disabled = false;
44
-
45
- /**
46
- * Event emitted when the checkbox checked state changes.
47
- */
48
- @Output() readonly checkedChange = new EventEmitter<boolean>();
49
-
50
- /**
51
- * Event emitted when the indeterminate state changes.
52
- */
53
- @Output() readonly indeterminateChange = new EventEmitter<boolean>();
54
-
55
- /**
56
- * Determine the state
57
- */
58
- get state(): 'checked' | 'unchecked' | 'indeterminate' {
59
- if (this.indeterminate) {
60
- return 'indeterminate';
61
- }
62
- return this.checked ? 'checked' : 'unchecked';
63
- }
64
-
65
- /**
66
- * Store the callback function that should be called when the checkbox checked state changes.
67
- * @internal
68
- */
69
- private onChange?: (checked: boolean) => void;
70
-
71
- /**
72
- * Store the callback function that should be called when the checkbox is blurred.
73
- * @internal
74
- */
75
- private onTouched?: () => void;
76
-
77
- @HostListener('keydown', ['$event'])
78
- onKeydown(event: KeyboardEvent): void {
79
- // According to WAI ARIA, Checkboxes don't activate on enter keypress
80
- if (event.key === 'Enter') {
81
- event.preventDefault();
82
- }
83
- }
84
-
85
- @HostListener('click')
86
- onClick(): void {
87
- this.checked = this.indeterminate ? true : !this.checked;
88
- this.checkedChange.emit(this.checked);
89
- this.onChange?.(this.checked);
90
-
91
- // if the checkbox was indeterminate, it isn't anymore
92
- if (this.indeterminate) {
93
- this.indeterminate = false;
94
- this.indeterminateChange.emit(this.indeterminate);
95
- }
96
- }
97
-
98
- @HostListener('blur')
99
- onBlur(): void {
100
- this.onTouched?.();
101
- }
102
-
103
- /**
104
- * Sets the checked state of the checkbox.
105
- * @param checked The checked state of the checkbox.
106
- * @internal
107
- */
108
- writeValue(checked: boolean): void {
109
- this.checked = checked;
110
- }
111
-
112
- /**
113
- * Registers a callback function that should be called when the checkbox checked state changes.
114
- * @param fn The callback function.
115
- * @internal
116
- */
117
- registerOnChange(fn: (checked: boolean) => void): void {
118
- this.onChange = fn;
119
- }
120
-
121
- /**
122
- * Registers a callback function that should be called when the checkbox is blurred.
123
- * @param fn The callback function.
124
- * @internal
125
- */
126
- registerOnTouched(fn: () => void): void {
127
- this.onTouched = fn;
128
- }
129
-
130
- /**
131
- * Sets the disabled state of the checkbox.
132
- * @param isDisabled The disabled state of the checkbox.
133
- * @internal
134
- */
135
- setDisabledState(isDisabled: boolean): void {
136
- this.disabled = isDisabled;
137
- }
138
- }
@@ -1,8 +0,0 @@
1
- import { InjectionToken, inject } from '@angular/core';
2
- import type { CheckboxDirective } from './checkbox.directive';
3
-
4
- export const CheckboxToken = new InjectionToken<CheckboxDirective>('CheckboxToken');
5
-
6
- export function injectCheckbox(): CheckboxDirective {
7
- return inject(CheckboxToken);
8
- }
@@ -1,50 +0,0 @@
1
- import { Component } from '@angular/core';
2
- import { CheckboxDirective } from '../src/checkbox.directive';
3
- import { CheckboxIndicatorDirective } from '../src/checkbox-indicator.directive';
4
- import { NgIconComponent, provideIcons } from '@ng-icons/core';
5
- import { lucideCheck } from '@ng-icons/lucide';
6
- import { LabelDirective } from '../../label';
7
- import classNames from 'classnames';
8
- import { NgIf } from '@angular/common';
9
-
10
- @Component({
11
- selector: 'rdx-checkbox',
12
- styleUrls: ['style.css'],
13
- template: `
14
- <div class="radix-themes light-theme">
15
- <label rdxLabel>
16
- <button
17
- class="{{ getClassnames() }}"
18
- data-accent-color
19
- rdxCheckbox
20
- [(checked)]="checked"
21
- >
22
- <ng-icon
23
- color="white"
24
- rdxCheckboxIndicator
25
- class="rt-BaseCheckboxIndicator rt-CheckboxIndicator"
26
- name="lucideCheck"
27
- ></ng-icon>
28
- </button>
29
- Check Item
30
- </label>
31
- </div>
32
- `,
33
- standalone: true,
34
- imports: [NgIf, LabelDirective, CheckboxDirective, CheckboxIndicatorDirective, NgIconComponent],
35
- providers: [provideIcons({ lucideCheck })]
36
- })
37
- export class CheckboxComponent {
38
- checked = false;
39
- isFormControl = false;
40
-
41
- getClassnames(): string {
42
- return classNames(
43
- 'rt-reset',
44
- 'rt-BaseCheckboxRoot',
45
- 'rt-CheckboxRoot',
46
- 'rt-r-size-2',
47
- 'rt-variant-classic'
48
- );
49
- }
50
- }
@@ -1,29 +0,0 @@
1
- import { Meta, moduleMetadata, StoryObj } from '@storybook/angular';
2
- import { CommonModule } from '@angular/common';
3
-
4
- import { CheckboxComponent } from './checkbox.component';
5
- import { BADGE } from '../../.storybook/helpers/bages-config';
6
-
7
- export default {
8
- component: CheckboxComponent,
9
- title: 'Primitives/Checkbox',
10
- parameters: {
11
- badges: [BADGE.SOON]
12
- },
13
- decorators: [
14
- moduleMetadata({
15
- imports: [CheckboxComponent, CommonModule]
16
- })
17
- ]
18
- } as Meta<CheckboxComponent>;
19
-
20
- type Story = StoryObj<CheckboxComponent>;
21
-
22
- export const Default: Story = {
23
- render: () => ({
24
- template: `
25
- <rdx-checkbox></rdx-checkbox>
26
-
27
- `
28
- })
29
- };
@@ -1,265 +0,0 @@
1
-
2
- /*@import "@radix-ui/themes/tokens.css";*/
3
-
4
- @import "@radix-ui/themes/src/components/reset.css";
5
-
6
-
7
- :root, .radix-theme, .light-theme {
8
- --cursor-checkbox: default;
9
- --black-a1: color(display-p3 0 0 0 / 0.05);
10
- --black-a2: color(display-p3 0 0 0 / 0.1);
11
- --black-a3: color(display-p3 0 0 0 / 0.15);
12
- --black-a4: color(display-p3 0 0 0 / 0.2);
13
- --black-a5: color(display-p3 0 0 0 / 0.3);
14
- --black-a6: color(display-p3 0 0 0 / 0.4);
15
- --black-a7: color(display-p3 0 0 0 / 0.5);
16
- --black-a8: color(display-p3 0 0 0 / 0.6);
17
- --black-a9: color(display-p3 0 0 0 / 0.7);
18
- --black-a10: color(display-p3 0 0 0 / 0.8);
19
- --black-a11: color(display-p3 0 0 0 / 0.9);
20
- --black-a12: color(display-p3 0 0 0 / 0.95);
21
- --gray-1: color(display-p3 0.988 0.988 0.988);
22
- --gray-2: color(display-p3 0.975 0.975 0.975);
23
- --gray-3: color(display-p3 0.939 0.939 0.939);
24
- --gray-4: color(display-p3 0.908 0.908 0.908);
25
- --gray-5: color(display-p3 0.88 0.88 0.88);
26
- --gray-6: color(display-p3 0.849 0.849 0.849);
27
- --gray-7: color(display-p3 0.807 0.807 0.807);
28
- --gray-8: color(display-p3 0.732 0.732 0.732);
29
- --gray-9: color(display-p3 0.553 0.553 0.553);
30
- --gray-10: color(display-p3 0.512 0.512 0.512);
31
- --gray-11: color(display-p3 0.392 0.392 0.392);
32
- --gray-12: color(display-p3 0.125 0.125 0.125);
33
- --gray-a1: color(display-p3 0 0 0 / 0.012);
34
- --gray-a2: color(display-p3 0 0 0 / 0.024);
35
- --gray-a3: color(display-p3 0 0 0 / 0.063);
36
- --gray-a4: color(display-p3 0 0 0 / 0.09);
37
- --gray-a5: color(display-p3 0 0 0 / 0.122);
38
- --gray-a6: color(display-p3 0 0 0 / 0.153);
39
- --gray-a7: color(display-p3 0 0 0 / 0.192);
40
- --gray-a8: color(display-p3 0 0 0 / 0.267);
41
- --gray-a9: color(display-p3 0 0 0 / 0.447);
42
- --gray-a10: color(display-p3 0 0 0 / 0.486);
43
- --gray-a11: color(display-p3 0 0 0 / 0.608);
44
- --gray-a12: color(display-p3 0 0 0 / 0.875);
45
- --white-a3: color(display-p3 1 1 1/0.15);
46
- --white-a4: color(display-p3 1 1 1/0.2);
47
- --indigo-8: color(display-p3 0.569 0.639 0.916);
48
- --indigo-9: color(display-p3 0.276 0.384 0.837);
49
- --indigo-indicator: var(--indigo-9);
50
- --accent-indicator: var(--indigo-indicator);
51
- --accent-8: var(--indigo-8);
52
- --focus-8: var(--accent-8);
53
- --scaling: 1;
54
- --space-4: calc(16px * var(--scaling));
55
- --radius-factor: 1;
56
- --radius-1: calc(3px * var(--scaling) * var(--radius-factor));
57
- --color-surface: hsla(0, 0%, 100%, .85);
58
- --shadow-1: inset 0 0 0 1px var(--gray-a5),inset 0 1.5px 2px 0 var(--gray-a2),inset 0 1.5px 2px 0 var(--black-a2);
59
- }
60
-
61
- /***************************************************************************************************
62
- * *
63
- * SIZES *
64
- * *
65
- ***************************************************************************************************/
66
-
67
-
68
- .rt-BaseCheckboxRoot {
69
- &:where(.rt-r-size-1) {
70
- --checkbox-size: calc(var(--space-4) * 0.875);
71
- --checkbox-indicator-size: calc(9px * var(--scaling));
72
- --checkbox-border-radius: calc(var(--radius-1) * 0.875);
73
- }
74
-
75
- &:where(.rt-r-size-2) {
76
- --checkbox-size: var(--space-4);
77
- --checkbox-indicator-size: 15px;
78
- --checkbox-border-radius: var(--radius-1);
79
- }
80
-
81
- &:where(.rt-r-size-3) {
82
- --checkbox-size: calc(var(--space-4) * 1.25);
83
- --checkbox-indicator-size: calc(12px * var(--scaling));
84
- --checkbox-border-radius: calc(var(--radius-1) * 1.25);
85
- }
86
- }
87
-
88
- .rt-BaseCheckboxRoot {
89
- position: relative;
90
- display: inline-flex;
91
- align-items: center;
92
- justify-content: center;
93
- vertical-align: top;
94
- flex-shrink: 0;
95
- cursor: var(--cursor-checkbox);
96
-
97
- /* Unless in a skeleton, align with text line height when possible and fall back to own height */
98
- height: var(--skeleton-height, var(--line-height, var(--checkbox-size)));
99
- --skeleton-height-override: var(--checkbox-size);
100
-
101
- /* Set root radius when in a skeleton */
102
- border-radius: var(--skeleton-radius);
103
- --skeleton-radius-override: var(--checkbox-border-radius);
104
-
105
- &::before {
106
- content: '';
107
- display: block;
108
- height: var(--checkbox-size);
109
- width: var(--checkbox-size);
110
- border-radius: var(--checkbox-border-radius);
111
- }
112
- }
113
-
114
- .rt-BaseCheckboxIndicator {
115
- position: absolute;
116
- width: var(--checkbox-indicator-size);
117
- height: var(--checkbox-indicator-size);
118
-
119
- /* Required for subpixel alignment in Safari */
120
- transform: translate(-50%, -50%);
121
- top: 50%;
122
- left: 50%;
123
- }
124
-
125
-
126
-
127
- /***************************************************************************************************
128
- * *
129
- * VARIANTS *
130
- * *
131
- ***************************************************************************************************/
132
-
133
- /* surface */
134
-
135
- .rt-BaseCheckboxRoot:where(.rt-variant-surface) {
136
- &:where([data-state='unchecked']) {
137
- &::before {
138
- background-color: var(--color-surface);
139
- box-shadow: inset 0 0 0 1px var(--gray-a7);
140
- }
141
- }
142
-
143
- &:where([data-state='checked']) {
144
- &::before {
145
- background-color: var(--accent-indicator);
146
- }
147
-
148
- & :where(.rt-BaseCheckboxIndicator) {
149
- color: var(--accent-contrast);
150
- }
151
-
152
- &:where(.rt-high-contrast) {
153
- &::before {
154
- background-color: var(--accent-12);
155
- }
156
-
157
- & :where(.rt-BaseCheckboxIndicator) {
158
- color: var(--accent-1);
159
- }
160
- }
161
- }
162
-
163
- &:where(:disabled) {
164
- &::before {
165
- box-shadow: inset 0 0 0 1px var(--gray-a6);
166
- background-color: transparent;
167
- }
168
-
169
- & :where(.rt-BaseCheckboxIndicator) {
170
- color: var(--gray-a8);
171
- }
172
- }
173
- }
174
-
175
- /* classic */
176
-
177
- .rt-BaseCheckboxRoot:where(.rt-variant-classic) {
178
- &:where([data-state='unchecked']) {
179
- &::before {
180
- background-color: var(--color-surface);
181
- box-shadow: inset 0 0 0 1px var(--gray-a3), var(--shadow-1);
182
- }
183
- }
184
-
185
- &:where([data-state='checked']) {
186
- &::before {
187
- background-color: var(--accent-indicator);
188
- background-image: linear-gradient(to bottom, var(--white-a3), transparent, var(--black-a1));
189
- box-shadow: inset 0 0.5px 0.5px var(--white-a4), inset 0 -0.5px 0.5px var(--black-a4);
190
- }
191
-
192
- & :where(.rt-BaseCheckboxIndicator) {
193
- color: var(--accent-contrast);
194
- }
195
-
196
- &:where(.rt-high-contrast) {
197
- &::before {
198
- background-color: var(--accent-12);
199
- }
200
-
201
- & :where(.rt-BaseCheckboxIndicator) {
202
- color: var(--accent-1);
203
- }
204
- }
205
- }
206
-
207
- &:where(:disabled) {
208
- &::before {
209
- box-shadow: var(--shadow-1);
210
- background-color: transparent;
211
- background-image: none;
212
- }
213
-
214
- & :where(.rt-BaseCheckboxIndicator) {
215
- color: var(--gray-a8);
216
- }
217
- }
218
- }
219
-
220
- /* soft */
221
-
222
- .rt-BaseCheckboxRoot:where(.rt-variant-soft) {
223
- &::before {
224
- background-color: var(--accent-a5);
225
- }
226
-
227
- &:where([data-state='checked']) {
228
- & :where(.rt-BaseCheckboxIndicator) {
229
- color: var(--accent-a11);
230
- }
231
-
232
- &:where(.rt-high-contrast) {
233
- & :where(.rt-BaseCheckboxIndicator) {
234
- color: var(--accent-12);
235
- }
236
- }
237
- }
238
-
239
- &:where(:disabled) {
240
- &::before {
241
- background-color: transparent;
242
- }
243
-
244
- & :where(.rt-BaseCheckboxIndicator) {
245
- color: var(--gray-a8);
246
- }
247
- }
248
- }
249
-
250
- .rt-CheckboxRoot {
251
- &:where(:focus-visible) {
252
- &::before {
253
- outline: 2px solid var(--focus-8);
254
- outline-offset: 2px;
255
- }
256
- }
257
-
258
- &:where(:disabled) {
259
- cursor: var(--cursor-disabled);
260
-
261
- &::before {
262
- background-color: var(--gray-a3);
263
- }
264
- }
265
- }
package/jest.config.ts DELETED
@@ -1,22 +0,0 @@
1
- /* eslint-disable */
2
- export default {
3
- displayName: 'primitives',
4
- preset: '../../jest.preset.cjs',
5
- setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
6
- coverageDirectory: '../../coverage/packages/primitives',
7
- transform: {
8
- '^.+\\.(ts|mjs|js|html)$': [
9
- 'jest-preset-angular',
10
- {
11
- tsconfig: '<rootDir>/tsconfig.spec.json',
12
- stringifyContentPathRegex: '\\.(html|svg)$'
13
- }
14
- ]
15
- },
16
- transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17
- snapshotSerializers: [
18
- 'jest-preset-angular/build/serializers/no-ng-attributes',
19
- 'jest-preset-angular/build/serializers/ng-snapshot',
20
- 'jest-preset-angular/build/serializers/html-comment'
21
- ]
22
- };
@@ -1,5 +0,0 @@
1
- {
2
- "lib": {
3
- "entryFile": "index.ts"
4
- }
5
- }
@@ -1,36 +0,0 @@
1
- import { Directive, ElementRef, HostListener, Input, Optional } from '@angular/core';
2
-
3
- @Directive({
4
- selector: 'label[rdxLabel]',
5
- standalone: true,
6
- host: {
7
- '[attr.for]': 'htmlFor ? htmlFor : null'
8
- }
9
- })
10
- export class LabelDirective {
11
- /**
12
- * The id of the element the label is associated with.
13
- * @default '-'
14
- */
15
- @Input() htmlFor = '';
16
-
17
- constructor(@Optional() private el: ElementRef) {}
18
-
19
- // prevent text selection when double-clicking label
20
- // The main problem with double-clicks in a web app is that
21
- // you will have to create special code to handle this on touch enabled devices.
22
- @HostListener('mousedown', ['$event'])
23
- onMouseDown(event: MouseEvent): void {
24
- const target = event.target as HTMLElement;
25
-
26
- // only prevent text selection if clicking inside the label itself
27
- if (['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'].includes(target.tagName)) {
28
- return;
29
- }
30
-
31
- // prevent text selection when double-clicking label
32
- if (this.el.nativeElement.contains(target) && !event.defaultPrevented && event.detail > 1) {
33
- event.preventDefault();
34
- }
35
- }
36
- }
@@ -1,40 +0,0 @@
1
- import { ArgTypes, Canvas, Meta } from '@storybook/addon-docs';
2
- import * as LabelDirectiveStories from "./label.stories";
3
- import { LabelDirective } from '../src/label.directive';
4
-
5
- <Meta
6
- title="Primitives/Label"
7
- />
8
-
9
- # Label
10
- #### Renders an accessible label associated with controls.
11
-
12
- <Canvas sourceState='hidden' of={LabelDirectiveStories.Default}></Canvas>
13
-
14
- ## Features
15
- - ✅ Text selection is prevented when double-clicking label.
16
-
17
- ## Import
18
-
19
- Get started with importing the directive:
20
-
21
- ```typescript
22
- import { LabelDirective } from '@radix-ng/primitives/label';
23
- ```
24
-
25
- ## Examples
26
-
27
- ```html
28
- <label rdxLabel htmlFor="uniqId">First name</label>
29
- <input type="text" class="Input" id="uniqId" />
30
-
31
- ```
32
- ## API Reference
33
-
34
- <ArgTypes exclude={['onMouseDown']} of={LabelDirective} />
35
-
36
- ## Accessibility
37
-
38
- This component is based on the native `label` element, it will automatically apply the correct labelling
39
- when wrapping controls or using the `for` attribute. For your own custom controls
40
- to work correctly, ensure they use native elements such as `button` or `input` as a base.
@@ -1,63 +0,0 @@
1
- import { Meta, moduleMetadata, StoryObj } from '@storybook/angular';
2
- import { LabelDirective } from '../src/label.directive';
3
- import { CommonModule } from '@angular/common';
4
- import { labelExclude } from '../../.docs/utils/storybook';
5
-
6
- export default {
7
- component: LabelDirective,
8
- title: 'Primitives/Label',
9
- parameters: {
10
- controls: {
11
- exclude: labelExclude
12
- }
13
- },
14
- decorators: [
15
- moduleMetadata({
16
- imports: [LabelDirective, CommonModule]
17
- })
18
- ]
19
- } as Meta<LabelDirective>;
20
-
21
- type Story = StoryObj<LabelDirective>;
22
-
23
- export const Default: Story = {
24
- render: (args) => ({
25
- props: {
26
- ...args
27
- },
28
- template: `
29
- <style>
30
- input {
31
- all: unset;
32
- }
33
-
34
- .Input {
35
- width: 200px;
36
- display: inline-flex;
37
- align-items: center;
38
- justify-content: center;
39
- border-radius: 4px;
40
- padding: 0 10px;
41
- margin-left: 10px;
42
- height: 35px;
43
- font-size: 15px;
44
- line-height: 1;
45
- color: white;
46
- background-color: color(display-p3 0 0 0/0.3);
47
- box-shadow: 0 0 0 1px color(display-p3 0 0 0/0.7);
48
- }
49
-
50
- label {
51
- color: white;
52
- font-size: 15px;
53
- line-height: 35px;
54
- font-weight: 500;
55
- }
56
- </style>
57
-
58
- <label rdxLabel htmlFor="uniqId">First Name </label>
59
- <input type="text" class="Input" id="uniqId" />
60
-
61
- `
62
- })
63
- };
package/ng-package.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/primitives",
4
- "lib": {
5
- "entryFile": "index.ts"
6
- }
7
- }
@@ -1,5 +0,0 @@
1
- {
2
- "lib": {
3
- "entryFile": "index.ts"
4
- }
5
- }
@@ -1,15 +0,0 @@
1
- import { Directive } from '@angular/core';
2
- import { injectProgress } from './progress.token';
3
-
4
- @Directive({
5
- selector: '[rdxProgressIndicator]',
6
- standalone: true,
7
- host: {
8
- '[attr.data-state]': 'progress.state',
9
- '[attr.data-value]': 'progress.value',
10
- '[attr.data-max]': 'progress.max'
11
- }
12
- })
13
- export class ProgressIndicatorDirective {
14
- protected readonly progress = injectProgress();
15
- }