smoothly 0.1.83 → 0.1.87
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/cjs/{generate-a6821b82.js → generate-f9a36f25.js} +1 -1
- package/dist/cjs/index-328edd81.js +1599 -0
- package/dist/cjs/{index-fc82954f.js → index-ac32385c.js} +230 -184
- package/dist/cjs/index.cjs.js +214 -116
- package/dist/cjs/smoothly-accordion_47.cjs.entry.js +1031 -19112
- package/dist/cjs/smoothly-calendar.cjs.entry.js +7 -15
- package/dist/cjs/smoothly-display-amount.cjs.entry.js +1 -1
- package/dist/cjs/smoothly-display.cjs.entry.js +2 -1
- package/dist/cjs/smoothly-input-date-range.cjs.entry.js +2 -2
- package/dist/cjs/smoothly-input-date.cjs.entry.js +2 -2
- package/dist/cjs/smoothly-input-month.cjs.entry.js +2 -2
- package/dist/cjs/smoothly-input.cjs.entry.js +17 -10
- package/dist/cjs/smoothly-select-demo.cjs.entry.js +2 -2
- package/dist/collection/components/calendar/index.js +9 -17
- package/dist/collection/components/display/index.js +1 -1
- package/dist/collection/components/input/index.js +17 -10
- package/dist/collection/components/input-date/style.css +4 -0
- package/dist/collection/components/input-date-range/style.css +4 -0
- package/dist/collection/components/select-demo/index.js +2 -2
- package/dist/collection/index.js +1 -1
- package/dist/collection/utilities/Cosmetic/Color/CommaRgb.js +90 -0
- package/dist/collection/utilities/Cosmetic/Color/Hex.js +11 -0
- package/dist/collection/utilities/Cosmetic/Color/Hsl.js +32 -0
- package/dist/collection/utilities/{colorNames.js → Cosmetic/Color/Name.js} +9 -1
- package/dist/collection/utilities/Cosmetic/Color/Rgb.js +19 -0
- package/dist/collection/utilities/Cosmetic/Color/index.js +23 -0
- package/dist/collection/utilities/Cosmetic/index.js +40 -0
- package/dist/collection/utilities/index.js +1 -1
- package/dist/custom-elements/index.js +1387 -19577
- package/dist/esm/{generate-776b3b0f.js → generate-50b98474.js} +1 -1
- package/dist/esm/index-1be6d668.js +1597 -0
- package/dist/{smoothly/index-a28d88cf.js → esm/index-a5a08f46.js} +230 -184
- package/dist/esm/index.js +215 -116
- package/dist/esm/smoothly-accordion_47.entry.js +1031 -19112
- package/dist/esm/smoothly-calendar.entry.js +7 -15
- package/dist/esm/smoothly-display-amount.entry.js +1 -1
- package/dist/esm/smoothly-display.entry.js +2 -1
- package/dist/esm/smoothly-input-date-range.entry.js +2 -2
- package/dist/esm/smoothly-input-date.entry.js +2 -2
- package/dist/esm/smoothly-input-month.entry.js +2 -2
- package/dist/esm/smoothly-input.entry.js +17 -10
- package/dist/esm/smoothly-select-demo.entry.js +2 -2
- package/dist/smoothly/{generate-776b3b0f.js → generate-50b98474.js} +1 -1
- package/dist/smoothly/index-1be6d668.js +1597 -0
- package/dist/{esm/index-a28d88cf.js → smoothly/index-a5a08f46.js} +230 -184
- package/dist/smoothly/index.esm.js +215 -116
- package/dist/smoothly/p-7b43df84.entry.js +1 -0
- package/dist/smoothly/smoothly-calendar.entry.js +7 -15
- package/dist/smoothly/smoothly-display-amount.entry.js +1 -1
- package/dist/smoothly/smoothly-display.entry.js +2 -1
- package/dist/smoothly/smoothly-input-date-range.entry.js +2 -2
- package/dist/smoothly/smoothly-input-date.entry.js +2 -2
- package/dist/smoothly/smoothly-input-month.entry.js +2 -2
- package/dist/smoothly/smoothly-input.entry.js +17 -10
- package/dist/smoothly/smoothly-select-demo.entry.js +2 -2
- package/dist/types/components/calendar/index.d.ts +2 -2
- package/dist/types/components/input/index.d.ts +1 -0
- package/dist/types/components.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utilities/Cosmetic/Color/CommaRgb.d.ts +11 -0
- package/dist/types/utilities/Cosmetic/Color/Hex.d.ts +4 -0
- package/dist/types/utilities/Cosmetic/Color/Hsl.d.ts +4 -0
- package/dist/types/utilities/Cosmetic/Color/Name.d.ts +155 -0
- package/dist/types/utilities/Cosmetic/Color/Rgb.d.ts +4 -0
- package/dist/types/utilities/Cosmetic/Color/index.d.ts +170 -0
- package/dist/types/utilities/Cosmetic/index.d.ts +23 -0
- package/dist/types/utilities/index.d.ts +1 -1
- package/package.json +3 -3
- package/dist/cjs/index-42db74b3.js +0 -19931
- package/dist/collection/utilities/colorTransform.js +0 -120
- package/dist/esm/index-36a04e8c.js +0 -19929
- package/dist/smoothly/index-36a04e8c.js +0 -19929
- package/dist/smoothly/p-c4dd9866.entry.js +0 -1
- package/dist/types/utilities/colorNames.d.ts +0 -3
- package/dist/types/utilities/colorTransform.d.ts +0 -8
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-138c41c2.js');
|
|
6
|
-
const index$1 = require('./index-
|
|
7
|
-
const generate = require('./generate-
|
|
6
|
+
const index$1 = require('./index-ac32385c.js');
|
|
7
|
+
const generate = require('./generate-f9a36f25.js');
|
|
8
8
|
require('./_commonjsHelpers-10109b76.js');
|
|
9
9
|
|
|
10
10
|
const styleCss = ".sc-smoothly-calendar-h{display:block;--other-month-opacity:0.5}.sc-smoothly-calendar-h>smoothly-input-month.sc-smoothly-calendar{width:calc(100% - 1em);padding:0.5em 0.5em 0 0.5em}th.sc-smoothly-calendar,td.sc-smoothly-calendar{text-align:center;padding:0.5em;min-width:2em;background-color:rgb(var(--smoothly-default-shade));cursor:pointer;user-select:none}td.currentMonth.sc-smoothly-calendar{color:rgb(var(--smoothly-default-contrast))}td.sc-smoothly-calendar:not(.currentMonth){color:rgba(var(--smoothly-default-contrast), var(--other-month-opacity))}td.sc-smoothly-calendar:nth-child(6):not(.currentMonth).selected,td.sc-smoothly-calendar:nth-child(6):not(.currentMonth).dateRange,td.sc-smoothly-calendar:nth-child(7):not(.currentMonth).selected,td.sc-smoothly-calendar:nth-child(7):not(.currentMonth).dateRange{color:rgba(var(--smoothly-default-contrast))}td.sc-smoothly-calendar:nth-child(6),td.sc-smoothly-calendar:nth-child(7){color:rgb(var(--smoothly-danger-tint))}td.sc-smoothly-calendar:nth-child(6):not(.currentMonth),td.sc-smoothly-calendar:nth-child(7):not(.currentMonth){color:rgba(var(--smoothly-danger-tint), var(--other-month-opacity))}td.sc-smoothly-calendar:not(.selected,.disable).sc-smoothly-calendar:hover{color:rgb(var(--smoothly-primary-contrast));background:rgb(var(--smoothly-primary-tint))}td.selected.sc-smoothly-calendar{color:rgb(var(--smoothly-primary-contrast));background:rgb(var(--smoothly-primary-color))}td.sc-smoothly-calendar:not(.selected,.dateRange).sc-smoothly-calendar:not(:hover).today{background:rgb(var(--smoothly-dark-tint));color:rgb(var(--smoothly-dark-contrast))}td.dateRange.sc-smoothly-calendar{color:rgb(var(--smoothly-primary-contrast));background:rgb(var(--smoothly-primary-tint))}td.disable.sc-smoothly-calendar{cursor:not-allowed;background-color:rgb(var(--smoothly-default-tint), 0.5);color:rgb(var(--smoothly-default-contrast), 0.5)}";
|
|
@@ -44,22 +44,14 @@ let Calendar = class {
|
|
|
44
44
|
event.stopPropagation();
|
|
45
45
|
} }),
|
|
46
46
|
index.h("table", null, index.h("thead", null, index.h("tr", null, generate.weekdays().map(day => (index.h("th", null, day))))), generate.month((_b = this.month) !== null && _b !== void 0 ? _b : this.value).map(week => (index.h("tr", null, week.map(date => {
|
|
47
|
-
var _a, _b, _c
|
|
48
|
-
return (index.h("td", { tabindex: 1, onClick: this.min || this.max
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
: undefined
|
|
52
|
-
: () => this.onClick(date), class: (date == this.value ? ["selected"] : [])
|
|
53
|
-
.concat(...(date == index$1.dist.Date.now() ? ["today"] : []), index$1.dist.Date.firstOfMonth((_c = this.month) !== null && _c !== void 0 ? _c : this.value) == index$1.dist.Date.firstOfMonth(date) ? ["currentMonth"] : [], this.doubleInput
|
|
54
|
-
? date >= ((_d = this.start) !== null && _d !== void 0 ? _d : "") && date <= ((_e = this.end) !== null && _e !== void 0 ? _e : "")
|
|
47
|
+
var _a, _b, _c;
|
|
48
|
+
return (index.h("td", { tabindex: 1, onClick: (this.min || this.max) && (date < this.min || date > this.max) ? undefined : () => this.onClick(date), class: (date == this.value ? ["selected"] : [])
|
|
49
|
+
.concat(...(date == index$1.dist.Date.now() ? ["today"] : []), index$1.dist.Date.firstOfMonth((_a = this.month) !== null && _a !== void 0 ? _a : this.value) == index$1.dist.Date.firstOfMonth(date) ? ["currentMonth"] : [], this.doubleInput
|
|
50
|
+
? date >= ((_b = this.start) !== null && _b !== void 0 ? _b : "") && date <= ((_c = this.end) !== null && _c !== void 0 ? _c : "")
|
|
55
51
|
? ["dateRange"]
|
|
56
52
|
: []
|
|
57
53
|
: "")
|
|
58
|
-
.concat(...(this.min || this.max
|
|
59
|
-
? date < ((_f = this.min) !== null && _f !== void 0 ? _f : "") || date > ((_g = this.max) !== null && _g !== void 0 ? _g : "")
|
|
60
|
-
? ["disable"]
|
|
61
|
-
: []
|
|
62
|
-
: ""))
|
|
54
|
+
.concat(...(this.min || this.max ? (date < this.min || date > this.max ? ["disable"] : []) : ""))
|
|
63
55
|
.join(" ") }, date.substring(8, 10)));
|
|
64
56
|
}))))),
|
|
65
57
|
];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-138c41c2.js');
|
|
6
|
-
const index$1 = require('./index-
|
|
6
|
+
const index$1 = require('./index-ac32385c.js');
|
|
7
7
|
require('./_commonjsHelpers-10109b76.js');
|
|
8
8
|
|
|
9
9
|
const styleCss = ".sc-smoothly-display-amount-h{display:block}[hidden].sc-smoothly-display-amount-h{display:none}";
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-138c41c2.js');
|
|
6
|
-
const index$1 = require('./index-
|
|
6
|
+
const index$1 = require('./index-328edd81.js');
|
|
7
7
|
require('./_commonjsHelpers-10109b76.js');
|
|
8
|
+
require('./index-ac32385c.js');
|
|
8
9
|
|
|
9
10
|
const styleCss = ".sc-smoothly-display-h{display:block}[hidden].sc-smoothly-display-h{display:none}";
|
|
10
11
|
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-138c41c2.js');
|
|
6
|
-
const index$1 = require('./index-
|
|
6
|
+
const index$1 = require('./index-ac32385c.js');
|
|
7
7
|
require('./_commonjsHelpers-10109b76.js');
|
|
8
8
|
|
|
9
|
-
const styleCss = ".sc-smoothly-input-date-range-h{position:relative;display:block}.sc-smoothly-input-date-range-h>nav.sc-smoothly-input-date-range{position:absolute;z-index:10;top:3.5em;background-color:rgb(var(--smoothly-default-shade));max-width:22em}.sc-smoothly-input-date-range-h>div.sc-smoothly-input-date-range{position:fixed;width:100vw;height:100vh;z-index:2}.sc-smoothly-input-date-range-h>nav.sc-smoothly-input-date-range>.arrow.sc-smoothly-input-date-range{position:absolute;z-index:9;transform:translate(10em, -.55em) rotate(45deg);width:1em;height:1em;background-color:rgb(var(--smoothly-default-shade))}.sc-smoothly-input-date-range-h>section.sc-smoothly-input-date-range{display:flex;flex-direction:row;align-items:center}.sc-smoothly-input-date-range-h>smoothly-input.sc-smoothly-input-date-range{padding:0}";
|
|
9
|
+
const styleCss = ".sc-smoothly-input-date-range-h{position:relative;display:block}.sc-smoothly-input-date-range-h>nav.sc-smoothly-input-date-range{position:absolute;z-index:10;top:3.5em;background-color:rgb(var(--smoothly-default-shade));max-width:22em}.sc-smoothly-input-date-range-h>div.sc-smoothly-input-date-range{position:fixed;top:0px;left:0px;right:0px;bottom:0px;width:100vw;height:100vh;z-index:2}.sc-smoothly-input-date-range-h>nav.sc-smoothly-input-date-range>.arrow.sc-smoothly-input-date-range{position:absolute;z-index:9;transform:translate(10em, -.55em) rotate(45deg);width:1em;height:1em;background-color:rgb(var(--smoothly-default-shade))}.sc-smoothly-input-date-range-h>section.sc-smoothly-input-date-range{display:flex;flex-direction:row;align-items:center}.sc-smoothly-input-date-range-h>smoothly-input.sc-smoothly-input-date-range{padding:0}";
|
|
10
10
|
|
|
11
11
|
let InputDateRange = class {
|
|
12
12
|
constructor(hostRef) {
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-138c41c2.js');
|
|
6
|
-
const index$1 = require('./index-
|
|
6
|
+
const index$1 = require('./index-ac32385c.js');
|
|
7
7
|
require('./_commonjsHelpers-10109b76.js');
|
|
8
8
|
|
|
9
|
-
const styleCss = ".sc-smoothly-input-date-h{position:relative}nav.sc-smoothly-input-date{position:absolute;z-index:10;top:3.5em;background-color:rgb(var(--smoothly-default-shade));max-width:22em}.sc-smoothly-input-date-h>div.sc-smoothly-input-date{position:fixed;width:100vw;height:100vh;z-index:2}.sc-smoothly-input-date-h>nav.sc-smoothly-input-date>.arrow.sc-smoothly-input-date{position:absolute;z-index:9;transform:translate(2em, -.55em) rotate(45deg);width:1em;height:1em;background-color:rgb(var(--smoothly-default-shade))}";
|
|
9
|
+
const styleCss = ".sc-smoothly-input-date-h{position:relative}nav.sc-smoothly-input-date{position:absolute;z-index:10;top:3.5em;background-color:rgb(var(--smoothly-default-shade));max-width:22em}.sc-smoothly-input-date-h>div.sc-smoothly-input-date{position:fixed;top:0px;left:0px;right:0px;bottom:0px;width:100vw;height:100vh;z-index:2}.sc-smoothly-input-date-h>nav.sc-smoothly-input-date>.arrow.sc-smoothly-input-date{position:absolute;z-index:9;transform:translate(2em, -.55em) rotate(45deg);width:1em;height:1em;background-color:rgb(var(--smoothly-default-shade))}";
|
|
10
10
|
|
|
11
11
|
let InputDate = class {
|
|
12
12
|
constructor(hostRef) {
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-138c41c2.js');
|
|
6
|
-
const index$1 = require('./index-
|
|
7
|
-
const generate = require('./generate-
|
|
6
|
+
const index$1 = require('./index-ac32385c.js');
|
|
7
|
+
const generate = require('./generate-f9a36f25.js');
|
|
8
8
|
require('./_commonjsHelpers-10109b76.js');
|
|
9
9
|
|
|
10
10
|
const styleCss = ".sc-smoothly-input-month-h{display:flex;justify-content:space-between;font-size:large}smoothly-icon.sc-smoothly-input-month{font-size:smaller}";
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-138c41c2.js');
|
|
6
|
-
const index$
|
|
6
|
+
const index$2 = require('./index-ac32385c.js');
|
|
7
|
+
const index$1 = require('./index-328edd81.js');
|
|
7
8
|
require('./_commonjsHelpers-10109b76.js');
|
|
8
9
|
|
|
9
10
|
const styleCss = ".sc-smoothly-input-h{display:block;position:relative}[hidden].sc-smoothly-input-h{display:none}label.sc-smoothly-input{position:absolute;left:0.4em;top:0.6em;color:rgb(var(--smoothly-text-tint));opacity:0.8;user-select:none;cursor:inherit;transition:font-size 0.1s;transition-timing-function:ease}input.sc-smoothly-input{padding:1em 0.2em 0.2em 0.2em;width:calc(100% - 0.4em);background:none;border:0;z-index:1;position:relative;font-size:1rem;font-family:var(--smoothly-font-family)}smoothly-icon.sc-smoothly-input{display:none;position:absolute;right:0.2em;top:0.6em}input.sc-smoothly-input:invalid+smoothly-icon.sc-smoothly-input{display:block}.has-value.sc-smoothly-input-h>label.sc-smoothly-input{top:0.3em;top:0.4em;font-size:60%;z-index:0}.sc-smoothly-input-h:focus-within>label.sc-smoothly-input{top:0.3em;top:0.4em;font-size:60%;z-index:0}input.sc-smoothly-input:focus{outline:none}input.sc-smoothly-input:-webkit-autofill,input.sc-smoothly-input:-webkit-autofill:hover,input.sc-smoothly-input:-webkit-autofill:focus,input.sc-smoothly-input:-webkit-autofill:active{box-shadow:0 0 0 30px unset inset !important;-webkit-box-shadow:0 0 0 30px unset inset !important}input.sc-smoothly-input:-webkit-autofill{-webkit-text-fill-color:unset !important}input.sc-smoothly-input:-internal-autofill-previewed,input.sc-smoothly-input:-internal-autofill-selected,textarea.sc-smoothly-input:-internal-autofill-previewed,textarea.sc-smoothly-input:-internal-autofill-selected,select.sc-smoothly-input:-internal-autofill-previewed,select.sc-smoothly-input:-internal-autofill-selected{background-color:none !important;background-image:none !important;color:unset !important}";
|
|
@@ -27,27 +28,30 @@ let SmoothlyInput = class {
|
|
|
27
28
|
result = index$1.dist.get("price", this.currency);
|
|
28
29
|
break;
|
|
29
30
|
default:
|
|
30
|
-
result = index$1.dist.get(this.type);
|
|
31
|
+
result = index$1.dist.get(this.type, getLocale());
|
|
31
32
|
break;
|
|
32
33
|
}
|
|
33
34
|
return result || index$1.dist.get("text");
|
|
34
35
|
}
|
|
36
|
+
newState(state) {
|
|
37
|
+
const formatter = this.formatter;
|
|
38
|
+
return formatter.format(index$1.dist.StateEditor.copy(formatter.unformat(index$1.dist.StateEditor.copy(state))));
|
|
39
|
+
}
|
|
35
40
|
valueWatcher(value, before) {
|
|
36
41
|
if (this.lastValue != value) {
|
|
37
42
|
this.lastValue = value;
|
|
38
|
-
this.state = Object.assign(Object.assign({}, this.state), { value: this.
|
|
43
|
+
this.state = Object.assign(Object.assign({}, this.state), { value: this.newState({ value: this.formatter.toString(value), selection: this.state.selection }).value });
|
|
39
44
|
}
|
|
40
45
|
if (value != before)
|
|
41
46
|
this.smoothlyChanged.emit({ name: this.name, value });
|
|
42
47
|
}
|
|
43
48
|
componentWillLoad() {
|
|
44
|
-
const
|
|
45
|
-
const value = formatter.toString(this.value) || "";
|
|
49
|
+
const value = this.formatter.toString(this.value) || "";
|
|
46
50
|
const start = value.length;
|
|
47
|
-
this.state =
|
|
51
|
+
this.state = this.newState({
|
|
48
52
|
value,
|
|
49
53
|
selection: { start, end: start, direction: "none" },
|
|
50
|
-
})
|
|
54
|
+
});
|
|
51
55
|
}
|
|
52
56
|
componentDidRender() {
|
|
53
57
|
if (this.keepFocusOnReRender) {
|
|
@@ -59,8 +63,7 @@ let SmoothlyInput = class {
|
|
|
59
63
|
this.keepFocusOnReRender = keepFocus;
|
|
60
64
|
}
|
|
61
65
|
async setSelectionRange(start, end, direction) {
|
|
62
|
-
|
|
63
|
-
this.state = formatter.format(index$1.dist.StateEditor.copy(formatter.unformat(index$1.dist.StateEditor.copy(Object.assign(Object.assign({}, this.state), { selection: { start, end, direction: direction != undefined ? direction : this.state.selection.direction } })))));
|
|
66
|
+
this.state = this.newState(Object.assign(Object.assign({}, this.state), { selection: { start, end, direction: direction != undefined ? direction : this.state.selection.direction } }));
|
|
64
67
|
const after = this.formatter.format(index$1.dist.StateEditor.copy(this.formatter.unformat(index$1.dist.StateEditor.copy(Object.assign({}, this.state)))));
|
|
65
68
|
this.updateBackend(after, this.inputElement);
|
|
66
69
|
}
|
|
@@ -77,7 +80,7 @@ let SmoothlyInput = class {
|
|
|
77
80
|
end: backend.selectionEnd != undefined ? backend.selectionEnd : backend.value.length,
|
|
78
81
|
direction: backend.selectionDirection ? backend.selectionDirection : "none",
|
|
79
82
|
} });
|
|
80
|
-
const after = this.
|
|
83
|
+
const after = this.newState(Object.assign({}, this.state));
|
|
81
84
|
this.updateBackend(after, backend);
|
|
82
85
|
}
|
|
83
86
|
onKeyDown(event) {
|
|
@@ -163,6 +166,10 @@ let SmoothlyInput = class {
|
|
|
163
166
|
"value": ["valueWatcher"]
|
|
164
167
|
}; }
|
|
165
168
|
};
|
|
169
|
+
function getLocale() {
|
|
170
|
+
const result = navigator.language;
|
|
171
|
+
return index$2.dist.Locale.is(result) ? result : index$2.dist.Language.is(result) ? index$2.dist.Locale.toLocale(result) : undefined;
|
|
172
|
+
}
|
|
166
173
|
SmoothlyInput.style = styleCss;
|
|
167
174
|
|
|
168
175
|
exports.smoothly_input = SmoothlyInput;
|
|
@@ -25,8 +25,8 @@ let SmoothlySelectDemo = class {
|
|
|
25
25
|
index.h("smoothly-select", { identifier: "currency" }, this.currencies.map(option => this.currency == option ? (index.h("option", { value: option, selected: true }, option)) : (index.h("option", { value: option }, option)))),
|
|
26
26
|
index.h("smoothly-select", { identifier: "language" }, index.h("optgroup", { label: "Nordic" }, index.h("option", { value: "sv" }, "Swedish"), index.h("option", { value: "da", selected: true }, "Danish"), index.h("option", { value: "no" }, "Norwegian")), index.h("optgroup", { label: "Other" }, index.h("option", { value: "en" }, "English"))),
|
|
27
27
|
index.h("smoothly-select", { identifier: "quantity", ref: e => (this.quantityElement = e) }, index.h("option", { value: "1" }, "1"), index.h("option", { value: "2" }, "2"), index.h("option", { value: "3" }, "3")),
|
|
28
|
-
index.h("smoothly-input-date", { max: "2021-12-30", min: "2021-10-10" }, "Date"),
|
|
29
|
-
index.h("smoothly-input-date-range", {
|
|
28
|
+
index.h("smoothly-input-date", { value: "2021-10-28", max: "2021-12-30", min: "2021-10-10" }, "Date"),
|
|
29
|
+
index.h("smoothly-input-date-range", { start: "2021-10-28", end: "2021-11-27", min: "2021-10-10", max: "2021-12-30" }),
|
|
30
30
|
index.h("smoothly-selector", null, index.h("smoothly-item", { value: "1" }, "January"), index.h("smoothly-item", { value: "2" }, "February"), index.h("smoothly-item", { value: "3" }, "March"), index.h("smoothly-item", { value: "4" }, "April"), index.h("smoothly-item", { value: "5" }, "May"), index.h("smoothly-item", { value: "6" }, "June"), index.h("smoothly-item", { value: "7" }, "July"), index.h("smoothly-item", { value: "8" }, "August"), index.h("smoothly-item", { value: "9" }, "September"), index.h("smoothly-item", { value: "10" }, "October"), index.h("smoothly-item", { value: "11" }, "November"), index.h("smoothly-item", { value: "12" }, "December")),
|
|
31
31
|
index.h("button", { onClick: () => this.alertf() }, "press here"),
|
|
32
32
|
index.h("smoothly-picker", { label: "Filter", "empty-menu-label": "Sorry, we're out of options.", "max-height": "58px", multiple: true, options: [
|
|
@@ -35,22 +35,14 @@ export class Calendar {
|
|
|
35
35
|
h("thead", null,
|
|
36
36
|
h("tr", null, generate.weekdays().map(day => (h("th", null, day))))),
|
|
37
37
|
generate.month((_b = this.month) !== null && _b !== void 0 ? _b : this.value).map(week => (h("tr", null, week.map(date => {
|
|
38
|
-
var _a, _b, _c
|
|
39
|
-
return (h("td", { tabindex: 1, onClick: this.min || this.max
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
: undefined
|
|
43
|
-
: () => this.onClick(date), class: (date == this.value ? ["selected"] : [])
|
|
44
|
-
.concat(...(date == Date.now() ? ["today"] : []), Date.firstOfMonth((_c = this.month) !== null && _c !== void 0 ? _c : this.value) == Date.firstOfMonth(date) ? ["currentMonth"] : [], this.doubleInput
|
|
45
|
-
? date >= ((_d = this.start) !== null && _d !== void 0 ? _d : "") && date <= ((_e = this.end) !== null && _e !== void 0 ? _e : "")
|
|
38
|
+
var _a, _b, _c;
|
|
39
|
+
return (h("td", { tabindex: 1, onClick: (this.min || this.max) && (date < this.min || date > this.max) ? undefined : () => this.onClick(date), class: (date == this.value ? ["selected"] : [])
|
|
40
|
+
.concat(...(date == Date.now() ? ["today"] : []), Date.firstOfMonth((_a = this.month) !== null && _a !== void 0 ? _a : this.value) == Date.firstOfMonth(date) ? ["currentMonth"] : [], this.doubleInput
|
|
41
|
+
? date >= ((_b = this.start) !== null && _b !== void 0 ? _b : "") && date <= ((_c = this.end) !== null && _c !== void 0 ? _c : "")
|
|
46
42
|
? ["dateRange"]
|
|
47
43
|
: []
|
|
48
44
|
: "")
|
|
49
|
-
.concat(...(this.min || this.max
|
|
50
|
-
? date < ((_f = this.min) !== null && _f !== void 0 ? _f : "") || date > ((_g = this.max) !== null && _g !== void 0 ? _g : "")
|
|
51
|
-
? ["disable"]
|
|
52
|
-
: []
|
|
53
|
-
: ""))
|
|
45
|
+
.concat(...(this.min || this.max ? (date < this.min || date > this.max ? ["disable"] : []) : ""))
|
|
54
46
|
.join(" ") }, date.substring(8, 10)));
|
|
55
47
|
}))))),
|
|
56
48
|
];
|
|
@@ -158,7 +150,7 @@ export class Calendar {
|
|
|
158
150
|
"mutable": true,
|
|
159
151
|
"complexType": {
|
|
160
152
|
"original": "Date",
|
|
161
|
-
"resolved": "string
|
|
153
|
+
"resolved": "string",
|
|
162
154
|
"references": {
|
|
163
155
|
"Date": {
|
|
164
156
|
"location": "import",
|
|
@@ -167,7 +159,7 @@ export class Calendar {
|
|
|
167
159
|
}
|
|
168
160
|
},
|
|
169
161
|
"required": false,
|
|
170
|
-
"optional":
|
|
162
|
+
"optional": false,
|
|
171
163
|
"docs": {
|
|
172
164
|
"tags": [],
|
|
173
165
|
"text": ""
|
|
@@ -180,7 +172,7 @@ export class Calendar {
|
|
|
180
172
|
"mutable": true,
|
|
181
173
|
"complexType": {
|
|
182
174
|
"original": "Date",
|
|
183
|
-
"resolved": "string
|
|
175
|
+
"resolved": "string",
|
|
184
176
|
"references": {
|
|
185
177
|
"Date": {
|
|
186
178
|
"location": "import",
|
|
@@ -189,7 +181,7 @@ export class Calendar {
|
|
|
189
181
|
}
|
|
190
182
|
},
|
|
191
183
|
"required": false,
|
|
192
|
-
"optional":
|
|
184
|
+
"optional": false,
|
|
193
185
|
"docs": {
|
|
194
186
|
"tags": [],
|
|
195
187
|
"text": ""
|
|
@@ -76,7 +76,7 @@ export class SmoothlyDisplay {
|
|
|
76
76
|
"mutable": false,
|
|
77
77
|
"complexType": {
|
|
78
78
|
"original": "Currency",
|
|
79
|
-
"resolved": "
|
|
79
|
+
"resolved": "\"AED\" | \"AFN\" | \"ALL\" | \"AMD\" | \"ANG\" | \"AOA\" | \"ARS\" | \"AUD\" | \"AWG\" | \"AZN\" | \"BAM\" | \"BBD\" | \"BDT\" | \"BGN\" | \"BHD\" | \"BIF\" | \"BMD\" | \"BND\" | \"BOB\" | \"BOV\" | \"BRL\" | \"BSD\" | \"BTN\" | \"BWP\" | \"BYN\" | \"BZD\" | \"CAD\" | \"CDF\" | \"CHE\" | \"CHF\" | \"CHW\" | \"CLF\" | \"CLP\" | \"CNY\" | \"COP\" | \"COU\" | \"CRC\" | \"CUC\" | \"CUP\" | \"CVE\" | \"CZK\" | \"DJF\" | \"DKK\" | \"DOP\" | \"DZD\" | \"EGP\" | \"ERN\" | \"ETB\" | \"EUR\" | \"FJD\" | \"FKP\" | \"GBP\" | \"GEL\" | \"GHS\" | \"GIP\" | \"GMD\" | \"GNF\" | \"GTQ\" | \"GYD\" | \"HKD\" | \"HNL\" | \"HRK\" | \"HTG\" | \"HUF\" | \"IDR\" | \"ILS\" | \"INR\" | \"IQD\" | \"IRR\" | \"ISK\" | \"JMD\" | \"JOD\" | \"JPY\" | \"KES\" | \"KGS\" | \"KHR\" | \"KMF\" | \"KPW\" | \"KRW\" | \"KWD\" | \"KYD\" | \"KZT\" | \"LAK\" | \"LBP\" | \"LKR\" | \"LRD\" | \"LSL\" | \"LYD\" | \"MAD\" | \"MDL\" | \"MGA\" | \"MKD\" | \"MMK\" | \"MNT\" | \"MOP\" | \"MRU\" | \"MUR\" | \"MVR\" | \"MWK\" | \"MXN\" | \"MXV\" | \"MYR\" | \"MZN\" | \"NAD\" | \"NGN\" | \"NIO\" | \"NOK\" | \"NPR\" | \"NZD\" | \"OMR\" | \"PAB\" | \"PEN\" | \"PGK\" | \"PHP\" | \"PKR\" | \"PLN\" | \"PYG\" | \"QAR\" | \"RON\" | \"RSD\" | \"RUB\" | \"RWF\" | \"SAR\" | \"SBD\" | \"SCR\" | \"SDG\" | \"SEK\" | \"SGD\" | \"SHP\" | \"SLL\" | \"SOS\" | \"SRD\" | \"SSP\" | \"STN\" | \"SVC\" | \"SYP\" | \"SZL\" | \"THB\" | \"TJS\" | \"TMT\" | \"TND\" | \"TOP\" | \"TRY\" | \"TTD\" | \"TWD\" | \"TZS\" | \"UAH\" | \"UGX\" | \"USD\" | \"USN\" | \"UYI\" | \"UYU\" | \"UYW\" | \"UZS\" | \"VES\" | \"VND\" | \"VUV\" | \"WST\" | \"XAF\" | \"XAG\" | \"XAU\" | \"XBA\" | \"XBB\" | \"XBC\" | \"XBD\" | \"XCD\" | \"XDR\" | \"XOF\" | \"XPD\" | \"XPF\" | \"XPT\" | \"XSU\" | \"XTS\" | \"XUA\" | \"XXX\" | \"YER\" | \"ZAR\" | \"ZMW\" | \"ZWL\" | undefined",
|
|
80
80
|
"references": {
|
|
81
81
|
"Currency": {
|
|
82
82
|
"location": "import",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Component, Event, h, Host, Method, Prop, Watch } from "@stencil/core";
|
|
2
|
+
import { Language, Locale } from "isoly";
|
|
2
3
|
import { Action, get, StateEditor } from "tidily";
|
|
3
4
|
export class SmoothlyInput {
|
|
4
5
|
constructor() {
|
|
@@ -17,27 +18,30 @@ export class SmoothlyInput {
|
|
|
17
18
|
result = get("price", this.currency);
|
|
18
19
|
break;
|
|
19
20
|
default:
|
|
20
|
-
result = get(this.type);
|
|
21
|
+
result = get(this.type, getLocale());
|
|
21
22
|
break;
|
|
22
23
|
}
|
|
23
24
|
return result || get("text");
|
|
24
25
|
}
|
|
26
|
+
newState(state) {
|
|
27
|
+
const formatter = this.formatter;
|
|
28
|
+
return formatter.format(StateEditor.copy(formatter.unformat(StateEditor.copy(state))));
|
|
29
|
+
}
|
|
25
30
|
valueWatcher(value, before) {
|
|
26
31
|
if (this.lastValue != value) {
|
|
27
32
|
this.lastValue = value;
|
|
28
|
-
this.state = Object.assign(Object.assign({}, this.state), { value: this.
|
|
33
|
+
this.state = Object.assign(Object.assign({}, this.state), { value: this.newState({ value: this.formatter.toString(value), selection: this.state.selection }).value });
|
|
29
34
|
}
|
|
30
35
|
if (value != before)
|
|
31
36
|
this.smoothlyChanged.emit({ name: this.name, value });
|
|
32
37
|
}
|
|
33
38
|
componentWillLoad() {
|
|
34
|
-
const
|
|
35
|
-
const value = formatter.toString(this.value) || "";
|
|
39
|
+
const value = this.formatter.toString(this.value) || "";
|
|
36
40
|
const start = value.length;
|
|
37
|
-
this.state =
|
|
41
|
+
this.state = this.newState({
|
|
38
42
|
value,
|
|
39
43
|
selection: { start, end: start, direction: "none" },
|
|
40
|
-
})
|
|
44
|
+
});
|
|
41
45
|
}
|
|
42
46
|
componentDidRender() {
|
|
43
47
|
if (this.keepFocusOnReRender) {
|
|
@@ -49,8 +53,7 @@ export class SmoothlyInput {
|
|
|
49
53
|
this.keepFocusOnReRender = keepFocus;
|
|
50
54
|
}
|
|
51
55
|
async setSelectionRange(start, end, direction) {
|
|
52
|
-
|
|
53
|
-
this.state = formatter.format(StateEditor.copy(formatter.unformat(StateEditor.copy(Object.assign(Object.assign({}, this.state), { selection: { start, end, direction: direction != undefined ? direction : this.state.selection.direction } })))));
|
|
56
|
+
this.state = this.newState(Object.assign(Object.assign({}, this.state), { selection: { start, end, direction: direction != undefined ? direction : this.state.selection.direction } }));
|
|
54
57
|
const after = this.formatter.format(StateEditor.copy(this.formatter.unformat(StateEditor.copy(Object.assign({}, this.state)))));
|
|
55
58
|
this.updateBackend(after, this.inputElement);
|
|
56
59
|
}
|
|
@@ -67,7 +70,7 @@ export class SmoothlyInput {
|
|
|
67
70
|
end: backend.selectionEnd != undefined ? backend.selectionEnd : backend.value.length,
|
|
68
71
|
direction: backend.selectionDirection ? backend.selectionDirection : "none",
|
|
69
72
|
} });
|
|
70
|
-
const after = this.
|
|
73
|
+
const after = this.newState(Object.assign({}, this.state));
|
|
71
74
|
this.updateBackend(after, backend);
|
|
72
75
|
}
|
|
73
76
|
onKeyDown(event) {
|
|
@@ -345,7 +348,7 @@ export class SmoothlyInput {
|
|
|
345
348
|
"mutable": false,
|
|
346
349
|
"complexType": {
|
|
347
350
|
"original": "Currency",
|
|
348
|
-
"resolved": "
|
|
351
|
+
"resolved": "\"AED\" | \"AFN\" | \"ALL\" | \"AMD\" | \"ANG\" | \"AOA\" | \"ARS\" | \"AUD\" | \"AWG\" | \"AZN\" | \"BAM\" | \"BBD\" | \"BDT\" | \"BGN\" | \"BHD\" | \"BIF\" | \"BMD\" | \"BND\" | \"BOB\" | \"BOV\" | \"BRL\" | \"BSD\" | \"BTN\" | \"BWP\" | \"BYN\" | \"BZD\" | \"CAD\" | \"CDF\" | \"CHE\" | \"CHF\" | \"CHW\" | \"CLF\" | \"CLP\" | \"CNY\" | \"COP\" | \"COU\" | \"CRC\" | \"CUC\" | \"CUP\" | \"CVE\" | \"CZK\" | \"DJF\" | \"DKK\" | \"DOP\" | \"DZD\" | \"EGP\" | \"ERN\" | \"ETB\" | \"EUR\" | \"FJD\" | \"FKP\" | \"GBP\" | \"GEL\" | \"GHS\" | \"GIP\" | \"GMD\" | \"GNF\" | \"GTQ\" | \"GYD\" | \"HKD\" | \"HNL\" | \"HRK\" | \"HTG\" | \"HUF\" | \"IDR\" | \"ILS\" | \"INR\" | \"IQD\" | \"IRR\" | \"ISK\" | \"JMD\" | \"JOD\" | \"JPY\" | \"KES\" | \"KGS\" | \"KHR\" | \"KMF\" | \"KPW\" | \"KRW\" | \"KWD\" | \"KYD\" | \"KZT\" | \"LAK\" | \"LBP\" | \"LKR\" | \"LRD\" | \"LSL\" | \"LYD\" | \"MAD\" | \"MDL\" | \"MGA\" | \"MKD\" | \"MMK\" | \"MNT\" | \"MOP\" | \"MRU\" | \"MUR\" | \"MVR\" | \"MWK\" | \"MXN\" | \"MXV\" | \"MYR\" | \"MZN\" | \"NAD\" | \"NGN\" | \"NIO\" | \"NOK\" | \"NPR\" | \"NZD\" | \"OMR\" | \"PAB\" | \"PEN\" | \"PGK\" | \"PHP\" | \"PKR\" | \"PLN\" | \"PYG\" | \"QAR\" | \"RON\" | \"RSD\" | \"RUB\" | \"RWF\" | \"SAR\" | \"SBD\" | \"SCR\" | \"SDG\" | \"SEK\" | \"SGD\" | \"SHP\" | \"SLL\" | \"SOS\" | \"SRD\" | \"SSP\" | \"STN\" | \"SVC\" | \"SYP\" | \"SZL\" | \"THB\" | \"TJS\" | \"TMT\" | \"TND\" | \"TOP\" | \"TRY\" | \"TTD\" | \"TWD\" | \"TZS\" | \"UAH\" | \"UGX\" | \"USD\" | \"USN\" | \"UYI\" | \"UYU\" | \"UYW\" | \"UZS\" | \"VES\" | \"VND\" | \"VUV\" | \"WST\" | \"XAF\" | \"XAG\" | \"XAU\" | \"XBA\" | \"XBB\" | \"XBC\" | \"XBD\" | \"XCD\" | \"XDR\" | \"XOF\" | \"XPD\" | \"XPF\" | \"XPT\" | \"XSU\" | \"XTS\" | \"XUA\" | \"XXX\" | \"YER\" | \"ZAR\" | \"ZMW\" | \"ZWL\" | undefined",
|
|
349
352
|
"references": {
|
|
350
353
|
"Currency": {
|
|
351
354
|
"location": "import",
|
|
@@ -434,3 +437,7 @@ export class SmoothlyInput {
|
|
|
434
437
|
"methodName": "valueWatcher"
|
|
435
438
|
}]; }
|
|
436
439
|
}
|
|
440
|
+
function getLocale() {
|
|
441
|
+
const result = navigator.language;
|
|
442
|
+
return Locale.is(result) ? result : Language.is(result) ? Locale.toLocale(result) : undefined;
|
|
443
|
+
}
|
|
@@ -26,8 +26,8 @@ export class SmoothlySelectDemo {
|
|
|
26
26
|
h("option", { value: "1" }, "1"),
|
|
27
27
|
h("option", { value: "2" }, "2"),
|
|
28
28
|
h("option", { value: "3" }, "3")),
|
|
29
|
-
h("smoothly-input-date", { max: "2021-12-30", min: "2021-10-10" }, "Date"),
|
|
30
|
-
h("smoothly-input-date-range", {
|
|
29
|
+
h("smoothly-input-date", { value: "2021-10-28", max: "2021-12-30", min: "2021-10-10" }, "Date"),
|
|
30
|
+
h("smoothly-input-date-range", { start: "2021-10-28", end: "2021-11-27", min: "2021-10-10", max: "2021-12-30" }),
|
|
31
31
|
h("smoothly-selector", null,
|
|
32
32
|
h("smoothly-item", { value: "1" }, "January"),
|
|
33
33
|
h("smoothly-item", { value: "2" }, "February"),
|
package/dist/collection/index.js
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Hex } from "./Hex";
|
|
2
|
+
import { Hsl } from "./Hsl";
|
|
3
|
+
import { Name as ColorName, Names } from "./Name";
|
|
4
|
+
import { Rgb } from "./Rgb";
|
|
5
|
+
export var CommaRgb;
|
|
6
|
+
(function (CommaRgb) {
|
|
7
|
+
function is(value) {
|
|
8
|
+
const values = typeof value == "string" ? value.split(",") : [];
|
|
9
|
+
return (values.length == 3 &&
|
|
10
|
+
values.every((value) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return !Number.isNaN(value) &&
|
|
13
|
+
((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
|
|
14
|
+
Number(value) >= 0 &&
|
|
15
|
+
Number(value) <= 255;
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
CommaRgb.is = is;
|
|
19
|
+
function from(color) {
|
|
20
|
+
let result;
|
|
21
|
+
const colorWithoutSpace = typeof color == "string" ? color.replace(/ /g, "").toLowerCase() : undefined;
|
|
22
|
+
if (!colorWithoutSpace)
|
|
23
|
+
result = undefined;
|
|
24
|
+
else if (CommaRgb.is(colorWithoutSpace))
|
|
25
|
+
result = colorWithoutSpace;
|
|
26
|
+
else if (Hex.is(colorWithoutSpace))
|
|
27
|
+
result = fromHex(colorWithoutSpace);
|
|
28
|
+
else if (Rgb.is(colorWithoutSpace))
|
|
29
|
+
result = fromRgb(colorWithoutSpace);
|
|
30
|
+
else if (ColorName.is(colorWithoutSpace))
|
|
31
|
+
result = fromHex(Names[colorWithoutSpace]);
|
|
32
|
+
else if (Hsl.is(colorWithoutSpace))
|
|
33
|
+
result = fromHsl(colorWithoutSpace);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
CommaRgb.from = from;
|
|
37
|
+
function fromHex(hex) {
|
|
38
|
+
let result = "0,0,0";
|
|
39
|
+
if (hex.length == 7)
|
|
40
|
+
result = `${parseInt(hex.substr(1, 2), 16)},${parseInt(hex.substr(3, 2), 16)},${parseInt(hex.substr(5, 2), 16)}`;
|
|
41
|
+
else if (hex.length == 4)
|
|
42
|
+
result = fromHex(`#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}`);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
CommaRgb.fromHex = fromHex;
|
|
46
|
+
function fromRgb(rgb) {
|
|
47
|
+
return rgb.substring(4, rgb.length - 1);
|
|
48
|
+
}
|
|
49
|
+
CommaRgb.fromRgb = fromRgb;
|
|
50
|
+
function fromHsl(hsl) {
|
|
51
|
+
let result = "";
|
|
52
|
+
let h, s, l;
|
|
53
|
+
let r, g, b;
|
|
54
|
+
const HSL = hsl
|
|
55
|
+
.substring(4, hsl.length - 1)
|
|
56
|
+
.split(",")
|
|
57
|
+
.map((value, index) => Number(index == 0 ? value : value.substr(0, value.length - 1)));
|
|
58
|
+
if (HSL.length == 3) {
|
|
59
|
+
h = HSL[0] / 360;
|
|
60
|
+
s = HSL[1] / 100;
|
|
61
|
+
l = HSL[2] / 100;
|
|
62
|
+
if (s == 0)
|
|
63
|
+
r = g = b = l;
|
|
64
|
+
else {
|
|
65
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
66
|
+
const p = 2 * l - q;
|
|
67
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
68
|
+
g = hue2rgb(p, q, h);
|
|
69
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
70
|
+
}
|
|
71
|
+
result = `${Math.round(255 * r)},${Math.round(255 * g)},${Math.round(255 * b)}`;
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
CommaRgb.fromHsl = fromHsl;
|
|
76
|
+
function hue2rgb(p, q, t) {
|
|
77
|
+
let result = p;
|
|
78
|
+
if (t < 0)
|
|
79
|
+
t += 1;
|
|
80
|
+
if (t > 1)
|
|
81
|
+
t -= 1;
|
|
82
|
+
if (t < 1 / 6)
|
|
83
|
+
result = p + (q - p) * 6 * t;
|
|
84
|
+
else if (t < 1 / 2)
|
|
85
|
+
result = q;
|
|
86
|
+
else if (t < 2 / 3)
|
|
87
|
+
result = p + (q - p) * (2 / 3 - t) * 6;
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
})(CommaRgb || (CommaRgb = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var Hex;
|
|
2
|
+
(function (Hex) {
|
|
3
|
+
function is(value) {
|
|
4
|
+
const matchArray = (typeof value == "string" && value.match(/[0-9a-fA-F]/g)) || undefined;
|
|
5
|
+
return (typeof value == "string" &&
|
|
6
|
+
value.length > 3 &&
|
|
7
|
+
value[0] == "#" &&
|
|
8
|
+
((matchArray === null || matchArray === void 0 ? void 0 : matchArray.length) == 3 || (matchArray === null || matchArray === void 0 ? void 0 : matchArray.length) == 6));
|
|
9
|
+
}
|
|
10
|
+
Hex.is = is;
|
|
11
|
+
})(Hex || (Hex = {}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export var Hsl;
|
|
2
|
+
(function (Hsl) {
|
|
3
|
+
function is(value) {
|
|
4
|
+
const values = typeof value == "string" && value.length > 11 ? value.substring(4, value.length - 1).split(",") : [];
|
|
5
|
+
return (typeof value == "string" &&
|
|
6
|
+
value.length > 11 &&
|
|
7
|
+
value.substr(0, 4) == "hsl(" &&
|
|
8
|
+
value.substr(value.length - 1, 1) == ")" &&
|
|
9
|
+
values.length == 3 &&
|
|
10
|
+
values.every((single, index) => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
let result = false;
|
|
13
|
+
if (index == 0)
|
|
14
|
+
result =
|
|
15
|
+
!Number.isNaN(single) &&
|
|
16
|
+
((_a = single.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == single.length &&
|
|
17
|
+
Number(single) >= 0 &&
|
|
18
|
+
Number(single) <= 360;
|
|
19
|
+
else {
|
|
20
|
+
const number = single.substr(0, single.length - 1);
|
|
21
|
+
result =
|
|
22
|
+
single[single.length - 1] == "%" &&
|
|
23
|
+
!Number.isNaN(number) &&
|
|
24
|
+
((_b = number.match(/[0-9]/g)) === null || _b === void 0 ? void 0 : _b.length) == number.length &&
|
|
25
|
+
Number(number) >= 0 &&
|
|
26
|
+
Number(number) <= 100;
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
Hsl.is = is;
|
|
32
|
+
})(Hsl || (Hsl = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const Names = {
|
|
2
2
|
aliceblue: "#f0f8ff",
|
|
3
3
|
antiquewhite: "#faebd7",
|
|
4
4
|
aqua: "#00ffff",
|
|
@@ -148,3 +148,11 @@ export const colorNames = {
|
|
|
148
148
|
yellow: "#ffff00",
|
|
149
149
|
yellowgreen: "#9acd32",
|
|
150
150
|
};
|
|
151
|
+
export var Name;
|
|
152
|
+
(function (Name) {
|
|
153
|
+
Name.types = () => Object.keys(Names);
|
|
154
|
+
function is(value) {
|
|
155
|
+
return typeof value == "string" && Name.types().includes(value.toLowerCase());
|
|
156
|
+
}
|
|
157
|
+
Name.is = is;
|
|
158
|
+
})(Name || (Name = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var Rgb;
|
|
2
|
+
(function (Rgb) {
|
|
3
|
+
function is(value) {
|
|
4
|
+
const values = typeof value == "string" && value.length > 9 ? value.substring(4, value.length - 1).split(",") : [];
|
|
5
|
+
return (typeof value == "string" &&
|
|
6
|
+
value.length > 9 &&
|
|
7
|
+
value.substr(0, 4) == "rgb(" &&
|
|
8
|
+
value.substr(value.length - 1, 1) == ")" &&
|
|
9
|
+
values.length == 3 &&
|
|
10
|
+
values.every((value) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return !Number.isNaN(value) &&
|
|
13
|
+
((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
|
|
14
|
+
Number(value) >= 0 &&
|
|
15
|
+
Number(value) <= 255;
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
Rgb.is = is;
|
|
19
|
+
})(Rgb || (Rgb = {}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CommaRgb as ColorCommaRgb } from "./CommaRgb";
|
|
2
|
+
import { Hex as ColorHex } from "./Hex";
|
|
3
|
+
import { Hsl as ColorHsl } from "./Hsl";
|
|
4
|
+
import { Name as ColorName, Names as ColorNames } from "./Name";
|
|
5
|
+
import { Rgb as ColorRgb } from "./Rgb";
|
|
6
|
+
export var Color;
|
|
7
|
+
(function (Color) {
|
|
8
|
+
function is(value) {
|
|
9
|
+
return (typeof value == "string" &&
|
|
10
|
+
(ColorCommaRgb.is(value) || ColorHex.is(value) || ColorHsl.is(value) || ColorName.is(value) || ColorRgb.is(value)));
|
|
11
|
+
}
|
|
12
|
+
Color.is = is;
|
|
13
|
+
function from(value) {
|
|
14
|
+
return is(value) ? value : undefined;
|
|
15
|
+
}
|
|
16
|
+
Color.from = from;
|
|
17
|
+
Color.Names = ColorNames;
|
|
18
|
+
Color.Name = ColorName;
|
|
19
|
+
Color.CommaRgb = ColorCommaRgb;
|
|
20
|
+
Color.Rgb = ColorRgb;
|
|
21
|
+
Color.Hex = ColorHex;
|
|
22
|
+
Color.Hsl = ColorHsl;
|
|
23
|
+
})(Color || (Color = {}));
|