@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.
Files changed (52) hide show
  1. package/dist/components/absolute-container/absolute-container.js +113 -91
  2. package/dist/components/absolute-container/absolute-container.stories.js +36 -0
  3. package/dist/components/absolute-container/index.js +1 -1
  4. package/dist/components/bottom-sheet/bottom-sheet.js +415 -308
  5. package/dist/components/bottom-sheet/bottom-sheet.stories.js +43 -0
  6. package/dist/components/bottom-sheet/bottom-sheet.test.js +15 -0
  7. package/dist/components/bottom-sheet/index.js +1 -1
  8. package/dist/components/canvas/canvas-base.d.ts +2 -1
  9. package/dist/components/canvas/canvas-base.d.ts.map +1 -1
  10. package/dist/components/canvas/canvas-base.js +56 -44
  11. package/dist/components/canvas/canvas-gradient.js +61 -45
  12. package/dist/components/canvas/canvas-image.js +158 -111
  13. package/dist/components/canvas/index.js +2 -2
  14. package/dist/components/carousel-scroller/carousel-scroller.js +133 -121
  15. package/dist/components/carousel-scroller/carousel-scroller.stories.js +40 -0
  16. package/dist/components/carousel-scroller/index.js +1 -1
  17. package/dist/components/color-palette/color-palette-utils.js +105 -41
  18. package/dist/components/color-palette/color-palette.js +429 -337
  19. package/dist/components/color-palette/component/color-palette-component.js +184 -142
  20. package/dist/components/color-palette/component/color-palette-component.stories.js +74 -0
  21. package/dist/components/color-palette/component/index.js +1 -0
  22. package/dist/components/color-palette/editor/color-palette-editor.js +702 -591
  23. package/dist/components/color-palette/editor/color-palette-editor.stories.js +39 -0
  24. package/dist/components/color-palette/editor/index.js +1 -0
  25. package/dist/components/color-palette/index.js +5 -7
  26. package/dist/components/color-palette/item/color-palette-item-edit.js +114 -87
  27. package/dist/components/color-palette/item/color-palette-item.js +155 -140
  28. package/dist/components/color-palette/item/index.js +2 -0
  29. package/dist/components/color-palette/menu/color-palette-menu.js +241 -217
  30. package/dist/components/color-palette/menu/color-palette-reorder.js +117 -103
  31. package/dist/components/color-palette/menu/index.js +2 -0
  32. package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +90 -0
  33. package/dist/components/color-palette/storybook/color-palette-valid.stories.js +295 -0
  34. package/dist/components/color-palette/storybook/color-palette.stories.js +76 -0
  35. package/dist/components/tool-tip/Tooltip2.js +103 -0
  36. package/dist/components/tool-tip/index.js +1 -1
  37. package/dist/components/tool-tip/tool-tip.d.ts +1 -0
  38. package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
  39. package/dist/components/tool-tip/tool-tip.js +125 -102
  40. package/dist/components/tool-tip/tool-tip.stories.js +30 -0
  41. package/dist/index.js +6 -14
  42. package/dist/utils/EventEmitter.js +23 -23
  43. package/dist/utils/basicUtils.js +149 -32
  44. package/dist/utils/dragDropUtils.js +121 -0
  45. package/dist/utils/generateUtils.js +73 -39
  46. package/dist/utils/types.d.ts +1 -1
  47. package/dist/utils/types.d.ts.map +1 -1
  48. package/dist/utils/types.js +1 -0
  49. package/package.json +1 -1
  50. package/dist/_virtual/_commonjsHelpers.js +0 -8
  51. package/dist/_virtual/x11.js +0 -4
  52. package/dist/node_modules/colorsea/colors/x11.js +0 -14
