@ship-ui/core 0.19.5 → 0.22.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.
Files changed (153) hide show
  1. package/README.md +3 -0
  2. package/assets/mcp/components.json +66 -4243
  3. package/bin/mcp/index.js +6027 -273
  4. package/bin/ship-fg-scanner +0 -0
  5. package/bin/ship-fg.mjs +14 -12
  6. package/bin/src/subset.ts +3 -1
  7. package/fesm2022/ship-ui-core-sh-form-field-experimental.mjs +42 -0
  8. package/fesm2022/ship-ui-core-sh-form-field-experimental.mjs.map +1 -0
  9. package/fesm2022/ship-ui-core-ship-accordion.mjs +127 -0
  10. package/fesm2022/ship-ui-core-ship-accordion.mjs.map +1 -0
  11. package/fesm2022/ship-ui-core-ship-alert.mjs +305 -0
  12. package/fesm2022/ship-ui-core-ship-alert.mjs.map +1 -0
  13. package/fesm2022/ship-ui-core-ship-blueprint.mjs +1156 -0
  14. package/fesm2022/ship-ui-core-ship-blueprint.mjs.map +1 -0
  15. package/fesm2022/ship-ui-core-ship-button-group.mjs +41 -0
  16. package/fesm2022/ship-ui-core-ship-button-group.mjs.map +1 -0
  17. package/fesm2022/ship-ui-core-ship-button.mjs +38 -0
  18. package/fesm2022/ship-ui-core-ship-button.mjs.map +1 -0
  19. package/fesm2022/ship-ui-core-ship-card.mjs +35 -0
  20. package/fesm2022/ship-ui-core-ship-card.mjs.map +1 -0
  21. package/fesm2022/ship-ui-core-ship-checkbox.mjs +113 -0
  22. package/fesm2022/ship-ui-core-ship-checkbox.mjs.map +1 -0
  23. package/fesm2022/ship-ui-core-ship-chip.mjs +44 -0
  24. package/fesm2022/ship-ui-core-ship-chip.mjs.map +1 -0
  25. package/fesm2022/ship-ui-core-ship-color-picker.mjs +947 -0
  26. package/fesm2022/ship-ui-core-ship-color-picker.mjs.map +1 -0
  27. package/fesm2022/ship-ui-core-ship-datepicker.mjs +951 -0
  28. package/fesm2022/ship-ui-core-ship-datepicker.mjs.map +1 -0
  29. package/fesm2022/ship-ui-core-ship-dialog.mjs +263 -0
  30. package/fesm2022/ship-ui-core-ship-dialog.mjs.map +1 -0
  31. package/fesm2022/ship-ui-core-ship-divider.mjs +22 -0
  32. package/fesm2022/ship-ui-core-ship-divider.mjs.map +1 -0
  33. package/fesm2022/ship-ui-core-ship-event-card.mjs +50 -0
  34. package/fesm2022/ship-ui-core-ship-event-card.mjs.map +1 -0
  35. package/fesm2022/ship-ui-core-ship-file-upload.mjs +112 -0
  36. package/fesm2022/ship-ui-core-ship-file-upload.mjs.map +1 -0
  37. package/fesm2022/ship-ui-core-ship-form-field.mjs +310 -0
  38. package/fesm2022/ship-ui-core-ship-form-field.mjs.map +1 -0
  39. package/fesm2022/ship-ui-core-ship-icon.mjs +81 -0
  40. package/fesm2022/ship-ui-core-ship-icon.mjs.map +1 -0
  41. package/fesm2022/ship-ui-core-ship-list.mjs +22 -0
  42. package/fesm2022/ship-ui-core-ship-list.mjs.map +1 -0
  43. package/fesm2022/ship-ui-core-ship-menu.mjs +545 -0
  44. package/fesm2022/ship-ui-core-ship-menu.mjs.map +1 -0
  45. package/fesm2022/ship-ui-core-ship-popover.mjs +286 -0
  46. package/fesm2022/ship-ui-core-ship-popover.mjs.map +1 -0
  47. package/fesm2022/ship-ui-core-ship-progress-bar.mjs +37 -0
  48. package/fesm2022/ship-ui-core-ship-progress-bar.mjs.map +1 -0
  49. package/fesm2022/ship-ui-core-ship-radio.mjs +102 -0
  50. package/fesm2022/ship-ui-core-ship-radio.mjs.map +1 -0
  51. package/fesm2022/ship-ui-core-ship-range-slider.mjs +277 -0
  52. package/fesm2022/ship-ui-core-ship-range-slider.mjs.map +1 -0
  53. package/fesm2022/ship-ui-core-ship-select.mjs +971 -0
  54. package/fesm2022/ship-ui-core-ship-select.mjs.map +1 -0
  55. package/fesm2022/ship-ui-core-ship-sidenav.mjs +248 -0
  56. package/fesm2022/ship-ui-core-ship-sidenav.mjs.map +1 -0
  57. package/fesm2022/ship-ui-core-ship-sortable.mjs +485 -0
  58. package/fesm2022/ship-ui-core-ship-sortable.mjs.map +1 -0
  59. package/fesm2022/ship-ui-core-ship-spinner.mjs +28 -0
  60. package/fesm2022/ship-ui-core-ship-spinner.mjs.map +1 -0
  61. package/fesm2022/ship-ui-core-ship-stepper.mjs +76 -0
  62. package/fesm2022/ship-ui-core-ship-stepper.mjs.map +1 -0
  63. package/fesm2022/ship-ui-core-ship-table-filter-bar.mjs +28 -0
  64. package/fesm2022/ship-ui-core-ship-table-filter-bar.mjs.map +1 -0
  65. package/fesm2022/ship-ui-core-ship-table.mjs +442 -0
  66. package/fesm2022/ship-ui-core-ship-table.mjs.map +1 -0
  67. package/fesm2022/ship-ui-core-ship-tabs.mjs +38 -0
  68. package/fesm2022/ship-ui-core-ship-tabs.mjs.map +1 -0
  69. package/fesm2022/ship-ui-core-ship-theme-toggle.mjs +119 -0
  70. package/fesm2022/ship-ui-core-ship-theme-toggle.mjs.map +1 -0
  71. package/fesm2022/ship-ui-core-ship-toggle-card.mjs +75 -0
  72. package/fesm2022/ship-ui-core-ship-toggle-card.mjs.map +1 -0
  73. package/fesm2022/ship-ui-core-ship-toggle.mjs +105 -0
  74. package/fesm2022/ship-ui-core-ship-toggle.mjs.map +1 -0
  75. package/fesm2022/ship-ui-core-ship-virtual-scroll.mjs +186 -0
  76. package/fesm2022/ship-ui-core-ship-virtual-scroll.mjs.map +1 -0
  77. package/fesm2022/ship-ui-core.mjs +880 -8782
  78. package/fesm2022/ship-ui-core.mjs.map +1 -1
  79. package/package.json +147 -3
  80. package/styles/core.scss +43 -0
  81. package/styles/helpers.scss +2 -0
  82. package/styles/index.scss +12 -123
  83. package/types/ship-ui-core-sh-form-field-experimental.d.ts +11 -0
  84. package/types/ship-ui-core-ship-accordion.d.ts +19 -0
  85. package/types/ship-ui-core-ship-alert.d.ts +68 -0
  86. package/types/ship-ui-core-ship-blueprint.d.ts +112 -0
  87. package/types/ship-ui-core-ship-button-group.d.ts +15 -0
  88. package/types/ship-ui-core-ship-button.d.ts +13 -0
  89. package/types/ship-ui-core-ship-card.d.ts +11 -0
  90. package/types/ship-ui-core-ship-checkbox.d.ts +22 -0
  91. package/types/ship-ui-core-ship-chip.d.ts +15 -0
  92. package/types/ship-ui-core-ship-color-picker.d.ts +105 -0
  93. package/types/ship-ui-core-ship-datepicker.d.ts +96 -0
  94. package/types/ship-ui-core-ship-dialog.d.ts +76 -0
  95. package/types/ship-ui-core-ship-divider.d.ts +8 -0
  96. package/types/ship-ui-core-ship-event-card.d.ts +11 -0
  97. package/types/ship-ui-core-ship-file-upload.d.ts +20 -0
  98. package/types/ship-ui-core-ship-form-field.d.ts +32 -0
  99. package/types/ship-ui-core-ship-icon.d.ts +18 -0
  100. package/types/ship-ui-core-ship-list.d.ts +8 -0
  101. package/types/ship-ui-core-ship-menu.d.ts +49 -0
  102. package/types/ship-ui-core-ship-popover.d.ts +40 -0
  103. package/types/ship-ui-core-ship-progress-bar.d.ts +14 -0
  104. package/types/ship-ui-core-ship-radio.d.ts +22 -0
  105. package/types/ship-ui-core-ship-range-slider.d.ts +31 -0
  106. package/types/ship-ui-core-ship-select.d.ts +81 -0
  107. package/types/ship-ui-core-ship-sidenav.d.ts +36 -0
  108. package/types/ship-ui-core-ship-sortable.d.ts +72 -0
  109. package/types/ship-ui-core-ship-spinner.d.ts +10 -0
  110. package/types/ship-ui-core-ship-stepper.d.ts +13 -0
  111. package/types/ship-ui-core-ship-table-filter-bar.d.ts +8 -0
  112. package/types/ship-ui-core-ship-table.d.ts +69 -0
  113. package/types/ship-ui-core-ship-tabs.d.ts +14 -0
  114. package/types/ship-ui-core-ship-theme-toggle.d.ts +28 -0
  115. package/types/ship-ui-core-ship-toggle-card.d.ts +15 -0
  116. package/types/ship-ui-core-ship-toggle.d.ts +21 -0
  117. package/types/ship-ui-core-ship-virtual-scroll.d.ts +22 -0
  118. package/types/ship-ui-core.d.ts +88 -1070
  119. package/styles/components/ship-accordion.scss +0 -113
  120. package/styles/components/ship-alert-container.scss +0 -49
  121. package/styles/components/ship-alert.scss +0 -177
  122. package/styles/components/ship-blueprint.scss +0 -242
  123. package/styles/components/ship-button-group.scss +0 -165
  124. package/styles/components/ship-button.scss +0 -141
  125. package/styles/components/ship-card.scss +0 -57
  126. package/styles/components/ship-checkbox.scss +0 -116
  127. package/styles/components/ship-chip.scss +0 -104
  128. package/styles/components/ship-color-picker.scss +0 -150
  129. package/styles/components/ship-datepicker.scss +0 -317
  130. package/styles/components/ship-dialog.scss +0 -152
  131. package/styles/components/ship-divider.scss +0 -27
  132. package/styles/components/ship-event-card.scss +0 -51
  133. package/styles/components/ship-file-upload.scss +0 -47
  134. package/styles/components/ship-form-field.scss +0 -408
  135. package/styles/components/ship-icon.scss +0 -54
  136. package/styles/components/ship-list.scss +0 -165
  137. package/styles/components/ship-menu.scss +0 -237
  138. package/styles/components/ship-popover.scss +0 -205
  139. package/styles/components/ship-progress-bar.scss +0 -173
  140. package/styles/components/ship-radio.scss +0 -113
  141. package/styles/components/ship-range-slider.scss +0 -421
  142. package/styles/components/ship-select.scss +0 -153
  143. package/styles/components/ship-sidenav.scss +0 -195
  144. package/styles/components/ship-sortable.scss +0 -45
  145. package/styles/components/ship-spinner.scss +0 -53
  146. package/styles/components/ship-stepper.scss +0 -158
  147. package/styles/components/ship-table.scss +0 -443
  148. package/styles/components/ship-tabs.scss +0 -125
  149. package/styles/components/ship-theme-toggle.scss +0 -41
  150. package/styles/components/ship-toggle-card.scss +0 -69
  151. package/styles/components/ship-toggle.scss +0 -255
  152. package/styles/components/ship-tooltip.scss +0 -151
  153. package/styles/components/ship-virtual-scroll.scss +0 -12
