@design-system-rte/angular 0.4.3 → 0.4.5

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 (84) hide show
  1. package/esm2022/design-system-rte-angular.mjs +5 -0
  2. package/esm2022/lib/components/button/button.component.mjs +26 -0
  3. package/esm2022/lib/components/checkbox/checkbox.component.mjs +35 -0
  4. package/esm2022/lib/components/checkbox-group/checkbox-group.component.mjs +29 -0
  5. package/esm2022/lib/components/grid/col/col.directive.mjs +41 -0
  6. package/esm2022/lib/components/grid/grid.directive.mjs +30 -0
  7. package/esm2022/lib/components/icon/icon-map.mjs +303 -0
  8. package/esm2022/lib/components/icon/icon.component.mjs +39 -0
  9. package/esm2022/lib/components/icon/icon.service.mjs +33 -0
  10. package/esm2022/lib/components/link/link.component.mjs +20 -0
  11. package/esm2022/lib/components/radio-button/radio-button.component.mjs +24 -0
  12. package/esm2022/lib/components/radio-button-group/radio-button-group.component.mjs +29 -0
  13. package/esm2022/public-api.mjs +10 -0
  14. package/fesm2022/design-system-rte-angular.mjs +583 -0
  15. package/fesm2022/design-system-rte-angular.mjs.map +1 -0
  16. package/index.d.ts +5 -0
  17. package/lib/components/button/button.component.d.ts +17 -0
  18. package/lib/components/checkbox/checkbox.component.d.ts +18 -0
  19. package/lib/components/checkbox-group/checkbox-group.component.d.ts +18 -0
  20. package/lib/components/grid/col/col.directive.d.ts +14 -0
  21. package/lib/components/grid/grid.directive.d.ts +10 -0
  22. package/lib/components/icon/icon-map.d.ts +301 -0
  23. package/lib/components/icon/icon.component.d.ts +21 -0
  24. package/lib/components/icon/icon.service.d.ts +11 -0
  25. package/lib/components/link/link.component.d.ts +9 -0
  26. package/lib/components/radio-button/radio-button.component.d.ts +13 -0
  27. package/lib/components/radio-button-group/radio-button-group.component.d.ts +18 -0
  28. package/package.json +16 -2
  29. package/CHANGELOG.md +0 -19
  30. package/ng-package.json +0 -10
  31. package/src/lib/components/button/button.component.html +0 -10
  32. package/src/lib/components/button/button.component.scss +0 -154
  33. package/src/lib/components/button/button.component.spec.ts +0 -22
  34. package/src/lib/components/button/button.component.stories.ts +0 -99
  35. package/src/lib/components/button/button.component.ts +0 -28
  36. package/src/lib/components/checkbox/checkbox.component.html +0 -31
  37. package/src/lib/components/checkbox/checkbox.component.scss +0 -176
  38. package/src/lib/components/checkbox/checkbox.component.stories.ts +0 -126
  39. package/src/lib/components/checkbox/checkbox.component.ts +0 -34
  40. package/src/lib/components/checkbox-group/checkbox-group.component.html +0 -46
  41. package/src/lib/components/checkbox-group/checkbox-group.component.scss +0 -82
  42. package/src/lib/components/checkbox-group/checkbox-group.component.stories.ts +0 -121
  43. package/src/lib/components/checkbox-group/checkbox-group.component.ts +0 -28
  44. package/src/lib/components/grid/col/col.directive.ts +0 -35
  45. package/src/lib/components/grid/grid.directive.stories.ts +0 -150
  46. package/src/lib/components/grid/grid.directive.ts +0 -22
  47. package/src/lib/components/icon/icon-map.ts +0 -305
  48. package/src/lib/components/icon/icon.component.html +0 -1
  49. package/src/lib/components/icon/icon.component.scss +0 -3
  50. package/src/lib/components/icon/icon.component.ts +0 -58
  51. package/src/lib/components/icon/icon.service.ts +0 -33
  52. package/src/lib/components/icon/icon.stories.ts +0 -84
  53. package/src/lib/components/icon-button/icon-button.component.html +0 -16
  54. package/src/lib/components/icon-button/icon-button.component.scss +0 -165
  55. package/src/lib/components/icon-button/icon-button.component.ts +0 -40
  56. package/src/lib/components/icon-button/icon-button.stories.ts +0 -200
  57. package/src/lib/components/icon-button-toggle/icon-button-toggle.component.html +0 -12
  58. package/src/lib/components/icon-button-toggle/icon-button-toggle.component.ts +0 -36
  59. package/src/lib/components/icon-button-toggle/icon-button-toggle.stories.ts +0 -197
  60. package/src/lib/components/link/link.component.html +0 -6
  61. package/src/lib/components/link/link.component.scss +0 -108
  62. package/src/lib/components/link/link.component.stories.ts +0 -61
  63. package/src/lib/components/link/link.component.ts +0 -18
  64. package/src/lib/components/radio-button/radio-button.component.html +0 -24
  65. package/src/lib/components/radio-button/radio-button.component.scss +0 -135
  66. package/src/lib/components/radio-button/radio-button.component.stories.ts +0 -76
  67. package/src/lib/components/radio-button/radio-button.component.ts +0 -22
  68. package/src/lib/components/radio-button-group/radio-button-group.component.html +0 -45
  69. package/src/lib/components/radio-button-group/radio-button-group.component.scss +0 -82
  70. package/src/lib/components/radio-button-group/radio-button-group.component.stories.ts +0 -121
  71. package/src/lib/components/radio-button-group/radio-button-group.component.ts +0 -28
  72. package/src/lib/components/split-button/split-button.component.html +0 -56
  73. package/src/lib/components/split-button/split-button.component.scss +0 -288
  74. package/src/lib/components/split-button/split-button.component.stories.ts +0 -227
  75. package/src/lib/components/split-button/split-button.component.ts +0 -55
  76. package/src/lib/components/tooltip/tooltip.component.html +0 -7
  77. package/src/lib/components/tooltip/tooltip.component.scss +0 -116
  78. package/src/lib/components/tooltip/tooltip.component.ts +0 -16
  79. package/src/lib/components/tooltip/tooltip.directive.stories.ts +0 -218
  80. package/src/lib/components/tooltip/tooltip.directive.ts +0 -187
  81. package/tsconfig.lib.json +0 -20
  82. package/tsconfig.lib.prod.json +0 -10
  83. package/tsconfig.spec.json +0 -14
  84. /package/{src/public-api.ts → public-api.d.ts} +0 -0