@@ -1,125 +1,137 @@
1
- import { css as a, LitElement as c, html as h } from "lit";
2
- import { query as p, customElement as u } from "lit/decorators.js";
3
- import { EventEmitter as m } from "../../utils/EventEmitter.js";
4
- var g = Object.defineProperty, b = Object.getOwnPropertyDescriptor, d = (t, r, i, o) => {
5
- for (var e = o > 1 ? void 0 : o ? b(r, i) : r, s = t.length - 1, n; s >= 0; s--)
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
- let l = class extends c {
10
- constructor() {
11
- super(), this.slotChildren = [], this.emitter = new m(), this.currentSlide = 0, this.debouncers = /* @__PURE__ */ new WeakMap(), this.emitter.on("slotsLoaded", (t) => {
12
- this.slotChildren = t;
13
- });
14
- }
15
- disconnectedCallback() {
16
- super.disconnectedCallback(), this.emitter.clear();
17
- }
18
- render() {
19
- return h`
20
- <div class="container">
21
- <button @click=${this.scrollToPrevSlide}><</button>
22
- <button @click=${this.scrollToNextSlide}>></button>
23
- <div>
24
- <slot @slotchange=${this.slotChange}></slot>
25
- </div>
26
- </div>
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
- getCurrentSlide() {
30
- return this.slotChildren[this.currentSlide - 1];
31
- }
32
- scrollToPrevSlide() {
33
- var t;
34
- this.currentSlide = this.currentSlide === 0 ? this.currentSlide = this.slotChildren.length - 1 : this.currentSlide - 1, (t = this.slotChildren.at(this.currentSlide)) == null || t.scrollIntoView({ behavior: "smooth", block: "nearest" });
35
- }
36
- scrollToNextSlide() {
37
- var t;
38
- this.currentSlide = this.currentSlide === this.slotChildren.length - 1 ? 0 : this.currentSlide + 1, (t = this.slotChildren.at(this.currentSlide)) == null || t.scrollIntoView({ behavior: "smooth", block: "nearest" });
39
- }
40
- slotChange() {
41
- const t = Array.from(
42
- this.slotEl.assignedElements().map((i) => i)
43
- );
44
- clearTimeout(this.debouncers.get(this.slotEl));
45
- const r = setTimeout(
46
- () => this.emitter.emit("slotsLoaded", t),
47
- 100
48
- );
49
- this.debouncers.set(this.slotEl, r);
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
- l.styles = a`
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
- d([
118
- p("slot")
119
- ], l.prototype, "slotEl", 2);
120
- l = d([
121
- u("carousel-scroller")
122
- ], l);
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 "./carousel-scroller.js";
1
+ import './carousel-scroller';
@@ -1,44 +1,108 @@
1
- import { parseUrl as i, isColorValid as n } from "../../utils/basicUtils.js";
2
- var s = /* @__PURE__ */ ((r) => (r.Row = "row", r.Column = "column", r))(s || {}), u = /* @__PURE__ */ ((r) => (r.Both = "Both", r.Alias = "Prefer Alias", r))(u || {}), f = /* @__PURE__ */ ((r) => (r.Raw = "Raw", r.Value = "Value", r))(f || {});
3
- const c = {
4
- noticeDuration: 1e4,
5
- errorPulse: !0,
6
- aliasMode: "Both",
7
- corners: !0,
8
- hoverWhileEditing: !1,
9
- reloadDelay: 5,
10
- copyFormat: "Raw",
11
- height: 150,
12
- width: 700,
13
- direction: "column",
14
- gradient: !1,
15
- preventHover: !1,
16
- override: !1
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 p = /* @__PURE__ */ ((r) => (r.VALID = "Valid", r.INVALID_COLORS = "Invalid Colors", r.INVALID_SETTINGS = "Invalid Settings", r.INVALID_COLORS_AND_SETTINGS = "Invalid Colors & Settings", r.INVALID_GRADIENT = "Invalid Gradient", r))(p || {});
19
- const d = /(?: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,})/;
20
- class h extends Error {
21
- constructor(l, t = "") {
22
- super(t), this.status = l;
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
- function v(r, l) {
26
- let t = r.flatMap((e) => e.includes("(") ? e.split(";").flatMap((a) => a.trim()).filter((a) => a !== "") : e.split(",").flatMap((a) => a.trim())).flatMap((e) => e.trim().replace(";", ""));
27
- const o = t.join("");
28
- if (o.match(d)) return i(o);
29
- if (!l) {
30
- for (let e of t)
31
- if (!n(e)) return "Invalid Colors";
32
- }
33
- return t;
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
- };