@alegendstale/holly-components 0.2.9 → 0.2.10
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
|
@@ -1,125 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
(n = t[s]) && (e = (o ? n(r, i, e) : n(e)) || e);
|
|
7
|
-
return o && e && g(r, i, e), e;
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
6
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
import { css, html, LitElement } from 'lit';
|
|
8
|
+
import { customElement, query } from 'lit/decorators.js';
|
|
9
|
+
import { EventEmitter } from '../../utils/EventEmitter';
|
|
10
|
+
let CarouselScroller = class CarouselScroller extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.slotChildren = [];
|
|
14
|
+
this.emitter = new EventEmitter();
|
|
15
|
+
this.currentSlide = 0;
|
|
16
|
+
this.debouncers = new WeakMap();
|
|
17
|
+
this.emitter.on('slotsLoaded', (slotChildren) => {
|
|
18
|
+
this.slotChildren = slotChildren;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
super.disconnectedCallback();
|
|
23
|
+
this.emitter.clear();
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
return html `
|
|
27
|
+
<div class="container">
|
|
28
|
+
<button @click=${this.scrollToPrevSlide}><</button>
|
|
29
|
+
<button @click=${this.scrollToNextSlide}>></button>
|
|
30
|
+
<div>
|
|
31
|
+
<slot @slotchange=${this.slotChange}></slot>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
27
34
|
`;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
}
|
|
36
|
+
getCurrentSlide() {
|
|
37
|
+
return this.slotChildren[this.currentSlide - 1];
|
|
38
|
+
}
|
|
39
|
+
scrollToPrevSlide() {
|
|
40
|
+
this.currentSlide =
|
|
41
|
+
this.currentSlide === 0
|
|
42
|
+
? (this.currentSlide = this.slotChildren.length - 1)
|
|
43
|
+
: this.currentSlide - 1;
|
|
44
|
+
this.slotChildren
|
|
45
|
+
.at(this.currentSlide)
|
|
46
|
+
?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
47
|
+
}
|
|
48
|
+
scrollToNextSlide() {
|
|
49
|
+
this.currentSlide =
|
|
50
|
+
this.currentSlide === this.slotChildren.length - 1
|
|
51
|
+
? 0
|
|
52
|
+
: this.currentSlide + 1;
|
|
53
|
+
this.slotChildren
|
|
54
|
+
.at(this.currentSlide)
|
|
55
|
+
?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
56
|
+
}
|
|
57
|
+
slotChange() {
|
|
58
|
+
const slotElements = Array.from(this.slotEl
|
|
59
|
+
.assignedElements()
|
|
60
|
+
.map((element) => element));
|
|
61
|
+
clearTimeout(this.debouncers.get(this.slotEl));
|
|
62
|
+
const timeoutId = setTimeout(() => this.emitter.emit('slotsLoaded', slotElements), 100);
|
|
63
|
+
this.debouncers.set(this.slotEl, timeoutId);
|
|
64
|
+
}
|
|
51
65
|
};
|
|
52
|
-
|
|
53
|
-
:host {
|
|
54
|
-
--padding: 40px;
|
|
55
|
-
--margin: 80px;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.container {
|
|
59
|
-
width: 600px;
|
|
60
|
-
height: 400px;
|
|
61
|
-
margin: 20px;
|
|
62
|
-
border-radius: 20px;
|
|
63
|
-
overflow: hidden;
|
|
64
|
-
position: relative;
|
|
65
|
-
|
|
66
|
-
& > button {
|
|
67
|
-
position: absolute;
|
|
68
|
-
width: var(--padding);
|
|
69
|
-
height: calc(var(--padding) * 2);
|
|
70
|
-
z-index: 1;
|
|
71
|
-
background-color: #00000080;
|
|
72
|
-
border: none;
|
|
73
|
-
bottom: calc(50% - var(--padding));
|
|
74
|
-
font-size: 32px;
|
|
75
|
-
|
|
76
|
-
&:hover {
|
|
77
|
-
background-color: #6352b880;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
&:nth-child(1) {
|
|
81
|
-
left: 0;
|
|
82
|
-
border-top-right-radius: 314px;
|
|
83
|
-
border-bottom-right-radius: 314px;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&:nth-child(2) {
|
|
87
|
-
right: 0;
|
|
88
|
-
border-top-left-radius: 314px;
|
|
89
|
-
border-bottom-left-radius: 314px;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
& > div {
|
|
94
|
-
display: flex;
|
|
95
|
-
overflow-x: scroll;
|
|
96
|
-
position: relative;
|
|
97
|
-
scroll-behavior: smooth;
|
|
98
|
-
scroll-snap-type: x mandatory;
|
|
99
|
-
scrollbar-width: none;
|
|
100
|
-
padding: 0 var(--padding);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
::slotted(*) {
|
|
104
|
-
display: flex;
|
|
105
|
-
flex-direction: column;
|
|
106
|
-
justify-content: center;
|
|
107
|
-
min-height: calc(400px - var(--margin));
|
|
108
|
-
min-width: calc(600px - var(--margin));
|
|
109
|
-
max-height: calc(400px - var(--margin));
|
|
110
|
-
max-width: calc(600px - var(--margin));
|
|
111
|
-
background: white;
|
|
112
|
-
scroll-snap-align: center;
|
|
113
|
-
padding: calc(var(--margin) / 2);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
66
|
+
CarouselScroller.styles = css `
|
|
67
|
+
:host {
|
|
68
|
+
--padding: 40px;
|
|
69
|
+
--margin: 80px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.container {
|
|
73
|
+
width: 600px;
|
|
74
|
+
height: 400px;
|
|
75
|
+
margin: 20px;
|
|
76
|
+
border-radius: 20px;
|
|
77
|
+
overflow: hidden;
|
|
78
|
+
position: relative;
|
|
79
|
+
|
|
80
|
+
& > button {
|
|
81
|
+
position: absolute;
|
|
82
|
+
width: var(--padding);
|
|
83
|
+
height: calc(var(--padding) * 2);
|
|
84
|
+
z-index: 1;
|
|
85
|
+
background-color: #00000080;
|
|
86
|
+
border: none;
|
|
87
|
+
bottom: calc(50% - var(--padding));
|
|
88
|
+
font-size: 32px;
|
|
89
|
+
|
|
90
|
+
&:hover {
|
|
91
|
+
background-color: #6352b880;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&:nth-child(1) {
|
|
95
|
+
left: 0;
|
|
96
|
+
border-top-right-radius: 314px;
|
|
97
|
+
border-bottom-right-radius: 314px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&:nth-child(2) {
|
|
101
|
+
right: 0;
|
|
102
|
+
border-top-left-radius: 314px;
|
|
103
|
+
border-bottom-left-radius: 314px;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
& > div {
|
|
108
|
+
display: flex;
|
|
109
|
+
overflow-x: scroll;
|
|
110
|
+
position: relative;
|
|
111
|
+
scroll-behavior: smooth;
|
|
112
|
+
scroll-snap-type: x mandatory;
|
|
113
|
+
scrollbar-width: none;
|
|
114
|
+
padding: 0 var(--padding);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
::slotted(*) {
|
|
118
|
+
display: flex;
|
|
119
|
+
flex-direction: column;
|
|
120
|
+
justify-content: center;
|
|
121
|
+
min-height: calc(400px - var(--margin));
|
|
122
|
+
min-width: calc(600px - var(--margin));
|
|
123
|
+
max-height: calc(400px - var(--margin));
|
|
124
|
+
max-width: calc(600px - var(--margin));
|
|
125
|
+
background: white;
|
|
126
|
+
scroll-snap-align: center;
|
|
127
|
+
padding: calc(var(--margin) / 2);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
116
130
|
`;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
],
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
],
|
|
123
|
-
export {
|
|
124
|
-
l as CarouselScroller
|
|
125
|
-
};
|
|
131
|
+
__decorate([
|
|
132
|
+
query('slot')
|
|
133
|
+
], CarouselScroller.prototype, "slotEl", void 0);
|
|
134
|
+
CarouselScroller = __decorate([
|
|
135
|
+
customElement('carousel-scroller')
|
|
136
|
+
], CarouselScroller);
|
|
137
|
+
export { CarouselScroller };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Carousel Scroller',
|
|
5
|
+
tags: ['autodocs'],
|
|
6
|
+
component: 'carousel-scroller',
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
const Template = {
|
|
10
|
+
render: ({ items }) => {
|
|
11
|
+
return html `
|
|
12
|
+
<carousel-scroller>
|
|
13
|
+
${repeat(items, (item) => html `<div>${item}</div>`)}
|
|
14
|
+
</carousel-scroller>
|
|
15
|
+
`;
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const items = [
|
|
19
|
+
'one',
|
|
20
|
+
'two',
|
|
21
|
+
'three'
|
|
22
|
+
];
|
|
23
|
+
export const Empty = {
|
|
24
|
+
...Template,
|
|
25
|
+
args: {
|
|
26
|
+
items: [],
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export const OneItem = {
|
|
30
|
+
...Template,
|
|
31
|
+
args: {
|
|
32
|
+
items: [items[0]],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
export const ManyItems = {
|
|
36
|
+
...Template,
|
|
37
|
+
args: {
|
|
38
|
+
items,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './carousel-scroller';
|
|
@@ -1,44 +1,108 @@
|
|
|
1
|
-
import { parseUrl
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { isColorValid, parseUrl, pluginToPaletteSettings } from "../../utils/basicUtils";
|
|
2
|
+
export var Direction;
|
|
3
|
+
(function (Direction) {
|
|
4
|
+
Direction["Row"] = "row";
|
|
5
|
+
Direction["Column"] = "column";
|
|
6
|
+
})(Direction || (Direction = {}));
|
|
7
|
+
export var AliasMode;
|
|
8
|
+
(function (AliasMode) {
|
|
9
|
+
AliasMode["Both"] = "Both";
|
|
10
|
+
AliasMode["Alias"] = "Prefer Alias";
|
|
11
|
+
})(AliasMode || (AliasMode = {}));
|
|
12
|
+
export var CopyFormat;
|
|
13
|
+
(function (CopyFormat) {
|
|
14
|
+
CopyFormat["Raw"] = "Raw";
|
|
15
|
+
CopyFormat["Value"] = "Value";
|
|
16
|
+
})(CopyFormat || (CopyFormat = {}));
|
|
17
|
+
export const defaultSettings = {
|
|
18
|
+
noticeDuration: 10000,
|
|
19
|
+
errorPulse: true,
|
|
20
|
+
aliasMode: AliasMode.Both,
|
|
21
|
+
corners: true,
|
|
22
|
+
hoverWhileEditing: false,
|
|
23
|
+
reloadDelay: 5,
|
|
24
|
+
copyFormat: CopyFormat.Raw,
|
|
25
|
+
height: 150,
|
|
26
|
+
width: 700,
|
|
27
|
+
direction: Direction.Column,
|
|
28
|
+
gradient: false,
|
|
29
|
+
preventHover: false,
|
|
30
|
+
override: false
|
|
17
31
|
};
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
export var Status;
|
|
33
|
+
(function (Status) {
|
|
34
|
+
Status["VALID"] = "Valid";
|
|
35
|
+
Status["INVALID_COLORS"] = "Invalid Colors";
|
|
36
|
+
Status["INVALID_SETTINGS"] = "Invalid Settings";
|
|
37
|
+
Status["INVALID_COLORS_AND_SETTINGS"] = "Invalid Colors & Settings";
|
|
38
|
+
Status["INVALID_GRADIENT"] = "Invalid Gradient";
|
|
39
|
+
})(Status || (Status = {}));
|
|
40
|
+
export const urlRegex = /(?:https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)?[a-zA-Z0-9]{2,}(?:\.[a-zA-Z0-9]{2,})(?:\.[a-zA-Z0-9]{2,})?\/(?:palette\/)?([a-zA-Z0-9-]{2,})/;
|
|
41
|
+
export class PaletteError extends Error {
|
|
42
|
+
constructor(status, message = '') {
|
|
43
|
+
super(message);
|
|
44
|
+
this.status = status;
|
|
45
|
+
}
|
|
24
46
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Parses input & extracts settings
|
|
49
|
+
* @param input settings from codeblock
|
|
50
|
+
* @returns PaletteSettings or Status if settings are not valid
|
|
51
|
+
*/
|
|
52
|
+
export function parseSettings(input) {
|
|
53
|
+
try {
|
|
54
|
+
// Extract JSON settings from the palette
|
|
55
|
+
return JSON.parse(input);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return Status.INVALID_SETTINGS;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Parses input & extracts colors based on color space or URL
|
|
63
|
+
* @param input colors from codeblock
|
|
64
|
+
* @returns Array of colors or Status if colors are not valid
|
|
65
|
+
*/
|
|
66
|
+
export function parseColors(input, override) {
|
|
67
|
+
let colors = input.flatMap((color) => {
|
|
68
|
+
// Split RGB / HSL delimited by semicolons
|
|
69
|
+
if (color.includes('(')) {
|
|
70
|
+
return color.split(';').flatMap((postSplitColor) => postSplitColor.trim())
|
|
71
|
+
// Remove whitespace elements from array
|
|
72
|
+
.filter((color) => color !== '');
|
|
73
|
+
}
|
|
74
|
+
// Split colors delimited by commas
|
|
75
|
+
return color.split(',').flatMap((postSplitColor) => {
|
|
76
|
+
return postSplitColor.trim();
|
|
77
|
+
});
|
|
78
|
+
// Remove semicolons
|
|
79
|
+
}).flatMap((color) => color.trim().replace(';', ''));
|
|
80
|
+
// Combine colors array into string
|
|
81
|
+
const rawColors = colors.join('');
|
|
82
|
+
// If URL parse and return
|
|
83
|
+
if (rawColors.match(urlRegex))
|
|
84
|
+
return parseUrl(rawColors);
|
|
85
|
+
// Return status if colors are invalid
|
|
86
|
+
if (!override) {
|
|
87
|
+
for (let color of colors) {
|
|
88
|
+
if (!isColorValid(color))
|
|
89
|
+
return Status.INVALID_COLORS;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Return final colors array
|
|
93
|
+
return colors;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Calculates colors and settings based on codeblock contents
|
|
97
|
+
*/
|
|
98
|
+
export function calcColorsAndSettings(input, pluginSettings) {
|
|
99
|
+
// Splits input by newline creating an array
|
|
100
|
+
const split = input.split('\n');
|
|
101
|
+
// Returns true if palette settings are defined
|
|
102
|
+
const hasSettings = split.some((val) => val.includes(('{')));
|
|
103
|
+
// Remove and parse the last split index (settings are always defined on the last index)
|
|
104
|
+
let settings = hasSettings ? parseSettings(split.pop() || '') : undefined;
|
|
105
|
+
// Get PaletteSettings if valid or plugin defaults if invalid
|
|
106
|
+
let settingsObj = typeof settings === 'object' ? settings : pluginToPaletteSettings(pluginSettings);
|
|
107
|
+
return { colors: parseColors(split, settingsObj.override), settings: settings };
|
|
34
108
|
}
|
|
35
|
-
export {
|
|
36
|
-
u as AliasMode,
|
|
37
|
-
f as CopyFormat,
|
|
38
|
-
s as Direction,
|
|
39
|
-
h as PaletteError,
|
|
40
|
-
p as Status,
|
|
41
|
-
c as defaultSettings,
|
|
42
|
-
v as parseColors,
|
|
43
|
-
d as urlRegex
|
|
44
|
-
};
|