@@ -1,218 +0,0 @@
1
- import { TAB_KEY } from "@design-system-rte/core/constants/keyboard.constants";
2
- import { Meta, StoryObj } from "@storybook/angular";
3
- import { within, userEvent, expect, waitFor } from "@storybook/test";
4
-
5
- import { TooltipDirective } from "./tooltip.directive";
6
-
7
- const meta: Meta<TooltipDirective> = {
8
- title: "Tooltip",
9
- component: TooltipDirective,
10
- tags: ["autodocs"],
11
- argTypes: {
12
- rteTooltip: {
13
- control: "text",
14
- defaultValue: "Tooltip Text",
15
- },
16
- rteTooltipPosition: {
17
- control: "select",
18
- options: ["auto", "top", "bottom", "left", "right"],
19
- defaultValue: "top",
20
- },
21
- rteTooltipAlignment: {
22
- control: "select",
23
- options: ["start", "center", "end"],
24
- defaultValue: "center",
25
- },
26
- rteTooltipArrow: {
27
- control: "boolean",
28
- defaultValue: true,
29
- },
30
- },
31
- parameters: {
32
- layout: "centered",
33
- },
34
- };
35
- export default meta;
36
- type Story = StoryObj<TooltipDirective>;
37
-
38
- const mockHost = (tooltipDirectives: string) => `
39
- <div style="
40
- text-decoration: underline;
41
- text-decoration-color: #BF4C00;
42
- text-decoration-thickness: 2px;
43
- text-underline-offset: 4px;
44
- color: #BF4C00;
45
- font-weight: bold;
46
- "
47
- ${tooltipDirectives}
48
- >
49
- Hover Me!
50
- </div>
51
- `;
52
-
53
- export const Default: Story = {
54
- args: {
55
- rteTooltip: "Tooltip",
56
- rteTooltipPosition: "top",
57
- rteTooltipAlignment: "center",
58
- rteTooltipArrow: true,
59
- },
60
- render: (args) => ({
61
- props: args,
62
- declarations: [TooltipDirective],
63
- template: mockHost(`
64
- [rteTooltip]="rteTooltip"
65
- [rteTooltipPosition]="rteTooltipPosition"
66
- [rteTooltipAlignment]="rteTooltipAlignment"
67
- [rteTooltipArrow]="rteTooltipArrow"
68
- `),
69
- }),
70
- };
71
-
72
- export const Position: Story = {
73
- args: Default.args,
74
- render: (args) => ({
75
- props: args,
76
- declarations: [TooltipDirective],
77
- template: `
78
- <div style="display: flex; flex-direction: column; align-items: center; gap: 16px;">
79
- ${mockHost(`
80
- rteTooltipPosition="top"
81
- [rteTooltip]="rteTooltip"
82
- [rteTooltipAlignment]="rteTooltipAlignment"
83
- [rteTooltipArrow]="rteTooltipArrow"
84
- `)}
85
- ${mockHost(`
86
- rteTooltipPosition="bottom"
87
- [rteTooltip]="rteTooltip"
88
- [rteTooltipAlignment]="rteTooltipAlignment"
89
- [rteTooltipArrow]="rteTooltipArrow"
90
- `)}
91
- ${mockHost(`
92
- rteTooltipPosition="left"
93
- [rteTooltip]="rteTooltip"
94
- [rteTooltipAlignment]="rteTooltipAlignment"
95
- [rteTooltipArrow]="rteTooltipArrow"
96
- `)}
97
- ${mockHost(`
98
- rteTooltipPosition="right"
99
- [rteTooltip]="rteTooltip"
100
- [rteTooltipAlignment]="rteTooltipAlignment"
101
- [rteTooltipArrow]="rteTooltipArrow"
102
- `)}
103
- </div>
104
- `,
105
- }),
106
- };
107
-
108
- export const Alignment: Story = {
109
- args: Default.args,
110
- render: (args) => ({
111
- props: args,
112
- declarations: [TooltipDirective],
113
- template: `
114
- <div style="display: flex; flex-direction: column; align-items: center; gap: 16px;">
115
- ${mockHost(`
116
- rteTooltipAlignment="start"
117
- [rteTooltipPosition]="rteTooltipPosition"
118
- [rteTooltip]="rteTooltip"
119
- [rteTooltipArrow]="rteTooltipArrow"
120
- `)}
121
- ${mockHost(`
122
- rteTooltipAlignment="center"
123
- [rteTooltipPosition]="rteTooltipPosition"
124
- [rteTooltip]="rteTooltip"
125
- [rteTooltipArrow]="rteTooltipArrow"
126
- `)}
127
- ${mockHost(`
128
- rteTooltipAlignment="end"
129
- [rteTooltipPosition]="rteTooltipPosition"
130
- [rteTooltip]="rteTooltip"
131
- [rteTooltipArrow]="rteTooltipArrow"
132
- `)}
133
- </div>
134
- `,
135
- }),
136
- };
137
-
138
- export const Arrow: Story = {
139
- args: Default.args,
140
- render: (args) => ({
141
- props: args,
142
- declarations: [TooltipDirective],
143
- template: `
144
- <div style="display: flex; gap: 8;">
145
- ${mockHost(`
146
- [rteTooltipArrow]="true"
147
- [rteTooltipPosition]="rteTooltipPosition"
148
- [rteTooltip]="rteTooltip"
149
- `)}
150
- ${mockHost(`
151
- [rteTooltipArrow]="false"
152
- [rteTooltipPosition]="rteTooltipPosition"
153
- [rteTooltip]="rteTooltip"
154
- `)}
155
- </div>
156
- `,
157
- }),
158
- };
159
-
160
- export const AutoPlacement: Story = {
161
- args: Default.args,
162
- render: (args) => ({
163
- props: args,
164
- declarations: [TooltipDirective],
165
- template: `
166
- <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px;">
167
- <div style="display: flex; align-items: flex-start; justify-content: flex-start; gap: 8px; border: 1px solid red; width: 75px; height: 250px;">
168
- ${mockHost(`
169
- rteTooltipPosition="auto"
170
- [rteTooltip]="rteTooltip"
171
- `)}
172
- </div>
173
-
174
- <div style="display: flex; align-items: center; justify-content: flex-start; gap: 8px; border: 1px solid red; width: 250px; height: 50px;">
175
- ${mockHost(`
176
- rteTooltipPosition="auto"
177
- [rteTooltip]="rteTooltip"
178
- `)}
179
- </div>
180
-
181
- <div style="display: flex; align-items: flex-end; justify-content: flex-end; gap: 8px; border: 1px solid red; width: 75px; height: 250px;">
182
- ${mockHost(`
183
- rteTooltipPosition="auto"
184
- [rteTooltip]="rteTooltip"
185
- `)}
186
- </div>
187
-
188
- <div style="display: flex; align-items: center; justify-content: flex-end; gap: 8px; border: 1px solid red; width: 250px; height: 50px;">
189
- ${mockHost(`
190
- rteTooltipPosition="auto"
191
- [rteTooltip]="rteTooltip"
192
- `)}
193
- </div>
194
- </div>
195
- `,
196
- }),
197
- };
198
-
199
- export const KeyboardInteraction: Story = {
200
- args: Default.args,
201
- render: (args) => ({
202
- props: args,
203
- declarations: [TooltipDirective],
204
- template: `
205
- <div style="display: flex; gap: 8px;">
206
- ${mockHost(`[rteTooltip]="rteTooltip"`)}
207
- </div>
208
- `,
209
- }),
210
- play: async ({ canvasElement }) => {
211
- const canvas = within(canvasElement);
212
- const tooltipHost = canvas.getByText("Hover Me!");
213
- await userEvent.keyboard(TAB_KEY);
214
- const tooltip = await canvas.findByRole("tooltip");
215
- expect(tooltipHost).toHaveFocus();
216
- await waitFor(() => expect(tooltip).toBeVisible());
217
- },
218
- };
@@ -1,187 +0,0 @@
1
- import {
2
- ChangeDetectorRef,
3
- ComponentRef,
4
- Directive,
5
- ElementRef,
6
- HostListener,
7
- inject,
8
- input,
9
- Renderer2,
10
- ViewContainerRef,
11
- } from "@angular/core";
12
- import { getAutoPlacement } from "@design-system-rte/core/components/utils/auto-placement";
13
-
14
- import { TooltipComponent } from "./tooltip.component";
15
-
16
- interface TooltipXBound {
17
- position: "left" | "right";
18
- offset: number;
19
- }
20
-
21
- interface TooltipYBound {
22
- position: "top" | "bottom";
23
- offset: number;
24
- }
25
-
26
- interface TooltipBounds {
27
- x: TooltipXBound;
28
- y: TooltipYBound;
29
- }
30
-
31
- const TOOLTIP_GAP = 8;
32
-
33
- @Directive({
34
- selector: "[rteTooltip]",
35
- standalone: true,
36
- })
37
- export class TooltipDirective {
38
- readonly rteTooltip = input.required<string>();
39
- readonly rteTooltipPosition = input("auto");
40
- readonly rteTooltipAlignment = input("center");
41
- readonly rteTooltipArrow = input(true);
42
-
43
- private tooltipRef: ComponentRef<TooltipComponent> | null = null;
44
- private hostElement: HTMLElement;
45
-
46
- private elementRef = inject(ElementRef);
47
- private viewContainerRef = inject(ViewContainerRef);
48
- private renderer = inject(Renderer2);
49
- private cdr = inject(ChangeDetectorRef);
50
-
51
- @HostListener("mouseenter")
52
- onMouseEnter(): void {
53
- this.showTooltip();
54
- }
55
-
56
- @HostListener("mouseleave")
57
- onMouseLeave(): void {
58
- this.hideTooltip();
59
- }
60
-
61
- @HostListener("focus")
62
- onFocus(): void {
63
- this.showTooltip();
64
- }
65
-
66
- @HostListener("blur")
67
- onBlur(): void {
68
- this.hideTooltip();
69
- }
70
-
71
- constructor() {
72
- this.hostElement = this.elementRef.nativeElement;
73
- this.hostElement.setAttribute("tabindex", "0");
74
- }
75
-
76
- showTooltip(): void {
77
- if (this.tooltipRef) {
78
- this.tooltipRef.destroy();
79
- }
80
-
81
- this.tooltipRef = this.viewContainerRef.createComponent(TooltipComponent);
82
- this.assignDirectiveToComponent();
83
- this.appendComponentToHost();
84
- this.cdr.detectChanges();
85
-
86
- if (this.tooltipRef) {
87
- const tooltipElement = this.tooltipRef.location.nativeElement;
88
- this.renderer.setStyle(tooltipElement, "opacity", "0");
89
- this.positionTooltip();
90
-
91
- this.renderer.setStyle(tooltipElement, "opacity", "1");
92
- }
93
- }
94
-
95
- private assignDirectiveToComponent(): void {
96
- if (this.tooltipRef) {
97
- const tooltipElement = this.tooltipRef.location.nativeElement;
98
- const position =
99
- this.rteTooltipPosition() === "auto"
100
- ? getAutoPlacement(this.hostElement, tooltipElement, "top")
101
- : this.rteTooltipPosition();
102
-
103
- this.tooltipRef.setInput("label", this.rteTooltip());
104
- this.tooltipRef.setInput("position", position);
105
- this.tooltipRef.setInput("alignment", this.rteTooltipAlignment());
106
- this.tooltipRef.setInput("arrow", this.rteTooltipArrow());
107
- }
108
- }
109
-
110
- private appendComponentToHost(): void {
111
- if (this.tooltipRef) {
112
- this.renderer.appendChild(this.elementRef.nativeElement, this.tooltipRef.location.nativeElement);
113
- }
114
- }
115
-
116
- private positionTooltip(): void {
117
- if (this.tooltipRef) {
118
- const tooltipElement = this.tooltipRef.location.nativeElement;
119
-
120
- const bounds = this.getTooltipPosition(this.hostElement, this.tooltipRef);
121
-
122
- this.renderer.setStyle(this.hostElement, "position", "relative");
123
-
124
- this.renderer.setStyle(tooltipElement, bounds.x.position, `${bounds.x.offset}px`);
125
- this.renderer.setStyle(tooltipElement, bounds.y.position, `${bounds.y.offset}px`);
126
- }
127
- }
128
-
129
- private getTooltipPosition(host: HTMLElement, tooltip: ComponentRef<TooltipComponent>): TooltipBounds {
130
- return {
131
- x: this.getTooltipXBound(host, tooltip),
132
- y: this.getTooltipYBound(host, tooltip),
133
- };
134
- }
135
-
136
- private getTooltipXBound(host: HTMLElement, tooltip: ComponentRef<TooltipComponent>): TooltipXBound {
137
- return {
138
- position: tooltip.instance.position() === "right" ? "right" : "left",
139
- offset: this.getTooltipXOffset(host, tooltip),
140
- };
141
- }
142
-
143
- private getTooltipXOffset(host: HTMLElement, tooltip: ComponentRef<TooltipComponent>): number {
144
- const hostRect = host.getBoundingClientRect();
145
- if (tooltip.instance.position() === "left") {
146
- return -tooltip.location.nativeElement.querySelector(".tooltip").offsetWidth - TOOLTIP_GAP;
147
- }
148
- if (tooltip.instance.position() === "right") {
149
- return -TOOLTIP_GAP;
150
- }
151
- return hostRect.width / 2;
152
- }
153
-
154
- private getTooltipYBound(host: HTMLElement, tooltip: ComponentRef<TooltipComponent>): TooltipYBound {
155
- return {
156
- position: tooltip.instance.position() === "bottom" ? "bottom" : "top",
157
- offset: this.getTooltipYOffset(host, tooltip),
158
- };
159
- }
160
-
161
- private getTooltipYOffset(host: HTMLElement, tooltip: ComponentRef<TooltipComponent>): number {
162
- const hostRect = host.getBoundingClientRect();
163
-
164
- if (tooltip.instance.position() === "top") {
165
- return -tooltip.location.nativeElement.querySelector(".tooltip").offsetHeight - TOOLTIP_GAP;
166
- }
167
- if (tooltip.instance.position() === "bottom") {
168
- return -TOOLTIP_GAP;
169
- }
170
- return hostRect.height / 2;
171
- }
172
-
173
- private hideTooltip(): void {
174
- if (this.tooltipRef) {
175
- const tooltipElement = this.tooltipRef.location.nativeElement;
176
-
177
- this.renderer.setStyle(tooltipElement, "opacity", "0");
178
-
179
- setTimeout(() => {
180
- if (this.tooltipRef) {
181
- this.tooltipRef.destroy();
182
- this.tooltipRef = null;
183
- }
184
- }, 200);
185
- }
186
- }
187
- }
package/tsconfig.lib.json DELETED
@@ -1,20 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "../../tsconfig.json",
4
- "compilerOptions": {
5
- "outDir": "../../out-tsc/lib",
6
- "declaration": true,
7
- "types": []
8
- },
9
- "angularCompilerOptions": {
10
- "compilationMode": "partial"
11
- },
12
- "exclude": [
13
- "**/*.spec.ts"
14
- ],
15
- "files": ["typings.d.ts"],
16
- "include": [
17
- "src/**/*.ts",
18
- "src/types.d.ts"
19
- ]
20
- }
@@ -1,10 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "./tsconfig.lib.json",
4
- "compilerOptions": {
5
- "declarationMap": false
6
- },
7
- "angularCompilerOptions": {
8
- "compilationMode": "partial"
9
- }
10
- }
@@ -1,14 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "../../tsconfig.json",
4
- "compilerOptions": {
5
- "outDir": "../../out-tsc/spec",
6
- "types": [
7
- "jasmine"
8
- ]
9
- },
10
- "include": [
11
- "**/*.spec.ts",
12
- "**/*.d.ts"
13
- ]
14
- }
File without changes