@@ -0,0 +1,947 @@
1
+ import { isPlatformBrowser } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { inject, DOCUMENT, PLATFORM_ID, viewChild, signal, input, model, output, computed, effect, untracked, HostListener, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
4
+ import { rgbToHex, rgbToHsl, rgbaToHex8, rgbToHsv, hsvToRgbExact, hslToRgbExact, classMutationSignal, contentProjectionSignal } from '@ship-ui/core';
5
+ import { ShipButton } from '@ship-ui/core/ship-button';
6
+ import { ShipFormFieldPopover } from '@ship-ui/core/ship-form-field';
7
+ import { ShipIcon } from '@ship-ui/core/ship-icon';
8
+
9
+ class ShipColorPicker {
10
+ constructor() {
11
+ this.#document = inject(DOCUMENT);
12
+ this.#platformId = inject(PLATFORM_ID);
13
+ this.canvasRef = viewChild.required('colorCanvas');
14
+ this.#canvasData = signal(null, /* @ts-ignore */
15
+ ...(ngDevMode ? [{ debugName: "#canvasData" }] : /* istanbul ignore next */ []));
16
+ this.showDarkColors = input(false, /* @ts-ignore */
17
+ ...(ngDevMode ? [{ debugName: "showDarkColors" }] : /* istanbul ignore next */ []));
18
+ this.renderingType = input('hsl', /* @ts-ignore */
19
+ ...(ngDevMode ? [{ debugName: "renderingType" }] : /* istanbul ignore next */ []));
20
+ this.gridSize = input(20, /* @ts-ignore */
21
+ ...(ngDevMode ? [{ debugName: "gridSize" }] : /* istanbul ignore next */ []));
22
+ this.hue = model(0, /* @ts-ignore */
23
+ ...(ngDevMode ? [{ debugName: "hue" }] : /* istanbul ignore next */ []));
24
+ this.direction = input('horizontal', /* @ts-ignore */
25
+ ...(ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []));
26
+ this.selectedColor = model([255, 255, 255, 1], /* @ts-ignore */
27
+ ...(ngDevMode ? [{ debugName: "selectedColor" }] : /* istanbul ignore next */ []));
28
+ this.alpha = model(1, /* @ts-ignore */
29
+ ...(ngDevMode ? [{ debugName: "alpha" }] : /* istanbul ignore next */ []));
30
+ this.currentColor = output();
31
+ this.centerLightness = computed(() => (this.showDarkColors() ? 200 : 100), /* @ts-ignore */
32
+ ...(ngDevMode ? [{ debugName: "centerLightness" }] : /* istanbul ignore next */ []));
33
+ this.isDragging = signal(false, /* @ts-ignore */
34
+ ...(ngDevMode ? [{ debugName: "isDragging" }] : /* istanbul ignore next */ []));
35
+ this.markerPosition = signal({ x: '50%', y: '50%' }, /* @ts-ignore */
36
+ ...(ngDevMode ? [{ debugName: "markerPosition" }] : /* istanbul ignore next */ []));
37
+ this._pos = { x: '0', y: '0' };
38
+ this._markerPosition = effect(() => (this._pos = this.markerPosition()), /* @ts-ignore */
39
+ ...(ngDevMode ? [{ debugName: "_markerPosition" }] : /* istanbul ignore next */ []));
40
+ this.#skipMarkerUpdate = false;
41
+ this.selectedColorRgb = computed(() => {
42
+ const c = this.selectedColor();
43
+ return c[3] !== undefined ? `rgba(${c[0]},${c[1]},${c[2]},${c[3]})` : `rgb(${c[0]},${c[1]},${c[2]})`;
44
+ }, /* @ts-ignore */
45
+ ...(ngDevMode ? [{ debugName: "selectedColorRgb" }] : /* istanbul ignore next */ []));
46
+ this.selectedColorHex = computed(() => rgbToHex(...this.selectedColor()), /* @ts-ignore */
47
+ ...(ngDevMode ? [{ debugName: "selectedColorHex" }] : /* istanbul ignore next */ []));
48
+ this.selectedColorHsl = computed(() => rgbToHsl(...this.selectedColor()).string, /* @ts-ignore */
49
+ ...(ngDevMode ? [{ debugName: "selectedColorHsl" }] : /* istanbul ignore next */ []));
50
+ this.alphaEffect = effect(() => {
51
+ const a = this.alpha();
52
+ const current = untracked(() => this.selectedColor());
53
+ if (current[3] !== a) {
54
+ this.#skipMarkerUpdate = false;
55
+ this.selectedColor.set([current[0], current[1], current[2], a]);
56
+ }
57
+ }, /* @ts-ignore */
58
+ ...(ngDevMode ? [{ debugName: "alphaEffect" }] : /* istanbul ignore next */ []));
59
+ this._prevColorStr = '';
60
+ this.selectedColorEffect = effect(() => {
61
+ const selectedColor = this.selectedColor();
62
+ const r = selectedColor[0];
63
+ const g = selectedColor[1];
64
+ const b = selectedColor[2];
65
+ const a = selectedColor[3] ?? 1;
66
+ untracked(() => {
67
+ if (this.alpha() !== a) {
68
+ this.alpha.set(a);
69
+ }
70
+ });
71
+ const str = `${r},${g},${b},${a}`;
72
+ if (this._prevColorStr === str && !this.#skipMarkerUpdate) {
73
+ // We still want to clear skipMarkerUpdate if it was set
74
+ // wait, actually if skipMarkerUpdate is true, it means we JUST dragged.
75
+ // In that case we do want to emit currentColor.
76
+ }
77
+ const hsl = rgbToHsl(r, g, b);
78
+ const hex = rgbToHex(r, g, b);
79
+ if (this.#skipMarkerUpdate) {
80
+ this.#skipMarkerUpdate = false;
81
+ this._prevColorStr = str;
82
+ }
83
+ else {
84
+ if (this._prevColorStr !== str) {
85
+ this.updateMarkerFromColor(selectedColor);
86
+ this._prevColorStr = str;
87
+ }
88
+ else {
89
+ // Color is structurally identical and not from a drag event, skip marker jump
90
+ }
91
+ }
92
+ this.currentColor.emit({
93
+ rgb: `rgb(${r}, ${g}, ${b})`,
94
+ rgba: `rgba(${r}, ${g}, ${b}, ${a})`,
95
+ hex: hex,
96
+ hex8: rgbaToHex8(r, g, b, a),
97
+ hsl: hsl.string,
98
+ hsla: `hsla(${hsl.h}, ${hsl.s}%, ${hsl.l}%, ${a})`,
99
+ hue: hsl.h,
100
+ saturation: hsl.s,
101
+ alpha: a,
102
+ });
103
+ }, /* @ts-ignore */
104
+ ...(ngDevMode ? [{ debugName: "selectedColorEffect" }] : /* istanbul ignore next */ []));
105
+ this.alphaColorRedrawEffect = effect(() => {
106
+ const color = this.selectedColor();
107
+ if (this.renderingType() === 'alpha' && this.#canvasData()) {
108
+ untracked(() => this.drawAlpha());
109
+ }
110
+ }, /* @ts-ignore */
111
+ ...(ngDevMode ? [{ debugName: "alphaColorRedrawEffect" }] : /* istanbul ignore next */ []));
112
+ this.previousLayoutHash = '';
113
+ this.previousHue = null;
114
+ this.renderingTypeEffect = effect(() => {
115
+ const currentHue = this.hue();
116
+ const layoutHash = this.getLayoutHash();
117
+ const canvasData = untracked(() => this.#canvasData());
118
+ if (canvasData) {
119
+ untracked(() => this.drawColorPicker());
120
+ if (this.previousLayoutHash !== layoutHash) {
121
+ if (this.renderingType() === 'hsl') {
122
+ this.adjustMarkerPosition();
123
+ queueMicrotask(() => this.updateMarkerFromColor(untracked(() => this.selectedColor())));
124
+ }
125
+ else {
126
+ this.updateMarkerFromColor(untracked(() => this.selectedColor()));
127
+ }
128
+ this.previousLayoutHash = layoutHash;
129
+ this.previousHue = currentHue;
130
+ }
131
+ else if (this.previousHue !== currentHue) {
132
+ const pos = untracked(() => this.markerPosition());
133
+ const { canvas, ctx } = canvasData;
134
+ let x = (parseFloat(pos.x.replace('%', '')) / 100) * Math.max(1, canvas.width - 1);
135
+ let y = (parseFloat(pos.y.replace('%', '')) / 100) * Math.max(1, canvas.height - 1);
136
+ x = Math.max(0, Math.min(canvas.width - 1, Math.round(x)));
137
+ y = Math.max(0, Math.min(canvas.height - 1, Math.round(y)));
138
+ const color = untracked(() => this.getColorAtPosition(x, y));
139
+ if (this.renderingType() !== 'alpha') {
140
+ color[3] = untracked(() => this.selectedColor()[3] ?? 1);
141
+ }
142
+ this.#skipMarkerUpdate = true;
143
+ this.selectedColor.set(color);
144
+ this.previousHue = currentHue;
145
+ }
146
+ }
147
+ }, /* @ts-ignore */
148
+ ...(ngDevMode ? [{ debugName: "renderingTypeEffect" }] : /* istanbul ignore next */ []));
149
+ this.#resizeObserver = typeof ResizeObserver !== 'undefined'
150
+ ? new ResizeObserver((entries) => {
151
+ for (const entry of entries) {
152
+ if (entry.contentRect.width > 0 && entry.contentRect.height > 0) {
153
+ this.setCanvasSize();
154
+ }
155
+ }
156
+ })
157
+ : null;
158
+ this.initColor = null;
159
+ }
160
+ #document;
161
+ #platformId;
162
+ #canvasData;
163
+ #skipMarkerUpdate;
164
+ onResize() {
165
+ this.setCanvasSize();
166
+ }
167
+ getLayoutHash() {
168
+ return `${this.renderingType()}-${this.direction()}-${this.gridSize()}-${this.showDarkColors()}`;
169
+ }
170
+ #resizeObserver;
171
+ ngAfterViewInit() {
172
+ this.initColor = this.selectedColor();
173
+ const canvas = this.canvasRef()?.nativeElement;
174
+ if (canvas?.parentElement) {
175
+ this.#resizeObserver?.observe(canvas.parentElement);
176
+ }
177
+ this.setCanvasSize();
178
+ this.initCanvasEvents();
179
+ }
180
+ ngOnDestroy() {
181
+ this.#resizeObserver?.disconnect();
182
+ }
183
+ updateMarkerFromColor(rgba) {
184
+ const [r, g, b, a] = rgba;
185
+ const coords = this.findPositionByColor(r, g, b, a);
186
+ if (coords === null)
187
+ return;
188
+ const { x, y } = coords;
189
+ const mockEvent = {
190
+ offsetX: x,
191
+ offsetY: y,
192
+ clientX: x,
193
+ clientY: y,
194
+ touches: [{ clientX: x, clientY: y }],
195
+ };
196
+ this.updateColorAndMarker(mockEvent, false, true);
197
+ }
198
+ findPositionByColor(r, g, b, a) {
199
+ const canvasData = this.#canvasData();
200
+ if (!canvasData || !canvasData.canvas)
201
+ return null;
202
+ const { canvas, ctx } = canvasData;
203
+ if (canvas.width === 0 || canvas.height === 0)
204
+ return null;
205
+ if (this.renderingType() === 'alpha') {
206
+ const aVal = a ?? 1;
207
+ if (this.direction() === 'horizontal') {
208
+ return { x: Math.round(aVal * (canvas.width - 1)), y: Math.round((canvas.height - 1) / 2) };
209
+ }
210
+ else {
211
+ return { x: Math.round((canvas.width - 1) / 2), y: Math.round(aVal * (canvas.height - 1)) };
212
+ }
213
+ }
214
+ if (this.renderingType() === 'hue') {
215
+ const hsl = rgbToHsl(r, g, b);
216
+ const ratio = hsl.h / 360;
217
+ if (this.direction() === 'horizontal') {
218
+ return { x: Math.round(ratio * (canvas.width - 1)), y: Math.round((canvas.height - 1) / 2) };
219
+ }
220
+ else {
221
+ return { x: Math.round((canvas.width - 1) / 2), y: Math.round(ratio * (canvas.height - 1)) };
222
+ }
223
+ }
224
+ if (this.renderingType() === 'rgb') {
225
+ const hsv = rgbToHsv(r, g, b);
226
+ return {
227
+ x: Math.round((hsv.s / 100) * (canvas.width - 1)),
228
+ y: Math.round((1 - hsv.v / 100) * (canvas.height - 1)),
229
+ };
230
+ }
231
+ if (this.renderingType() === 'saturation') {
232
+ const hsl = rgbToHsl(r, g, b);
233
+ const ratio = hsl.s / 100;
234
+ if (this.direction() === 'horizontal') {
235
+ return { x: Math.round(ratio * (canvas.width - 1)), y: Math.round((canvas.height - 1) / 2) };
236
+ }
237
+ else {
238
+ return { x: Math.round((canvas.width - 1) / 2), y: Math.round(ratio * (canvas.height - 1)) };
239
+ }
240
+ }
241
+ if (this.renderingType() === 'hsl') {
242
+ const { centerX, centerY, radius } = canvasData;
243
+ const hsl = rgbToHsl(r, g, b);
244
+ const centerL = this.centerLightness();
245
+ let distance = 0;
246
+ if (centerL > 0) {
247
+ distance = ((100 - hsl.l) * radius) / ((50 * centerL) / 100);
248
+ }
249
+ const angle = (hsl.h / 360) * 2 * Math.PI - Math.PI;
250
+ return {
251
+ x: Math.round(centerX + distance * Math.cos(angle)),
252
+ y: Math.round(centerY + distance * Math.sin(angle)),
253
+ };
254
+ }
255
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
256
+ let bestMatch = { x: 0, y: 0, distance: Infinity };
257
+ for (let y = 0; y < canvas.height; y++) {
258
+ for (let x = 0; x < canvas.width; x++) {
259
+ const index = (y * canvas.width + x) * 4;
260
+ const pixelR = imageData[index];
261
+ const pixelG = imageData[index + 1];
262
+ const pixelB = imageData[index + 2];
263
+ const distance = Math.sqrt(Math.pow(r - pixelR, 2) + Math.pow(g - pixelG, 2) + Math.pow(b - pixelB, 2));
264
+ if (distance < bestMatch.distance) {
265
+ bestMatch = { x, y, distance };
266
+ }
267
+ }
268
+ }
269
+ return { x: bestMatch.x, y: bestMatch.y };
270
+ }
271
+ adjustMarkerPosition() {
272
+ const { canvas, centerX, centerY, radius } = this.#canvasData();
273
+ let { x, y } = this._pos;
274
+ let markerX = (parseFloat(x.replace('%', '')) / 100) * canvas.width;
275
+ let markerY = (parseFloat(y.replace('%', '')) / 100) * canvas.height;
276
+ const distance = Math.sqrt(Math.pow(markerX - centerX, 2) + Math.pow(markerY - centerY, 2));
277
+ if (distance > radius) {
278
+ const angle = Math.atan2(markerY - centerY, markerX - centerX);
279
+ markerX = centerX + radius * Math.cos(angle);
280
+ markerY = centerY + radius * Math.sin(angle);
281
+ x = ((markerX / canvas.width) * 100).toFixed(2) + '%';
282
+ y = ((markerY / canvas.height) * 100).toFixed(2) + '%';
283
+ this.markerPosition.set({ x, y });
284
+ }
285
+ }
286
+ initCanvasEvents() {
287
+ const data = this.#canvasData();
288
+ if (!data)
289
+ return;
290
+ const { canvas } = data;
291
+ canvas.addEventListener('mousedown', (event) => {
292
+ this.isDragging.set(true);
293
+ this.updateColorAndMarker(event);
294
+ });
295
+ this.#document.addEventListener('mousemove', (event) => {
296
+ if (this.isDragging()) {
297
+ event.preventDefault();
298
+ this.updateColorAndMarker(event, true);
299
+ }
300
+ });
301
+ this.#document.addEventListener('mouseup', () => this.isDragging.set(false));
302
+ canvas.addEventListener('touchstart', (_) => this.isDragging.set(true));
303
+ this.#document.addEventListener('touchmove', (event) => {
304
+ if (this.isDragging()) {
305
+ event.preventDefault();
306
+ this.updateColorAndMarker(event.touches[0], true);
307
+ }
308
+ });
309
+ this.#document.addEventListener('touchend', () => this.isDragging.set(false));
310
+ this.#document.addEventListener('touchcancel', () => this.isDragging.set(false));
311
+ }
312
+ setCanvasSize() {
313
+ if (!isPlatformBrowser(this.#platformId))
314
+ return;
315
+ const canvas = this.canvasRef()?.nativeElement;
316
+ if (canvas) {
317
+ const ctx = canvas.getContext('2d', {
318
+ willReadFrequently: true,
319
+ imageSmoothingEnabled: true,
320
+ imageSmoothingQuality: 'high',
321
+ });
322
+ const parentWidth = canvas.parentElement?.offsetWidth || canvas.offsetWidth;
323
+ canvas.width = parentWidth;
324
+ canvas.height = parentWidth;
325
+ this.#canvasData.set({
326
+ canvas,
327
+ ctx,
328
+ centerX: canvas.width / 2,
329
+ centerY: canvas.height / 2,
330
+ radius: Math.min(canvas.width, canvas.height) / 2,
331
+ });
332
+ this.drawColorPicker();
333
+ setTimeout(() => {
334
+ if (!this.isDragging()) {
335
+ this.updateMarkerFromColor(untracked(() => this.selectedColor()));
336
+ }
337
+ });
338
+ }
339
+ }
340
+ getColorAtPosition(mouseX, mouseY) {
341
+ const { canvas, ctx } = this.#canvasData();
342
+ const w = Math.max(1, canvas.width - 1);
343
+ const h = Math.max(1, canvas.height - 1);
344
+ const xRatio = mouseX / w;
345
+ const yRatio = mouseY / h;
346
+ if (this.renderingType() === 'rgb') {
347
+ return hsvToRgbExact(this.hue(), xRatio * 100, (1 - yRatio) * 100);
348
+ }
349
+ else if (this.renderingType() === 'saturation') {
350
+ const ratio = this.direction() === 'horizontal' ? xRatio : yRatio;
351
+ return hslToRgbExact(this.hue(), ratio * 100, 50);
352
+ }
353
+ else if (this.renderingType() === 'hue') {
354
+ const ratio = this.direction() === 'horizontal' ? xRatio : yRatio;
355
+ return hslToRgbExact(ratio * 360, 100, 50);
356
+ }
357
+ else if (this.renderingType() === 'alpha') {
358
+ const ratio = this.direction() === 'horizontal' ? xRatio : yRatio;
359
+ const current = this.selectedColor();
360
+ return [current[0], current[1], current[2], parseFloat(ratio.toFixed(2))];
361
+ }
362
+ else {
363
+ const pixelData = ctx.getImageData(mouseX, mouseY, 1, 1).data;
364
+ return [pixelData[0], pixelData[1], pixelData[2]];
365
+ }
366
+ }
367
+ updateColorAndMarker(event, outsideCanvas = false, onlyMarker = false) {
368
+ const { canvas, ctx } = this.#canvasData();
369
+ let mouseX = event instanceof MouseEvent ? event.offsetX : event.clientX;
370
+ let mouseY = event instanceof MouseEvent ? event.offsetY : event.clientY;
371
+ if (outsideCanvas) {
372
+ const rect = canvas.getBoundingClientRect();
373
+ mouseX = Math.round(event.clientX - rect.left);
374
+ mouseY = Math.round(event.clientY - rect.top);
375
+ }
376
+ if (this.renderingType() === 'hsl') {
377
+ const centerX = canvas.width / 2;
378
+ const centerY = canvas.height / 2;
379
+ const radius = Math.min(canvas.width, canvas.height) / 2;
380
+ const distance = Math.sqrt(Math.pow(mouseX - centerX, 2) + Math.pow(mouseY - centerY, 2));
381
+ if (distance > radius) {
382
+ const angle = Math.atan2(mouseY - centerY, mouseX - centerX);
383
+ mouseX = centerX + radius * Math.cos(angle);
384
+ mouseY = centerY + radius * Math.sin(angle);
385
+ }
386
+ }
387
+ mouseX = Math.max(0, Math.min(canvas.width - 1, Math.round(mouseX)));
388
+ mouseY = Math.max(0, Math.min(canvas.height - 1, Math.round(mouseY)));
389
+ if (!onlyMarker) {
390
+ const newColor = this.getColorAtPosition(mouseX, mouseY);
391
+ if (this.renderingType() !== 'alpha') {
392
+ newColor[3] = this.selectedColor()[3] ?? 1;
393
+ }
394
+ this.#skipMarkerUpdate = true;
395
+ this.selectedColor.set(newColor);
396
+ }
397
+ const xPercent = ((mouseX / Math.max(1, canvas.width - 1)) * 100).toFixed(2) + '%';
398
+ const yPercent = ((mouseY / Math.max(1, canvas.height - 1)) * 100).toFixed(2) + '%';
399
+ this.markerPosition.set({ x: xPercent, y: yPercent });
400
+ }
401
+ drawColorPicker() {
402
+ switch (this.renderingType()) {
403
+ case 'hsl':
404
+ this.drawColorWheel();
405
+ break;
406
+ case 'grid':
407
+ this.drawGrid();
408
+ break;
409
+ case 'hue':
410
+ this.drawHue();
411
+ break;
412
+ case 'alpha':
413
+ this.drawAlpha();
414
+ break;
415
+ case 'rgb':
416
+ this.drawRgb();
417
+ break;
418
+ case 'saturation':
419
+ this.drawSaturation();
420
+ break;
421
+ }
422
+ }
423
+ drawAlpha() {
424
+ const { canvas, ctx } = this.#canvasData();
425
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
426
+ const w = Math.max(1, canvas.width - 1);
427
+ const h = Math.max(1, canvas.height - 1);
428
+ const gradient = ctx.createLinearGradient(0, 0, this.direction() === 'horizontal' ? w : 0, this.direction() === 'horizontal' ? 0 : h);
429
+ const [r, g, b] = this.selectedColor();
430
+ gradient.addColorStop(0, `rgba(${r}, ${g}, ${b}, 0)`);
431
+ gradient.addColorStop(1, `rgba(${r}, ${g}, ${b}, 1)`);
432
+ ctx.fillStyle = gradient;
433
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
434
+ }
435
+ drawRgb() {
436
+ const { canvas, ctx } = this.#canvasData();
437
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
438
+ const w = Math.max(1, canvas.width - 1);
439
+ const h = Math.max(1, canvas.height - 1);
440
+ const gradient = ctx.createLinearGradient(0, 0, w, 0);
441
+ gradient.addColorStop(0, '#ffffff');
442
+ gradient.addColorStop(1, `hsl(${this.hue()}, 100%, 50%)`);
443
+ ctx.fillStyle = gradient;
444
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
445
+ const gradient2 = ctx.createLinearGradient(0, 0, 0, h);
446
+ gradient2.addColorStop(0, 'rgba(0, 0, 0, 0)');
447
+ gradient2.addColorStop(1, '#000000');
448
+ ctx.fillStyle = gradient2;
449
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
450
+ }
451
+ drawSaturation() {
452
+ const { canvas, ctx } = this.#canvasData();
453
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
454
+ const w = Math.max(1, canvas.width - 1);
455
+ const h = Math.max(1, canvas.height - 1);
456
+ if (this.direction() === 'horizontal') {
457
+ const gradient = ctx.createLinearGradient(0, 0, w, 0);
458
+ gradient.addColorStop(0, `hsl(${this.hue()}, 0%, 50%)`);
459
+ gradient.addColorStop(1, `hsl(${this.hue()}, 100%, 50%)`);
460
+ ctx.fillStyle = gradient;
461
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
462
+ }
463
+ else {
464
+ const gradient = ctx.createLinearGradient(0, 0, 0, h);
465
+ gradient.addColorStop(0, `hsl(${this.hue()}, 0%, 50%)`);
466
+ gradient.addColorStop(1, `hsl(${this.hue()}, 100%, 50%)`);
467
+ ctx.fillStyle = gradient;
468
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
469
+ }
470
+ }
471
+ drawHue() {
472
+ const { canvas, ctx } = this.#canvasData();
473
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
474
+ const w = Math.max(1, canvas.width - 1);
475
+ const h = Math.max(1, canvas.height - 1);
476
+ const gradient = ctx.createLinearGradient(0, 0, this.direction() === 'horizontal' ? w : 0, this.direction() === 'horizontal' ? 0 : h);
477
+ for (let i = 0; i <= 360; i += 10) {
478
+ gradient.addColorStop(i / 360, `hsl(${i}, 100%, 50%)`);
479
+ }
480
+ ctx.fillStyle = gradient;
481
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
482
+ }
483
+ drawColorWheel() {
484
+ const { canvas, ctx, centerX, centerY, radius } = this.#canvasData();
485
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
486
+ for (let y = 0; y < canvas.height; y++) {
487
+ for (let x = 0; x < canvas.width; x++) {
488
+ const distance = Math.sqrt(Math.pow(x - centerX, 2) + Math.pow(y - centerY, 2));
489
+ if (distance <= radius + 2) {
490
+ const angle = Math.atan2(y - centerY, x - centerX);
491
+ const hue = ((angle + Math.PI) / (2 * Math.PI)) * 360;
492
+ ctx.fillStyle = `hsl(${hue}, 100%, ${100 - (this.centerLightness() / 100) * (distance / radius) * 50}%)`;
493
+ ctx.fillRect(x, y, 1, 1);
494
+ }
495
+ }
496
+ }
497
+ }
498
+ drawGrid() {
499
+ const { canvas, ctx } = this.#canvasData();
500
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
501
+ const gridSize = this.gridSize();
502
+ const cellSize = canvas.width / gridSize;
503
+ const inputHue = this.hue();
504
+ const reversedHue = (inputHue + 180) % 360;
505
+ const maxDistance = Math.sqrt(2) * (gridSize - 1);
506
+ for (let y = 0; y < canvas.height; y += cellSize) {
507
+ for (let x = 0; x < canvas.width; x += cellSize) {
508
+ const cellX = Math.floor(x / cellSize);
509
+ const cellY = Math.floor(y / cellSize);
510
+ const distanceTopLeft = Math.sqrt(cellX * cellX + cellY * cellY);
511
+ const l = Math.floor((distanceTopLeft / maxDistance) * 100);
512
+ const h = cellX >= cellY ? inputHue : reversedHue;
513
+ const distanceFromCenter = Math.abs(cellX - cellY) / (gridSize - 1);
514
+ const s = Math.floor(distanceFromCenter * 100);
515
+ ctx.fillStyle = `hsl(${h}, ${s}%, ${l}%)`;
516
+ ctx.fillRect(x, y, cellSize, cellSize);
517
+ }
518
+ }
519
+ }
520
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipColorPicker, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
521
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.0", type: ShipColorPicker, isStandalone: true, selector: "sh-color-picker", inputs: { showDarkColors: { classPropertyName: "showDarkColors", publicName: "showDarkColors", isSignal: true, isRequired: false, transformFunction: null }, renderingType: { classPropertyName: "renderingType", publicName: "renderingType", isSignal: true, isRequired: false, transformFunction: null }, gridSize: { classPropertyName: "gridSize", publicName: "gridSize", isSignal: true, isRequired: false, transformFunction: null }, hue: { classPropertyName: "hue", publicName: "hue", isSignal: true, isRequired: false, transformFunction: null }, direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null }, selectedColor: { classPropertyName: "selectedColor", publicName: "selectedColor", isSignal: true, isRequired: false, transformFunction: null }, alpha: { classPropertyName: "alpha", publicName: "alpha", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { hue: "hueChange", selectedColor: "selectedColorChange", alpha: "alphaChange", currentColor: "currentColor" }, host: { listeners: { "window:resize": "onResize()" }, properties: { "class": "renderingType()", "class.vertical": "(renderingType() === \"hue\" || renderingType() === \"saturation\") && direction() === \"vertical\"" } }, viewQueries: [{ propertyName: "canvasRef", first: true, predicate: ["colorCanvas"], descendants: true, isSignal: true }], ngImport: i0, template: `
522
+ <canvas #colorCanvas></canvas>
523
+ <div
524
+ class="marker"
525
+ [style.left]="markerPosition().x"
526
+ [style.top]="markerPosition().y"
527
+ [style.background]="selectedColorRgb()"></div>
528
+ `, isInline: true, styles: ["sh-color-picker{position:relative;display:block;width:18.75rem;aspect-ratio:1/1}sh-color-picker canvas{background-image:linear-gradient(45deg,#808080 25%,transparent 25%),linear-gradient(-45deg,#808080 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#808080 75%),linear-gradient(-45deg,transparent 75%,#808080 75%);background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0px}sh-color-picker.hsl canvas{border-radius:100%;overflow:hidden}sh-color-picker.rgb{border-radius:.125rem}sh-color-picker.saturation:not(.vertical),sh-color-picker.hue:not(.vertical),sh-color-picker.alpha:not(.vertical){height:1.25rem;aspect-ratio:auto;border-radius:.125rem}sh-color-picker.saturation:not(.vertical) canvas,sh-color-picker.hue:not(.vertical) canvas,sh-color-picker.alpha:not(.vertical) canvas{border-radius:.125rem}sh-color-picker.saturation:not(.vertical) .marker,sh-color-picker.hue:not(.vertical) .marker,sh-color-picker.alpha:not(.vertical) .marker{top:50%!important}sh-color-picker.saturation.vertical,sh-color-picker.hue.vertical,sh-color-picker.alpha.vertical{width:1.25rem;height:18.75rem;aspect-ratio:auto;border-radius:.125rem}sh-color-picker.saturation.vertical canvas,sh-color-picker.hue.vertical canvas,sh-color-picker.alpha.vertical canvas{border-radius:.125rem}sh-color-picker.saturation.vertical .marker,sh-color-picker.hue.vertical .marker,sh-color-picker.alpha.vertical .marker{left:50%!important}sh-color-picker canvas{width:100%;height:100%;border:2px solid var(--base-1);outline:var(--border-10)}sh-color-picker .marker{position:absolute;inset:0;width:1.25rem;height:1.25rem;border-radius:50%;border:1px solid #fff;pointer-events:none;transform:translate(-50%,-50%);box-shadow:0 1px 4px #0000004d}sh-color-picker-input{display:flex}sh-color-picker-input sh-popover{width:100%}sh-color-picker-input [popoverContent]{padding:.75rem;width:17.5rem;display:flex;flex-direction:column;gap:.5rem}sh-color-picker-input .input-container{flex:1 0;display:flex;align-items:center;gap:.25rem;padding-right:.5rem}sh-color-picker-input .input-container input{margin-right:0;min-width:10.9375rem}sh-color-picker-input .color-indicator{position:relative;width:1.5rem;height:1.5rem;border-radius:var(--shape-2);border:var(--border-10);overflow:hidden;background-color:#fff;background-image:linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(-45deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(-45deg,transparent 75%,#ccc 75%);background-size:8px 8px;background-position:0 0,0 4px,4px -4px,-4px 0px}sh-color-picker-input .color-indicator:after{content:\"\";position:absolute;inset:0;background:var(--indicator-color)}sh-color-picker-input sh-color-picker{width:100%}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
529
+ }
530
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipColorPicker, decorators: [{
531
+ type: Component,
532
+ args: [{ selector: 'sh-color-picker', encapsulation: ViewEncapsulation.None, imports: [], template: `
533
+ <canvas #colorCanvas></canvas>
534
+ <div
535
+ class="marker"
536
+ [style.left]="markerPosition().x"
537
+ [style.top]="markerPosition().y"
538
+ [style.background]="selectedColorRgb()"></div>
539
+ `, changeDetection: ChangeDetectionStrategy.OnPush, host: {
540
+ '[class]': 'renderingType()',
541
+ '[class.vertical]': '(renderingType() === "hue" || renderingType() === "saturation") && direction() === "vertical"',
542
+ }, styles: ["sh-color-picker{position:relative;display:block;width:18.75rem;aspect-ratio:1/1}sh-color-picker canvas{background-image:linear-gradient(45deg,#808080 25%,transparent 25%),linear-gradient(-45deg,#808080 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#808080 75%),linear-gradient(-45deg,transparent 75%,#808080 75%);background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0px}sh-color-picker.hsl canvas{border-radius:100%;overflow:hidden}sh-color-picker.rgb{border-radius:.125rem}sh-color-picker.saturation:not(.vertical),sh-color-picker.hue:not(.vertical),sh-color-picker.alpha:not(.vertical){height:1.25rem;aspect-ratio:auto;border-radius:.125rem}sh-color-picker.saturation:not(.vertical) canvas,sh-color-picker.hue:not(.vertical) canvas,sh-color-picker.alpha:not(.vertical) canvas{border-radius:.125rem}sh-color-picker.saturation:not(.vertical) .marker,sh-color-picker.hue:not(.vertical) .marker,sh-color-picker.alpha:not(.vertical) .marker{top:50%!important}sh-color-picker.saturation.vertical,sh-color-picker.hue.vertical,sh-color-picker.alpha.vertical{width:1.25rem;height:18.75rem;aspect-ratio:auto;border-radius:.125rem}sh-color-picker.saturation.vertical canvas,sh-color-picker.hue.vertical canvas,sh-color-picker.alpha.vertical canvas{border-radius:.125rem}sh-color-picker.saturation.vertical .marker,sh-color-picker.hue.vertical .marker,sh-color-picker.alpha.vertical .marker{left:50%!important}sh-color-picker canvas{width:100%;height:100%;border:2px solid var(--base-1);outline:var(--border-10)}sh-color-picker .marker{position:absolute;inset:0;width:1.25rem;height:1.25rem;border-radius:50%;border:1px solid #fff;pointer-events:none;transform:translate(-50%,-50%);box-shadow:0 1px 4px #0000004d}sh-color-picker-input{display:flex}sh-color-picker-input sh-popover{width:100%}sh-color-picker-input [popoverContent]{padding:.75rem;width:17.5rem;display:flex;flex-direction:column;gap:.5rem}sh-color-picker-input .input-container{flex:1 0;display:flex;align-items:center;gap:.25rem;padding-right:.5rem}sh-color-picker-input .input-container input{margin-right:0;min-width:10.9375rem}sh-color-picker-input .color-indicator{position:relative;width:1.5rem;height:1.5rem;border-radius:var(--shape-2);border:var(--border-10);overflow:hidden;background-color:#fff;background-image:linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(-45deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(-45deg,transparent 75%,#ccc 75%);background-size:8px 8px;background-position:0 0,0 4px,4px -4px,-4px 0px}sh-color-picker-input .color-indicator:after{content:\"\";position:absolute;inset:0;background:var(--indicator-color)}sh-color-picker-input sh-color-picker{width:100%}\n"] }]
543
+ }], propDecorators: { canvasRef: [{ type: i0.ViewChild, args: ['colorCanvas', { isSignal: true }] }], showDarkColors: [{ type: i0.Input, args: [{ isSignal: true, alias: "showDarkColors", required: false }] }], renderingType: [{ type: i0.Input, args: [{ isSignal: true, alias: "renderingType", required: false }] }], gridSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "gridSize", required: false }] }], hue: [{ type: i0.Input, args: [{ isSignal: true, alias: "hue", required: false }] }, { type: i0.Output, args: ["hueChange"] }], direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "direction", required: false }] }], selectedColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedColor", required: false }] }, { type: i0.Output, args: ["selectedColorChange"] }], alpha: [{ type: i0.Input, args: [{ isSignal: true, alias: "alpha", required: false }] }, { type: i0.Output, args: ["alphaChange"] }], currentColor: [{ type: i0.Output, args: ["currentColor"] }], onResize: [{
544
+ type: HostListener,
545
+ args: ['window:resize', []]
546
+ }] } });
547
+
548
+ class ShipColorPickerInput {
549
+ constructor() {
550
+ this.#document = inject(DOCUMENT);
551
+ this.renderingType = input('hsl', /* @ts-ignore */
552
+ ...(ngDevMode ? [{ debugName: "renderingType" }] : /* istanbul ignore next */ []));
553
+ this.format = input('rgb', /* @ts-ignore */
554
+ ...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
555
+ this.color = input(null, /* @ts-ignore */
556
+ ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
557
+ this.variant = input(null, /* @ts-ignore */
558
+ ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
559
+ this.size = input(null, /* @ts-ignore */
560
+ ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
561
+ this.readonly = input(false, /* @ts-ignore */
562
+ ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
563
+ this.closed = output();
564
+ this.isOpen = model(false, /* @ts-ignore */
565
+ ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
566
+ this.currentClass = classMutationSignal();
567
+ this.isEyeDropperSupported = typeof window !== 'undefined' && 'EyeDropper' in window;
568
+ this.showEyeDropper = input(true, /* @ts-ignore */
569
+ ...(ngDevMode ? [{ debugName: "showEyeDropper" }] : /* istanbul ignore next */ []));
570
+ this.internalHue = signal(0, /* @ts-ignore */
571
+ ...(ngDevMode ? [{ debugName: "internalHue" }] : /* istanbul ignore next */ []));
572
+ this.internalAlpha = signal(1, /* @ts-ignore */
573
+ ...(ngDevMode ? [{ debugName: "internalAlpha" }] : /* istanbul ignore next */ []));
574
+ this.internalColorTuple = signal([255, 255, 255, 1], /* @ts-ignore */
575
+ ...(ngDevMode ? [{ debugName: "internalColorTuple" }] : /* istanbul ignore next */ []));
576
+ this.hasAlpha = computed(() => ['rgba', 'hex8', 'hsla'].includes(this.format()), /* @ts-ignore */
577
+ ...(ngDevMode ? [{ debugName: "hasAlpha" }] : /* istanbul ignore next */ []));
578
+ this.formattedColorString = computed(() => {
579
+ const format = this.format();
580
+ const tuple = this.internalColorTuple();
581
+ const [r, g, b, aRaw] = tuple;
582
+ const a = aRaw ?? 1;
583
+ switch (format) {
584
+ case 'rgb':
585
+ return `rgb(${r}, ${g}, ${b})`;
586
+ case 'rgba':
587
+ return `rgba(${r}, ${g}, ${b}, ${a})`;
588
+ case 'hex':
589
+ return rgbToHex(r, g, b);
590
+ case 'hex8':
591
+ return rgbaToHex8(r, g, b, a);
592
+ case 'hsl':
593
+ return rgbToHsl(r, g, b).string;
594
+ case 'hsla': {
595
+ const hsl = rgbToHsl(r, g, b);
596
+ return `hsla(${hsl.h}, ${hsl.s}%, ${hsl.l}%, ${a})`;
597
+ }
598
+ default:
599
+ return `rgb(${r}, ${g}, ${b})`;
600
+ }
601
+ }, /* @ts-ignore */
602
+ ...(ngDevMode ? [{ debugName: "formattedColorString" }] : /* istanbul ignore next */ []));
603
+ this.#formatSyncEffect = effect(() => {
604
+ const str = this.formattedColorString();
605
+ const input = untracked(() => this.#inputRef());
606
+ if (input && input.value !== str) {
607
+ if (this.#document.activeElement !== input) {
608
+ input.value = str;
609
+ input.dispatchEvent(new Event('input'));
610
+ }
611
+ }
612
+ }, /* @ts-ignore */
613
+ ...(ngDevMode ? [{ debugName: "#formatSyncEffect" }] : /* istanbul ignore next */ []));
614
+ this.pureHueColor = computed(() => {
615
+ return hslToRgbExact(this.internalHue(), 100, 50);
616
+ }, /* @ts-ignore */
617
+ ...(ngDevMode ? [{ debugName: "pureHueColor" }] : /* istanbul ignore next */ []));
618
+ this.#inputRef = signal(null, /* @ts-ignore */
619
+ ...(ngDevMode ? [{ debugName: "#inputRef" }] : /* istanbul ignore next */ []));
620
+ this.#inputObserver = contentProjectionSignal('#input-wrap input');
621
+ this.#inputRefEffect = effect(() => {
622
+ const inputs = this.#inputObserver();
623
+ if (!inputs.length)
624
+ return;
625
+ const input = inputs[0];
626
+ if (!input)
627
+ return;
628
+ this.#createCustomInputEventListener(input);
629
+ input.addEventListener('inputValueChanged', (event) => {
630
+ this.parseAndSetColor(event.detail.value);
631
+ });
632
+ input.addEventListener('input', (event) => {
633
+ const target = event.target;
634
+ this.parseAndSetColor(target.value);
635
+ });
636
+ input.addEventListener('blur', () => {
637
+ const str = untracked(() => this.formattedColorString());
638
+ if (input.value !== str) {
639
+ input.value = str;
640
+ input.dispatchEvent(new Event('input'));
641
+ }
642
+ });
643
+ input.addEventListener('focus', () => {
644
+ this.isOpen.set(true);
645
+ });
646
+ this.#inputRef.set(input);
647
+ input.autocomplete = 'off';
648
+ if (typeof input.value === 'string' && input.value) {
649
+ this.parseAndSetColor(input.value);
650
+ }
651
+ }, /* @ts-ignore */
652
+ ...(ngDevMode ? [{ debugName: "#inputRefEffect" }] : /* istanbul ignore next */ []));
653
+ }
654
+ #document;
655
+ #formatSyncEffect;
656
+ #inputRef;
657
+ #inputObserver;
658
+ onMainColorChange(colorObj) {
659
+ if (colorObj.hue !== undefined) {
660
+ if (this.renderingType() === 'hsl' && colorObj.saturation > 0) {
661
+ this.internalHue.set(colorObj.hue);
662
+ }
663
+ }
664
+ }
665
+ onHuePickerChange(colorObj) {
666
+ if (colorObj.hue !== undefined && colorObj.hue !== this.internalHue()) {
667
+ this.internalHue.set(colorObj.hue);
668
+ }
669
+ }
670
+ async openEyeDropper(event) {
671
+ event.preventDefault();
672
+ event.stopPropagation();
673
+ try {
674
+ // @ts-ignore
675
+ const eyeDropper = new window.EyeDropper();
676
+ const result = await eyeDropper.open();
677
+ if (result && result.sRGBHex) {
678
+ this.parseAndSetColor(result.sRGBHex);
679
+ // Force the text field to immediately display the new output string according to the active format
680
+ const input = untracked(() => this.#inputRef());
681
+ if (input) {
682
+ const str = this.formattedColorString();
683
+ if (input.value !== str) {
684
+ input.value = str;
685
+ input.dispatchEvent(new Event('input'));
686
+ }
687
+ }
688
+ }
689
+ }
690
+ catch (e) {
691
+ // User cancelled
692
+ }
693
+ }
694
+ close() {
695
+ this.closed.emit(this.formattedColorString());
696
+ }
697
+ #inputRefEffect;
698
+ parseAndSetColor(colorStr) {
699
+ if (!colorStr)
700
+ return;
701
+ if (colorStr === untracked(() => this.formattedColorString()))
702
+ return;
703
+ const div = this.#document.createElement('div');
704
+ div.style.color = colorStr;
705
+ if (div.style.color === '')
706
+ return; // Not a valid color format
707
+ this.#document.body.appendChild(div);
708
+ const computedColor = getComputedStyle(div).color;
709
+ this.#document.body.removeChild(div);
710
+ const rgbaMatch = computedColor.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
711
+ if (rgbaMatch) {
712
+ const r = parseInt(rgbaMatch[1], 10);
713
+ const g = parseInt(rgbaMatch[2], 10);
714
+ const b = parseInt(rgbaMatch[3], 10);
715
+ const a = rgbaMatch[4] ? parseFloat(rgbaMatch[4]) : 1;
716
+ const current = untracked(() => this.internalColorTuple());
717
+ if (current[0] !== r || current[1] !== g || current[2] !== b || (current[3] ?? 1) !== a) {
718
+ this.internalColorTuple.set([r, g, b, a]);
719
+ this.internalAlpha.set(a);
720
+ // Also update hue so the hue slider matches the typed color!
721
+ const max = Math.max(r, g, b) / 255;
722
+ const min = Math.min(r, g, b) / 255;
723
+ if (max !== min) {
724
+ const d = max - min;
725
+ let h = 0;
726
+ switch (max) {
727
+ case r / 255:
728
+ h = (g / 255 - b / 255) / d + (g / 255 < b / 255 ? 6 : 0);
729
+ break;
730
+ case g / 255:
731
+ h = (b / 255 - r / 255) / d + 2;
732
+ break;
733
+ case b / 255:
734
+ h = (r / 255 - g / 255) / d + 4;
735
+ break;
736
+ }
737
+ h /= 6;
738
+ this.internalHue.set(Math.floor(h * 360));
739
+ }
740
+ }
741
+ }
742
+ }
743
+ hslToRgbExact(h, s, l) {
744
+ s /= 100;
745
+ l /= 100;
746
+ const k = (n) => (n + h / 30) % 12;
747
+ const a = s * Math.min(l, 1 - l);
748
+ const f = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
749
+ return [Math.round(255 * f(0)), Math.round(255 * f(8)), Math.round(255 * f(4))];
750
+ }
751
+ rgbToHex(r, g, b) {
752
+ return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
753
+ }
754
+ rgbaToHex8(r, g, b, a) {
755
+ const alphaHex = Math.round(a * 255)
756
+ .toString(16)
757
+ .padStart(2, '0');
758
+ return this.rgbToHex(r, g, b) + alphaHex;
759
+ }
760
+ rgbToHsl(r, g, b) {
761
+ r /= 255;
762
+ g /= 255;
763
+ b /= 255;
764
+ const max = Math.max(r, g, b), min = Math.min(r, g, b);
765
+ let h = 0, s = 0, l = (max + min) / 2;
766
+ if (max === min) {
767
+ h = s = 0;
768
+ }
769
+ else {
770
+ const d = max - min;
771
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
772
+ switch (max) {
773
+ case r:
774
+ h = (g - b) / d + (g < b ? 6 : 0);
775
+ break;
776
+ case g:
777
+ h = (b - r) / d + 2;
778
+ break;
779
+ case b:
780
+ h = (r - g) / d + 4;
781
+ break;
782
+ }
783
+ h /= 6;
784
+ }
785
+ const hDeg = Math.floor(h * 360);
786
+ const sPct = Math.round(s * 100);
787
+ const lPct = Math.round(l * 100);
788
+ return {
789
+ h: hDeg,
790
+ s: sPct,
791
+ l: lPct,
792
+ string: `hsl(${hDeg}, ${sPct}%, ${lPct}%)`,
793
+ };
794
+ }
795
+ #createCustomInputEventListener(input) {
796
+ Object.defineProperty(input, 'value', {
797
+ configurable: true,
798
+ get() {
799
+ const descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
800
+ return descriptor.get.call(this);
801
+ },
802
+ set(newVal) {
803
+ const descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
804
+ descriptor.set.call(this, newVal);
805
+ const inputEvent = new CustomEvent('inputValueChanged', {
806
+ bubbles: true,
807
+ cancelable: true,
808
+ detail: {
809
+ value: newVal,
810
+ },
811
+ });
812
+ this.dispatchEvent(inputEvent);
813
+ return newVal;
814
+ },
815
+ });
816
+ return input;
817
+ }
818
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipColorPickerInput, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
819
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: ShipColorPickerInput, isStandalone: true, selector: "sh-color-picker-input", inputs: { renderingType: { classPropertyName: "renderingType", publicName: "renderingType", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, isOpen: { classPropertyName: "isOpen", publicName: "isOpen", isSignal: true, isRequired: false, transformFunction: null }, showEyeDropper: { classPropertyName: "showEyeDropper", publicName: "showEyeDropper", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed", isOpen: "isOpenChange" }, ngImport: i0, template: `
820
+ <sh-form-field-popover
821
+ (closed)="close()"
822
+ [(isOpen)]="isOpen"
823
+ [class]="currentClass()"
824
+ [variant]="variant()"
825
+ [size]="size()"
826
+ [color]="color()"
827
+ [readonly]="readonly()">
828
+ <ng-content select="label" ngProjectAs="label" />
829
+
830
+ <ng-content select="[prefix]" ngProjectAs="[prefix]" />
831
+ <ng-content select="[textPrefix]" ngProjectAs="[textPrefix]" />
832
+
833
+ <div id="input-wrap" class="input-container" ngProjectAs="input">
834
+ <ng-content select="input" />
835
+
836
+ <div class="color-indicator" [style.--indicator-color]="formattedColorString()"></div>
837
+
838
+ @if (isEyeDropperSupported && showEyeDropper()) {
839
+ <button size="xsmall" tabindex="-1" variant="outlined" shButton (click)="openEyeDropper($event)">
840
+ <sh-icon>eyedropper</sh-icon>
841
+ </button>
842
+ }
843
+ </div>
844
+
845
+ <ng-content select="[textSuffix]" ngProjectAs="[textSuffix]" />
846
+ <ng-content select="[suffix]" ngProjectAs="[suffix]" />
847
+
848
+ <div popoverContent>
849
+ @if (this.isOpen()) {
850
+ <sh-color-picker
851
+ [renderingType]="renderingType()"
852
+ [direction]="'horizontal'"
853
+ [(selectedColor)]="internalColorTuple"
854
+ [hue]="internalHue()"
855
+ [(alpha)]="internalAlpha"
856
+ (currentColor)="onMainColorChange($event)" />
857
+
858
+ @if (renderingType() !== 'hsl') {
859
+ <sh-color-picker
860
+ renderingType="hue"
861
+ [direction]="'horizontal'"
862
+ [hue]="internalHue()"
863
+ [selectedColor]="pureHueColor()"
864
+ (currentColor)="onHuePickerChange($event)" />
865
+ }
866
+
867
+ @if (hasAlpha()) {
868
+ <sh-color-picker
869
+ renderingType="alpha"
870
+ [direction]="'horizontal'"
871
+ [(alpha)]="internalAlpha"
872
+ [(selectedColor)]="internalColorTuple" />
873
+ }
874
+ }
875
+ </div>
876
+ </sh-form-field-popover>
877
+ `, isInline: true, styles: ["sh-color-picker{position:relative;display:block;width:18.75rem;aspect-ratio:1/1}sh-color-picker canvas{background-image:linear-gradient(45deg,#808080 25%,transparent 25%),linear-gradient(-45deg,#808080 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#808080 75%),linear-gradient(-45deg,transparent 75%,#808080 75%);background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0px}sh-color-picker.hsl canvas{border-radius:100%;overflow:hidden}sh-color-picker.rgb{border-radius:.125rem}sh-color-picker.saturation:not(.vertical),sh-color-picker.hue:not(.vertical),sh-color-picker.alpha:not(.vertical){height:1.25rem;aspect-ratio:auto;border-radius:.125rem}sh-color-picker.saturation:not(.vertical) canvas,sh-color-picker.hue:not(.vertical) canvas,sh-color-picker.alpha:not(.vertical) canvas{border-radius:.125rem}sh-color-picker.saturation:not(.vertical) .marker,sh-color-picker.hue:not(.vertical) .marker,sh-color-picker.alpha:not(.vertical) .marker{top:50%!important}sh-color-picker.saturation.vertical,sh-color-picker.hue.vertical,sh-color-picker.alpha.vertical{width:1.25rem;height:18.75rem;aspect-ratio:auto;border-radius:.125rem}sh-color-picker.saturation.vertical canvas,sh-color-picker.hue.vertical canvas,sh-color-picker.alpha.vertical canvas{border-radius:.125rem}sh-color-picker.saturation.vertical .marker,sh-color-picker.hue.vertical .marker,sh-color-picker.alpha.vertical .marker{left:50%!important}sh-color-picker canvas{width:100%;height:100%;border:2px solid var(--base-1);outline:var(--border-10)}sh-color-picker .marker{position:absolute;inset:0;width:1.25rem;height:1.25rem;border-radius:50%;border:1px solid #fff;pointer-events:none;transform:translate(-50%,-50%);box-shadow:0 1px 4px #0000004d}sh-color-picker-input{display:flex}sh-color-picker-input sh-popover{width:100%}sh-color-picker-input [popoverContent]{padding:.75rem;width:17.5rem;display:flex;flex-direction:column;gap:.5rem}sh-color-picker-input .input-container{flex:1 0;display:flex;align-items:center;gap:.25rem;padding-right:.5rem}sh-color-picker-input .input-container input{margin-right:0;min-width:10.9375rem}sh-color-picker-input .color-indicator{position:relative;width:1.5rem;height:1.5rem;border-radius:var(--shape-2);border:var(--border-10);overflow:hidden;background-color:#fff;background-image:linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(-45deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(-45deg,transparent 75%,#ccc 75%);background-size:8px 8px;background-position:0 0,0 4px,4px -4px,-4px 0px}sh-color-picker-input .color-indicator:after{content:\"\";position:absolute;inset:0;background:var(--indicator-color)}sh-color-picker-input sh-color-picker{width:100%}\n"], dependencies: [{ kind: "component", type: ShipFormFieldPopover, selector: "sh-form-field-popover", inputs: ["isOpen", "color", "variant", "size", "readonly"], outputs: ["isOpenChange", "closed"] }, { kind: "component", type: ShipColorPicker, selector: "sh-color-picker", inputs: ["showDarkColors", "renderingType", "gridSize", "hue", "direction", "selectedColor", "alpha"], outputs: ["hueChange", "selectedColorChange", "alphaChange", "currentColor"] }, { kind: "component", type: ShipIcon, selector: "sh-icon", inputs: ["color", "size"] }, { kind: "component", type: ShipButton, selector: "[shButton]", inputs: ["color", "variant", "size", "readonly"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
878
+ }
879
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipColorPickerInput, decorators: [{
880
+ type: Component,
881
+ args: [{ selector: 'sh-color-picker-input', encapsulation: ViewEncapsulation.None, imports: [ShipFormFieldPopover, ShipColorPicker, ShipIcon, ShipButton], template: `
882
+ <sh-form-field-popover
883
+ (closed)="close()"
884
+ [(isOpen)]="isOpen"
885
+ [class]="currentClass()"
886
+ [variant]="variant()"
887
+ [size]="size()"
888
+ [color]="color()"
889
+ [readonly]="readonly()">
890
+ <ng-content select="label" ngProjectAs="label" />
891
+
892
+ <ng-content select="[prefix]" ngProjectAs="[prefix]" />
893
+ <ng-content select="[textPrefix]" ngProjectAs="[textPrefix]" />
894
+
895
+ <div id="input-wrap" class="input-container" ngProjectAs="input">
896
+ <ng-content select="input" />
897
+
898
+ <div class="color-indicator" [style.--indicator-color]="formattedColorString()"></div>
899
+
900
+ @if (isEyeDropperSupported && showEyeDropper()) {
901
+ <button size="xsmall" tabindex="-1" variant="outlined" shButton (click)="openEyeDropper($event)">
902
+ <sh-icon>eyedropper</sh-icon>
903
+ </button>
904
+ }
905
+ </div>
906
+
907
+ <ng-content select="[textSuffix]" ngProjectAs="[textSuffix]" />
908
+ <ng-content select="[suffix]" ngProjectAs="[suffix]" />
909
+
910
+ <div popoverContent>
911
+ @if (this.isOpen()) {
912
+ <sh-color-picker
913
+ [renderingType]="renderingType()"
914
+ [direction]="'horizontal'"
915
+ [(selectedColor)]="internalColorTuple"
916
+ [hue]="internalHue()"
917
+ [(alpha)]="internalAlpha"
918
+ (currentColor)="onMainColorChange($event)" />
919
+
920
+ @if (renderingType() !== 'hsl') {
921
+ <sh-color-picker
922
+ renderingType="hue"
923
+ [direction]="'horizontal'"
924
+ [hue]="internalHue()"
925
+ [selectedColor]="pureHueColor()"
926
+ (currentColor)="onHuePickerChange($event)" />
927
+ }
928
+
929
+ @if (hasAlpha()) {
930
+ <sh-color-picker
931
+ renderingType="alpha"
932
+ [direction]="'horizontal'"
933
+ [(alpha)]="internalAlpha"
934
+ [(selectedColor)]="internalColorTuple" />
935
+ }
936
+ }
937
+ </div>
938
+ </sh-form-field-popover>
939
+ `, changeDetection: ChangeDetectionStrategy.OnPush, styles: ["sh-color-picker{position:relative;display:block;width:18.75rem;aspect-ratio:1/1}sh-color-picker canvas{background-image:linear-gradient(45deg,#808080 25%,transparent 25%),linear-gradient(-45deg,#808080 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#808080 75%),linear-gradient(-45deg,transparent 75%,#808080 75%);background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0px}sh-color-picker.hsl canvas{border-radius:100%;overflow:hidden}sh-color-picker.rgb{border-radius:.125rem}sh-color-picker.saturation:not(.vertical),sh-color-picker.hue:not(.vertical),sh-color-picker.alpha:not(.vertical){height:1.25rem;aspect-ratio:auto;border-radius:.125rem}sh-color-picker.saturation:not(.vertical) canvas,sh-color-picker.hue:not(.vertical) canvas,sh-color-picker.alpha:not(.vertical) canvas{border-radius:.125rem}sh-color-picker.saturation:not(.vertical) .marker,sh-color-picker.hue:not(.vertical) .marker,sh-color-picker.alpha:not(.vertical) .marker{top:50%!important}sh-color-picker.saturation.vertical,sh-color-picker.hue.vertical,sh-color-picker.alpha.vertical{width:1.25rem;height:18.75rem;aspect-ratio:auto;border-radius:.125rem}sh-color-picker.saturation.vertical canvas,sh-color-picker.hue.vertical canvas,sh-color-picker.alpha.vertical canvas{border-radius:.125rem}sh-color-picker.saturation.vertical .marker,sh-color-picker.hue.vertical .marker,sh-color-picker.alpha.vertical .marker{left:50%!important}sh-color-picker canvas{width:100%;height:100%;border:2px solid var(--base-1);outline:var(--border-10)}sh-color-picker .marker{position:absolute;inset:0;width:1.25rem;height:1.25rem;border-radius:50%;border:1px solid #fff;pointer-events:none;transform:translate(-50%,-50%);box-shadow:0 1px 4px #0000004d}sh-color-picker-input{display:flex}sh-color-picker-input sh-popover{width:100%}sh-color-picker-input [popoverContent]{padding:.75rem;width:17.5rem;display:flex;flex-direction:column;gap:.5rem}sh-color-picker-input .input-container{flex:1 0;display:flex;align-items:center;gap:.25rem;padding-right:.5rem}sh-color-picker-input .input-container input{margin-right:0;min-width:10.9375rem}sh-color-picker-input .color-indicator{position:relative;width:1.5rem;height:1.5rem;border-radius:var(--shape-2);border:var(--border-10);overflow:hidden;background-color:#fff;background-image:linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(-45deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(-45deg,transparent 75%,#ccc 75%);background-size:8px 8px;background-position:0 0,0 4px,4px -4px,-4px 0px}sh-color-picker-input .color-indicator:after{content:\"\";position:absolute;inset:0;background:var(--indicator-color)}sh-color-picker-input sh-color-picker{width:100%}\n"] }]
940
+ }], propDecorators: { renderingType: [{ type: i0.Input, args: [{ isSignal: true, alias: "renderingType", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }], isOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isOpen", required: false }] }, { type: i0.Output, args: ["isOpenChange"] }], showEyeDropper: [{ type: i0.Input, args: [{ isSignal: true, alias: "showEyeDropper", required: false }] }] } });
941
+
942
+ /**
943
+ * Generated bundle index. Do not edit.
944
+ */
945
+
946
+ export { ShipColorPicker, ShipColorPickerInput };
947
+ //# sourceMappingURL=ship-ui-core-ship-color-picker.mjs.map