@alegendstale/holly-components 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/absolute-container/absolute-container.js +113 -91
- package/dist/components/absolute-container/absolute-container.stories.js +36 -0
- package/dist/components/absolute-container/index.js +1 -1
- package/dist/components/bottom-sheet/bottom-sheet.js +415 -308
- package/dist/components/bottom-sheet/bottom-sheet.stories.js +43 -0
- package/dist/components/bottom-sheet/bottom-sheet.test.js +15 -0
- package/dist/components/bottom-sheet/index.js +1 -1
- package/dist/components/canvas/canvas-base.d.ts +2 -1
- package/dist/components/canvas/canvas-base.d.ts.map +1 -1
- package/dist/components/canvas/canvas-base.js +56 -44
- package/dist/components/canvas/canvas-gradient.js +61 -45
- package/dist/components/canvas/canvas-image.js +158 -111
- package/dist/components/canvas/index.js +2 -2
- package/dist/components/carousel-scroller/carousel-scroller.js +133 -121
- package/dist/components/carousel-scroller/carousel-scroller.stories.js +40 -0
- package/dist/components/carousel-scroller/index.js +1 -1
- package/dist/components/color-palette/color-palette-utils.js +105 -41
- package/dist/components/color-palette/color-palette.js +429 -337
- package/dist/components/color-palette/component/color-palette-component.js +184 -142
- package/dist/components/color-palette/component/color-palette-component.stories.js +74 -0
- package/dist/components/color-palette/component/index.js +1 -0
- package/dist/components/color-palette/editor/color-palette-editor.js +702 -591
- package/dist/components/color-palette/editor/color-palette-editor.stories.js +39 -0
- package/dist/components/color-palette/editor/index.js +1 -0
- package/dist/components/color-palette/index.js +5 -7
- package/dist/components/color-palette/item/color-palette-item-edit.js +114 -87
- package/dist/components/color-palette/item/color-palette-item.js +155 -140
- package/dist/components/color-palette/item/index.js +2 -0
- package/dist/components/color-palette/menu/color-palette-menu.js +241 -217
- package/dist/components/color-palette/menu/color-palette-reorder.js +117 -103
- package/dist/components/color-palette/menu/index.js +2 -0
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +90 -0
- package/dist/components/color-palette/storybook/color-palette-valid.stories.js +295 -0
- package/dist/components/color-palette/storybook/color-palette.stories.js +76 -0
- package/dist/components/tool-tip/Tooltip2.js +103 -0
- package/dist/components/tool-tip/index.js +1 -1
- package/dist/components/tool-tip/tool-tip.d.ts +1 -0
- package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
- package/dist/components/tool-tip/tool-tip.js +125 -102
- package/dist/components/tool-tip/tool-tip.stories.js +30 -0
- package/dist/index.js +6 -14
- package/dist/utils/EventEmitter.js +23 -23
- package/dist/utils/basicUtils.js +149 -32
- package/dist/utils/dragDropUtils.js +121 -0
- package/dist/utils/generateUtils.js +73 -39
- package/dist/utils/types.d.ts +1 -1
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/utils/types.js +1 -0
- package/package.json +1 -1
- package/dist/_virtual/_commonjsHelpers.js +0 -8
- package/dist/_virtual/x11.js +0 -4
- package/dist/node_modules/colorsea/colors/x11.js +0 -14
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export class DragDrop {
|
|
2
|
+
constructor(dropzones, draggables, onDrop) {
|
|
3
|
+
this.dropzones = dropzones;
|
|
4
|
+
this.draggables = draggables;
|
|
5
|
+
this.result = { beforeElement: null, insertedElement: null, afterElement: null, order: this.draggables };
|
|
6
|
+
this.onDrop = onDrop;
|
|
7
|
+
this.load();
|
|
8
|
+
}
|
|
9
|
+
dragStart(draggable, e) {
|
|
10
|
+
draggable.classList.toggle('is-dragging', true);
|
|
11
|
+
}
|
|
12
|
+
dragOver(dropzone, e) {
|
|
13
|
+
if (e.dataTransfer) {
|
|
14
|
+
const hasElement = Array.from(e.dataTransfer.items).some((item) => {
|
|
15
|
+
return item.kind !== 'element';
|
|
16
|
+
});
|
|
17
|
+
// Return early if element being dragged is not an element
|
|
18
|
+
if (hasElement)
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
this.result.beforeElement = this.getDragBeforeElement(e.clientX);
|
|
23
|
+
this.result.insertedElement = this.getDraggingElement();
|
|
24
|
+
this.result.afterElement = this.getDragAfterElement(e.clientX);
|
|
25
|
+
const insertedIndex = this.draggables.indexOf(this.result.insertedElement);
|
|
26
|
+
// If at the end of draggables
|
|
27
|
+
if (this.result.afterElement === null) {
|
|
28
|
+
// Append element
|
|
29
|
+
dropzone.appendChild(this.result.insertedElement);
|
|
30
|
+
// Remove element from order
|
|
31
|
+
this.result.order.splice(insertedIndex, 1);
|
|
32
|
+
// Add to end of order
|
|
33
|
+
this.result.order.push(this.result.insertedElement);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Place element between
|
|
37
|
+
dropzone.insertBefore(this.result.insertedElement, this.result.afterElement);
|
|
38
|
+
// Remove element from order
|
|
39
|
+
this.result.order.splice(insertedIndex, 1);
|
|
40
|
+
// Get the after index, post element removal
|
|
41
|
+
const afterIndex = this.draggables.indexOf(this.result.afterElement);
|
|
42
|
+
// Insert the element before the after index
|
|
43
|
+
this.result.order.splice(afterIndex, 0, this.result.insertedElement);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
dragEnd(draggable, e) {
|
|
47
|
+
draggable.classList.toggle('is-dragging', false);
|
|
48
|
+
this.onDrop(e, this.result);
|
|
49
|
+
this.result = { beforeElement: null, insertedElement: null, afterElement: null, order: this.draggables };
|
|
50
|
+
}
|
|
51
|
+
load() {
|
|
52
|
+
for (let draggable of this.draggables) {
|
|
53
|
+
// Important, so that all types of elements can be dragged, including divs & spans
|
|
54
|
+
draggable.setAttribute('draggable', "true");
|
|
55
|
+
draggable.addEventListener("dragstart", (e) => this.dragStart(draggable, e));
|
|
56
|
+
draggable.addEventListener("dragend", (e) => this.dragEnd(draggable, e));
|
|
57
|
+
}
|
|
58
|
+
for (let dropzone of this.dropzones) {
|
|
59
|
+
dropzone.addEventListener("dragover", (e) => this.dragOver(dropzone, e));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
unload() {
|
|
63
|
+
for (let draggable of this.draggables) {
|
|
64
|
+
draggable.removeEventListener('dragstart', (e) => this.dragStart(draggable, e));
|
|
65
|
+
draggable.removeEventListener('dragend', (e) => this.dragEnd(draggable, e));
|
|
66
|
+
}
|
|
67
|
+
for (let dropzone of this.dropzones) {
|
|
68
|
+
dropzone.removeEventListener('dragover', (e) => this.dragOver(dropzone, e));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @returns The element which is being dragged
|
|
73
|
+
*/
|
|
74
|
+
getDraggingElement() {
|
|
75
|
+
return this.draggables.filter((draggable) => draggable.classList.contains('is-dragging'))[0];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @returns All draggable elements not being dragged
|
|
79
|
+
*/
|
|
80
|
+
getDraggableElements() {
|
|
81
|
+
return this.draggables.filter((draggable) => !draggable.classList.contains('is-dragging'));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Gets the closest element before the dragged element
|
|
85
|
+
*/
|
|
86
|
+
getDragBeforeElement(x) {
|
|
87
|
+
return this.getDraggableElements().reduce((closest, child) => {
|
|
88
|
+
const rect = child.getBoundingClientRect();
|
|
89
|
+
const leftPosition = x - rect.left;
|
|
90
|
+
const halfChildWidth = rect.width / 2;
|
|
91
|
+
const offset = leftPosition - halfChildWidth;
|
|
92
|
+
// Return the closest element to the right of the cursor
|
|
93
|
+
if (offset > 0 && offset < closest.offset)
|
|
94
|
+
return { offset, element: child };
|
|
95
|
+
else
|
|
96
|
+
return closest;
|
|
97
|
+
},
|
|
98
|
+
// Initial closest value
|
|
99
|
+
{ offset: Number.POSITIVE_INFINITY, element: null })
|
|
100
|
+
.element;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Gets the closest element after the dragged element
|
|
104
|
+
*/
|
|
105
|
+
getDragAfterElement(x) {
|
|
106
|
+
return this.getDraggableElements().reduce((closest, child) => {
|
|
107
|
+
const rect = child.getBoundingClientRect();
|
|
108
|
+
const leftPosition = x - rect.left;
|
|
109
|
+
const halfChildWidth = rect.width / 2;
|
|
110
|
+
const offset = leftPosition - halfChildWidth;
|
|
111
|
+
// Return the closest element to the left of the cursor
|
|
112
|
+
if (offset < 0 && offset > closest.offset)
|
|
113
|
+
return { offset, element: child };
|
|
114
|
+
else
|
|
115
|
+
return closest;
|
|
116
|
+
},
|
|
117
|
+
// Initial closest value
|
|
118
|
+
{ offset: Number.NEGATIVE_INFINITY, element: null })
|
|
119
|
+
.element;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -1,40 +1,74 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import colorsea from "colorsea";
|
|
2
|
+
export var Combination;
|
|
3
|
+
(function (Combination) {
|
|
4
|
+
Combination["Complimentary"] = "Complimentary";
|
|
5
|
+
Combination["Monochromatic"] = "Monochromatic";
|
|
6
|
+
Combination["Analogous"] = "Analogous";
|
|
7
|
+
Combination["Triadic"] = "Triadic";
|
|
8
|
+
Combination["Tetradic"] = "Tetradic";
|
|
9
|
+
Combination["Random"] = "Random";
|
|
10
|
+
})(Combination || (Combination = {}));
|
|
11
|
+
/**
|
|
12
|
+
* Generate colors based on color theory
|
|
13
|
+
* @param baseColor Initial color to generate the rest from
|
|
14
|
+
* @param combination The type of color theory combination to use
|
|
15
|
+
* @param settings The settings for the palette
|
|
16
|
+
* @returns Generated colors & settings
|
|
17
|
+
*/
|
|
18
|
+
export function generateColors(combination, optional = { baseColor: colorsea.random() }) {
|
|
19
|
+
let { baseColor, settings } = optional;
|
|
20
|
+
// Never called because baseColor is set by default in parameters
|
|
21
|
+
if (!baseColor)
|
|
22
|
+
baseColor = colorsea.random();
|
|
23
|
+
let colors = [];
|
|
24
|
+
switch (combination) {
|
|
25
|
+
case Combination.Complimentary:
|
|
26
|
+
colors = [baseColor.hex(), baseColor.complement().hex()];
|
|
27
|
+
if (settings)
|
|
28
|
+
settings.aliases = ['Base', 'Complimentary Color'];
|
|
29
|
+
break;
|
|
30
|
+
case Combination.Monochromatic:
|
|
31
|
+
const lightest = baseColor.lighten(20);
|
|
32
|
+
const lighter = baseColor.lighten(10);
|
|
33
|
+
const darker = baseColor.darken(10);
|
|
34
|
+
const darkest = baseColor.darken(20);
|
|
35
|
+
colors = [lightest.hex(), lighter.hex(), baseColor.hex(), darker.hex(), darkest.hex()];
|
|
36
|
+
if (settings)
|
|
37
|
+
settings.aliases = ['Lightest', 'Lighter', 'Base', 'Darker', 'Darkest'];
|
|
38
|
+
break;
|
|
39
|
+
case Combination.Analogous:
|
|
40
|
+
const east = baseColor.adjustHue(-25);
|
|
41
|
+
const west = baseColor.adjustHue(25);
|
|
42
|
+
colors = [east.hex(), baseColor.hex(), west.hex()];
|
|
43
|
+
if (settings)
|
|
44
|
+
settings.aliases = ['Analogous East', 'Base', 'Analogous West'];
|
|
45
|
+
break;
|
|
46
|
+
case Combination.Triadic:
|
|
47
|
+
const hex120 = baseColor.spin(120);
|
|
48
|
+
const hex240 = baseColor.spin(240);
|
|
49
|
+
colors = [baseColor.hex(), hex120.hex(), hex240.hex()];
|
|
50
|
+
if (settings)
|
|
51
|
+
settings.aliases = ['Triadic First', 'Base', 'Triadic Third'];
|
|
52
|
+
break;
|
|
53
|
+
case Combination.Tetradic:
|
|
54
|
+
const hex90 = baseColor.spin(90);
|
|
55
|
+
const hex180 = baseColor.spin(180);
|
|
56
|
+
const hex270 = baseColor.spin(270);
|
|
57
|
+
colors = [baseColor.hex(), hex90.hex(), hex180.hex(), hex270.hex()];
|
|
58
|
+
if (settings)
|
|
59
|
+
settings.aliases = ['Base', 'Tetradic Second', 'Tetradic Third', 'Tetradic Fourth'];
|
|
60
|
+
break;
|
|
61
|
+
case Combination.Random:
|
|
62
|
+
// Clamp to a minimum value of 2
|
|
63
|
+
const randomNumber = Math.max(Math.round(Math.random() * 10), 2);
|
|
64
|
+
let randomColors = [];
|
|
65
|
+
for (let i = 0; i < randomNumber; i++) {
|
|
66
|
+
randomColors.push(colorsea.random().hex());
|
|
67
|
+
}
|
|
68
|
+
colors = randomColors;
|
|
69
|
+
if (settings)
|
|
70
|
+
settings.aliases = [];
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
return { colors, settings };
|
|
36
74
|
}
|
|
37
|
-
export {
|
|
38
|
-
M as Combination,
|
|
39
|
-
B as generateColors
|
|
40
|
-
};
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAA;CACT,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var o = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
2
|
-
function l(e) {
|
|
3
|
-
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
4
|
-
}
|
|
5
|
-
export {
|
|
6
|
-
o as commonjsGlobal,
|
|
7
|
-
l as getDefaultExportFromCjs
|
|
8
|
-
};
|
package/dist/_virtual/x11.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { commonjsGlobal as d, getDefaultExportFromCjs as r } from "../../../_virtual/_commonjsHelpers.js";
|
|
2
|
-
import { __module as e } from "../../../_virtual/x11.js";
|
|
3
|
-
(function(f, o) {
|
|
4
|
-
(function(i, a) {
|
|
5
|
-
f.exports = a();
|
|
6
|
-
})(d, function() {
|
|
7
|
-
return { aliceblue: "#f0f8ff", antiquewhite: "#faebd7", aqua: "#00ffff", aquamarine: "#7fffd4", azure: "#f0ffff", beige: "#f5f5dc", bisque: "#ffe4c4", black: "#000000", blanchedalmond: "#ffebcd", blue: "#0000ff", blueviolet: "#8a2be2", brown: "#a52a2a", burlywood: "#deb887", cadetblue: "#5f9ea0", chartreuse: "#7fff00", chocolate: "#d2691e", coral: "#ff7f50", cornflower: "#6495ed", cornflowerblue: "#6495ed", cornsilk: "#fff8dc", crimson: "#dc143c", cyan: "#00ffff", darkblue: "#00008b", darkcyan: "#008b8b", darkgoldenrod: "#b8860b", darkgray: "#a9a9a9", darkgreen: "#006400", darkgrey: "#a9a9a9", darkkhaki: "#bdb76b", darkmagenta: "#8b008b", darkolivegreen: "#556b2f", darkorange: "#ff8c00", darkorchid: "#9932cc", darkred: "#8b0000", darksalmon: "#e9967a", darkseagreen: "#8fbc8f", darkslateblue: "#483d8b", darkslategray: "#2f4f4f", darkslategrey: "#2f4f4f", darkturquoise: "#00ced1", darkviolet: "#9400d3", deeppink: "#ff1493", deepskyblue: "#00bfff", dimgray: "#696969", dimgrey: "#696969", dodgerblue: "#1e90ff", firebrick: "#b22222", floralwhite: "#fffaf0", forestgreen: "#228b22", fuchsia: "#ff00ff", gainsboro: "#dcdcdc", ghostwhite: "#f8f8ff", gold: "#ffd700", goldenrod: "#daa520", gray: "#808080", green: "#008000", greenyellow: "#adff2f", grey: "#808080", honeydew: "#f0fff0", hotpink: "#ff69b4", indianred: "#cd5c5c", indigo: "#4b0082", ivory: "#fffff0", khaki: "#f0e68c", laserlemon: "#ffff54", lavender: "#e6e6fa", lavenderblush: "#fff0f5", lawngreen: "#7cfc00", lemonchiffon: "#fffacd", lightblue: "#add8e6", lightcoral: "#f08080", lightcyan: "#e0ffff", lightgoldenrod: "#fafad2", lightgoldenrodyellow: "#fafad2", lightgray: "#d3d3d3", lightgreen: "#90ee90", lightgrey: "#d3d3d3", lightpink: "#ffb6c1", lightsalmon: "#ffa07a", lightseagreen: "#20b2aa", lightskyblue: "#87cefa", lightslategray: "#778899", lightslategrey: "#778899", lightsteelblue: "#b0c4de", lightyellow: "#ffffe0", lime: "#00ff00", limegreen: "#32cd32", linen: "#faf0e6", magenta: "#ff00ff", maroon: "#800000", maroon2: "#7f0000", maroon3: "#b03060", mediumaquamarine: "#66cdaa", mediumblue: "#0000cd", mediumorchid: "#ba55d3", mediumpurple: "#9370db", mediumseagreen: "#3cb371", mediumslateblue: "#7b68ee", mediumspringgreen: "#00fa9a", mediumturquoise: "#48d1cc", mediumvioletred: "#c71585", midnightblue: "#191970", mintcream: "#f5fffa", mistyrose: "#ffe4e1", moccasin: "#ffe4b5", navajowhite: "#ffdead", navy: "#000080", oldlace: "#fdf5e6", olive: "#808000", olivedrab: "#6b8e23", orange: "#ffa500", orangered: "#ff4500", orchid: "#da70d6", palegoldenrod: "#eee8aa", palegreen: "#98fb98", paleturquoise: "#afeeee", palevioletred: "#db7093", papayawhip: "#ffefd5", peachpuff: "#ffdab9", peru: "#cd853f", pink: "#ffc0cb", plum: "#dda0dd", powderblue: "#b0e0e6", purple: "#800080", purple2: "#7f007f", purple3: "#a020f0", rebeccapurple: "#663399", red: "#ff0000", rosybrown: "#bc8f8f", royalblue: "#4169e1", saddlebrown: "#8b4513", salmon: "#fa8072", sandybrown: "#f4a460", seagreen: "#2e8b57", seashell: "#fff5ee", sienna: "#a0522d", silver: "#c0c0c0", skyblue: "#87ceeb", slateblue: "#6a5acd", slategray: "#708090", slategrey: "#708090", snow: "#fffafa", springgreen: "#00ff7f", steelblue: "#4682b4", tan: "#d2b48c", teal: "#008080", thistle: "#d8bfd8", tomato: "#ff6347", turquoise: "#40e0d0", violet: "#ee82ee", wheat: "#f5deb3", white: "#ffffff", whitesmoke: "#f5f5f5", yellow: "#ffff00", yellowgreen: "#9acd32" };
|
|
8
|
-
});
|
|
9
|
-
})(e);
|
|
10
|
-
var l = e.exports;
|
|
11
|
-
const t = /* @__PURE__ */ r(l);
|
|
12
|
-
export {
|
|
13
|
-
t as default
|
|
14
|
-
};
|