kemet-ui 4.0.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6546,6 +6546,230 @@
6546
6546
  }
6547
6547
  ]
6548
6548
  },
6549
+ {
6550
+ "kind": "javascript-module",
6551
+ "path": "src/elements/otp-input.ts",
6552
+ "declarations": [
6553
+ {
6554
+ "kind": "class",
6555
+ "description": "",
6556
+ "name": "KemetOtpInput",
6557
+ "cssProperties": [
6558
+ {
6559
+ "description": "The text color of the otp inputs.",
6560
+ "name": "--kemet-otp-input-color"
6561
+ },
6562
+ {
6563
+ "description": "The minimum width of the otp inputs.",
6564
+ "name": "--kemet-otp-input-min-width"
6565
+ },
6566
+ {
6567
+ "description": "The font size of the otp inputs.",
6568
+ "name": "--kemet-otp-input-font-size"
6569
+ },
6570
+ {
6571
+ "description": "The border of the otp inputs.",
6572
+ "name": "--kemet-otp-input-border"
6573
+ },
6574
+ {
6575
+ "description": "The border radius of the otp inputs.",
6576
+ "name": "--kemet-otp-input-border-radius"
6577
+ }
6578
+ ],
6579
+ "cssParts": [
6580
+ {
6581
+ "description": "The input elements.",
6582
+ "name": "input"
6583
+ }
6584
+ ],
6585
+ "members": [
6586
+ {
6587
+ "kind": "field",
6588
+ "name": "digits",
6589
+ "type": {
6590
+ "text": "number"
6591
+ },
6592
+ "default": "6",
6593
+ "description": "The number of inputs.",
6594
+ "attribute": "digits"
6595
+ },
6596
+ {
6597
+ "kind": "field",
6598
+ "name": "value",
6599
+ "type": {
6600
+ "text": "string"
6601
+ },
6602
+ "default": "''",
6603
+ "description": "All digits entered by the user combined in one string.",
6604
+ "attribute": "value",
6605
+ "reflects": true
6606
+ },
6607
+ {
6608
+ "kind": "field",
6609
+ "name": "pattern",
6610
+ "type": {
6611
+ "text": "string"
6612
+ },
6613
+ "description": "The pattern to match against for stripping characters",
6614
+ "attribute": "pattern"
6615
+ },
6616
+ {
6617
+ "kind": "field",
6618
+ "name": "autoFocus",
6619
+ "type": {
6620
+ "text": "boolean"
6621
+ },
6622
+ "default": "true"
6623
+ },
6624
+ {
6625
+ "kind": "field",
6626
+ "name": "values",
6627
+ "type": {
6628
+ "text": "string[]"
6629
+ },
6630
+ "default": "[]"
6631
+ },
6632
+ {
6633
+ "kind": "field",
6634
+ "name": "lastInput",
6635
+ "type": {
6636
+ "text": "string"
6637
+ }
6638
+ },
6639
+ {
6640
+ "kind": "field",
6641
+ "name": "completed",
6642
+ "type": {
6643
+ "text": "boolean"
6644
+ },
6645
+ "default": "false"
6646
+ },
6647
+ {
6648
+ "kind": "field",
6649
+ "name": "inputElements",
6650
+ "type": {
6651
+ "text": "NodeListOf<HTMLInputElement>"
6652
+ }
6653
+ },
6654
+ {
6655
+ "kind": "method",
6656
+ "name": "determineCompleted"
6657
+ },
6658
+ {
6659
+ "kind": "method",
6660
+ "name": "makeInputs"
6661
+ },
6662
+ {
6663
+ "kind": "method",
6664
+ "name": "eatCharacters",
6665
+ "parameters": [
6666
+ {
6667
+ "name": "inputValue",
6668
+ "type": {
6669
+ "text": "string"
6670
+ }
6671
+ }
6672
+ ]
6673
+ },
6674
+ {
6675
+ "kind": "method",
6676
+ "name": "handleInput",
6677
+ "parameters": [
6678
+ {
6679
+ "name": "event",
6680
+ "type": {
6681
+ "text": "InputEvent"
6682
+ }
6683
+ }
6684
+ ]
6685
+ },
6686
+ {
6687
+ "kind": "method",
6688
+ "name": "handleKeyDown",
6689
+ "parameters": [
6690
+ {
6691
+ "name": "event",
6692
+ "type": {
6693
+ "text": "KeyboardEvent"
6694
+ }
6695
+ }
6696
+ ]
6697
+ },
6698
+ {
6699
+ "kind": "method",
6700
+ "name": "handlePaste",
6701
+ "parameters": [
6702
+ {
6703
+ "name": "event",
6704
+ "type": {
6705
+ "text": "ClipboardEvent"
6706
+ }
6707
+ }
6708
+ ]
6709
+ }
6710
+ ],
6711
+ "events": [
6712
+ {
6713
+ "description": "Fires when otp is filled out completely",
6714
+ "name": "kemet-completed"
6715
+ }
6716
+ ],
6717
+ "attributes": [
6718
+ {
6719
+ "name": "digits",
6720
+ "type": {
6721
+ "text": "number"
6722
+ },
6723
+ "default": "6",
6724
+ "description": "The number of inputs.",
6725
+ "fieldName": "digits"
6726
+ },
6727
+ {
6728
+ "name": "value",
6729
+ "type": {
6730
+ "text": "string"
6731
+ },
6732
+ "default": "''",
6733
+ "description": "All digits entered by the user combined in one string.",
6734
+ "fieldName": "value"
6735
+ },
6736
+ {
6737
+ "name": "pattern",
6738
+ "type": {
6739
+ "text": "string"
6740
+ },
6741
+ "description": "The pattern to match against for stripping characters",
6742
+ "fieldName": "pattern"
6743
+ }
6744
+ ],
6745
+ "superclass": {
6746
+ "name": "LitElement",
6747
+ "package": "lit"
6748
+ },
6749
+ "tagName": "kemet-otp-input",
6750
+ "customElement": true,
6751
+ "summary": "An input element that accepts multiple items from a combo."
6752
+ }
6753
+ ],
6754
+ "exports": [
6755
+ {
6756
+ "kind": "js",
6757
+ "name": "default",
6758
+ "declaration": {
6759
+ "name": "KemetOtpInput",
6760
+ "module": "src/elements/otp-input.ts"
6761
+ }
6762
+ },
6763
+ {
6764
+ "kind": "custom-element-definition",
6765
+ "name": "kemet-otp-input",
6766
+ "declaration": {
6767
+ "name": "KemetOtpInput",
6768
+ "module": "src/elements/otp-input.ts"
6769
+ }
6770
+ }
6771
+ ]
6772
+ },
6549
6773
  {
6550
6774
  "kind": "javascript-module",
6551
6775
  "path": "src/elements/password.ts",
@@ -11723,6 +11947,168 @@
11723
11947
  }
11724
11948
  ]
11725
11949
  },
11950
+ {
11951
+ "kind": "javascript-module",
11952
+ "path": "src/elements/typewriter.ts",
11953
+ "declarations": [
11954
+ {
11955
+ "kind": "class",
11956
+ "description": "",
11957
+ "name": "KemetTypewriter",
11958
+ "members": [
11959
+ {
11960
+ "kind": "field",
11961
+ "name": "content",
11962
+ "type": {
11963
+ "text": "string"
11964
+ },
11965
+ "default": "''",
11966
+ "description": "The content to be typed.",
11967
+ "attribute": "content"
11968
+ },
11969
+ {
11970
+ "kind": "field",
11971
+ "name": "delay",
11972
+ "type": {
11973
+ "text": "number"
11974
+ },
11975
+ "default": "10",
11976
+ "description": "The delay between each character.",
11977
+ "attribute": "delay"
11978
+ },
11979
+ {
11980
+ "kind": "field",
11981
+ "name": "cursor",
11982
+ "type": {
11983
+ "text": "string"
11984
+ },
11985
+ "default": "''",
11986
+ "description": "The cursor to be displayed.",
11987
+ "attribute": "cursor"
11988
+ },
11989
+ {
11990
+ "kind": "field",
11991
+ "name": "loop",
11992
+ "type": {
11993
+ "text": "boolean"
11994
+ },
11995
+ "default": "false",
11996
+ "description": "Whether to loop the content.",
11997
+ "attribute": "loop"
11998
+ },
11999
+ {
12000
+ "kind": "field",
12001
+ "name": "restartDelay",
12002
+ "type": {
12003
+ "text": "number"
12004
+ },
12005
+ "default": "1000",
12006
+ "description": "The delay before restarting the typewriter.",
12007
+ "attribute": "restart-delay"
12008
+ },
12009
+ {
12010
+ "kind": "field",
12011
+ "name": "typewriter",
12012
+ "type": {
12013
+ "text": "Typewriter"
12014
+ },
12015
+ "privacy": "private"
12016
+ },
12017
+ {
12018
+ "kind": "field",
12019
+ "name": "timeoutId",
12020
+ "type": {
12021
+ "text": "ReturnType<typeof setTimeout> | null"
12022
+ },
12023
+ "privacy": "private",
12024
+ "default": "null"
12025
+ },
12026
+ {
12027
+ "kind": "method",
12028
+ "name": "restartTypewriter"
12029
+ }
12030
+ ],
12031
+ "events": [
12032
+ {
12033
+ "description": "Fires when typewriter is completed",
12034
+ "name": "kemet-completed"
12035
+ }
12036
+ ],
12037
+ "attributes": [
12038
+ {
12039
+ "name": "content",
12040
+ "type": {
12041
+ "text": "string"
12042
+ },
12043
+ "default": "''",
12044
+ "description": "The content to be typed.",
12045
+ "fieldName": "content"
12046
+ },
12047
+ {
12048
+ "name": "delay",
12049
+ "type": {
12050
+ "text": "number"
12051
+ },
12052
+ "default": "10",
12053
+ "description": "The delay between each character.",
12054
+ "fieldName": "delay"
12055
+ },
12056
+ {
12057
+ "name": "cursor",
12058
+ "type": {
12059
+ "text": "string"
12060
+ },
12061
+ "default": "''",
12062
+ "description": "The cursor to be displayed.",
12063
+ "fieldName": "cursor"
12064
+ },
12065
+ {
12066
+ "name": "loop",
12067
+ "type": {
12068
+ "text": "boolean"
12069
+ },
12070
+ "default": "false",
12071
+ "description": "Whether to loop the content.",
12072
+ "fieldName": "loop"
12073
+ },
12074
+ {
12075
+ "name": "restart-delay",
12076
+ "type": {
12077
+ "text": "number"
12078
+ },
12079
+ "default": "1000",
12080
+ "description": "The delay before restarting the typewriter.",
12081
+ "fieldName": "restartDelay"
12082
+ }
12083
+ ],
12084
+ "superclass": {
12085
+ "name": "LitElement",
12086
+ "package": "lit"
12087
+ },
12088
+ "tagName": "kemet-typewriter",
12089
+ "customElement": true,
12090
+ "summary": "An element that types out content."
12091
+ }
12092
+ ],
12093
+ "exports": [
12094
+ {
12095
+ "kind": "js",
12096
+ "name": "default",
12097
+ "declaration": {
12098
+ "name": "KemetTypewriter",
12099
+ "module": "src/elements/typewriter.ts"
12100
+ }
12101
+ },
12102
+ {
12103
+ "kind": "custom-element-definition",
12104
+ "name": "kemet-typewriter",
12105
+ "declaration": {
12106
+ "name": "KemetTypewriter",
12107
+ "module": "src/elements/typewriter.ts"
12108
+ }
12109
+ }
12110
+ ]
12111
+ },
11726
12112
  {
11727
12113
  "kind": "javascript-module",
11728
12114
  "path": "src/elements/upload-file.ts",
@@ -0,0 +1,52 @@
1
+ import * as lit_html from 'lit-html';
2
+ import * as lit from 'lit';
3
+ import { LitElement } from 'lit';
4
+
5
+ /**
6
+ * @since 4.1.0
7
+ * @status stable
8
+ *
9
+ * @tagname kemet-otp-input
10
+ * @summary An input element that accepts multiple items from a combo.
11
+ *
12
+ * @prop {number} digits - The number of inputs.
13
+ * @prop {string} pattern - The pattern to match against for stripping characters
14
+ * @prop {string} value - All digits entered by the user combined in one string.
15
+ *
16
+ * @csspart input - The input elements.
17
+ *
18
+ * @cssproperty --kemet-otp-input-color - The text color of the otp inputs.
19
+ * @cssproperty --kemet-otp-input-min-width - The minimum width of the otp inputs.
20
+ * @cssproperty --kemet-otp-input-font-size - The font size of the otp inputs.
21
+ * @cssproperty --kemet-otp-input-border - The border of the otp inputs.
22
+ * @cssproperty --kemet-otp-input-border-radius - The border radius of the otp inputs.
23
+ *
24
+ * @event kemet-completed - Fires when otp is filled out completely
25
+ *
26
+ */
27
+ declare class KemetOtpInput extends LitElement {
28
+ static styles: lit.CSSResult[];
29
+ digits: number;
30
+ value: string;
31
+ pattern: string;
32
+ autoFocus: boolean;
33
+ values: string[];
34
+ lastInput: string;
35
+ completed: boolean;
36
+ inputElements: NodeListOf<HTMLInputElement>;
37
+ updated(): void;
38
+ render(): lit_html.TemplateResult<1>[];
39
+ determineCompleted(): void;
40
+ makeInputs(): lit_html.TemplateResult<1>[];
41
+ eatCharacters(inputValue: string): string;
42
+ handleInput(event: InputEvent): void;
43
+ handleKeyDown(event: KeyboardEvent): void;
44
+ handlePaste(event: ClipboardEvent): void;
45
+ }
46
+ declare global {
47
+ interface HTMLElementTagNameMap {
48
+ 'kemet-otp-input': KemetOtpInput;
49
+ }
50
+ }
51
+
52
+ export { KemetOtpInput as default };
@@ -0,0 +1,52 @@
1
+ import * as lit_html from 'lit-html';
2
+ import * as lit from 'lit';
3
+ import { LitElement } from 'lit';
4
+
5
+ /**
6
+ * @since 4.1.0
7
+ * @status stable
8
+ *
9
+ * @tagname kemet-otp-input
10
+ * @summary An input element that accepts multiple items from a combo.
11
+ *
12
+ * @prop {number} digits - The number of inputs.
13
+ * @prop {string} pattern - The pattern to match against for stripping characters
14
+ * @prop {string} value - All digits entered by the user combined in one string.
15
+ *
16
+ * @csspart input - The input elements.
17
+ *
18
+ * @cssproperty --kemet-otp-input-color - The text color of the otp inputs.
19
+ * @cssproperty --kemet-otp-input-min-width - The minimum width of the otp inputs.
20
+ * @cssproperty --kemet-otp-input-font-size - The font size of the otp inputs.
21
+ * @cssproperty --kemet-otp-input-border - The border of the otp inputs.
22
+ * @cssproperty --kemet-otp-input-border-radius - The border radius of the otp inputs.
23
+ *
24
+ * @event kemet-completed - Fires when otp is filled out completely
25
+ *
26
+ */
27
+ declare class KemetOtpInput extends LitElement {
28
+ static styles: lit.CSSResult[];
29
+ digits: number;
30
+ value: string;
31
+ pattern: string;
32
+ autoFocus: boolean;
33
+ values: string[];
34
+ lastInput: string;
35
+ completed: boolean;
36
+ inputElements: NodeListOf<HTMLInputElement>;
37
+ updated(): void;
38
+ render(): lit_html.TemplateResult<1>[];
39
+ determineCompleted(): void;
40
+ makeInputs(): lit_html.TemplateResult<1>[];
41
+ eatCharacters(inputValue: string): string;
42
+ handleInput(event: InputEvent): void;
43
+ handleKeyDown(event: KeyboardEvent): void;
44
+ handlePaste(event: ClipboardEvent): void;
45
+ }
46
+ declare global {
47
+ interface HTMLElementTagNameMap {
48
+ 'kemet-otp-input': KemetOtpInput;
49
+ }
50
+ }
51
+
52
+ export { KemetOtpInput as default };
@@ -0,0 +1,202 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __decorateClass = (decorators, target, key, kind) => {
19
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
21
+ if (decorator = decorators[i])
22
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
23
+ if (kind && result) __defProp(target, key, result);
24
+ return result;
25
+ };
26
+
27
+ // src/elements/otp-input.ts
28
+ var otp_input_exports = {};
29
+ __export(otp_input_exports, {
30
+ default: () => KemetOtpInput
31
+ });
32
+ module.exports = __toCommonJS(otp_input_exports);
33
+ var import_lit2 = require("lit");
34
+ var import_decorators = require("lit/decorators.js");
35
+
36
+ // src/styles/elements/otp-input.ts
37
+ var import_lit = require("lit");
38
+ var stylesBase = import_lit.css`
39
+ :host {
40
+ --kemet-otp-input-color: rgb(var(--kemet-color-gray-600));
41
+ --kemet-otp-input-min-width: 3rem;
42
+ --kemet-otp-input-font-size: 2rem;
43
+ --kemet-otp-input-border: 1px solid rgb(var(--kemet-color-gray-300));
44
+ --kemet-otp-input-border-radius: var(--kemet-border-radius-md);
45
+
46
+ display: grid;
47
+ gap: var(--kemet-spacer-md);
48
+ grid-template-columns: repeat(auto-fit, minmax(var(--kemet-otp-input-min-width), 1fr));
49
+ }
50
+
51
+ label {
52
+ display: flex;
53
+ aspect-ratio: 4/3;
54
+ }
55
+
56
+ span {
57
+ position: absolute;
58
+ margin: -1px;
59
+ width: 1px;
60
+ height: 1px;
61
+ display: block;
62
+ overflow: hidden;
63
+ border-width: 0;
64
+ clip: rect(0, 0, 0, 0);
65
+ white-space: nowrap;
66
+ }
67
+
68
+ [part="input"] {
69
+ color: var(--kemet-otp-input-color);
70
+ text-align: center;
71
+ width: 100%;
72
+ height: 100%;
73
+ font-size: var(--kemet-otp-input-font-size);
74
+ border: var(--kemet-otp-input-border);
75
+ border-radius: var(--kemet-otp-input-border-radius);
76
+ }
77
+ `;
78
+
79
+ // src/utilities/events.ts
80
+ var emitEvent = (element, name, detail, bubbles = true, composed = true) => {
81
+ element.dispatchEvent(
82
+ new CustomEvent(name, { bubbles, composed, detail })
83
+ );
84
+ };
85
+
86
+ // src/elements/otp-input.ts
87
+ var KemetOtpInput = class extends import_lit2.LitElement {
88
+ constructor() {
89
+ super(...arguments);
90
+ this.digits = 6;
91
+ this.value = "";
92
+ this.autoFocus = true;
93
+ this.values = [];
94
+ this.completed = false;
95
+ }
96
+ updated() {
97
+ this.determineCompleted();
98
+ }
99
+ render() {
100
+ return this.makeInputs();
101
+ }
102
+ determineCompleted() {
103
+ const hasBlankValues = this.values.includes("");
104
+ if (this.values.length === this.digits && !hasBlankValues && !this.completed) {
105
+ emitEvent(this, "kemet-completed", {
106
+ detail: { value: this.value },
107
+ bubbles: true,
108
+ composed: true
109
+ });
110
+ this.completed = true;
111
+ }
112
+ }
113
+ makeInputs() {
114
+ return Array.from(
115
+ { length: this.digits },
116
+ (_, index) => import_lit2.html`
117
+ <label>
118
+ <span>Enter digit ${index + 1}</span>
119
+ <input
120
+ part="input"
121
+ id="${index}"
122
+ maxlength="1"
123
+ @input=${this.handleInput}
124
+ @keydown=${this.handleKeyDown}
125
+ @paste=${this.handlePaste}
126
+ />
127
+ </label>
128
+ `
129
+ );
130
+ }
131
+ eatCharacters(inputValue) {
132
+ const regex = new RegExp(this.pattern);
133
+ return inputValue.replace(regex, "");
134
+ }
135
+ handleInput(event) {
136
+ const input = event.target;
137
+ const currentIndex = parseInt(input.getAttribute("id"));
138
+ const nextInput = this.inputElements[currentIndex + 1];
139
+ if (this.pattern) {
140
+ input.value = this.eatCharacters(input.value);
141
+ }
142
+ this.values[currentIndex] = input.value;
143
+ this.value = this.values.join("");
144
+ this.lastInput = input.value;
145
+ const fullDigits = this.values.length === this.digits && !!input.value;
146
+ if (!fullDigits) {
147
+ this.completed = false;
148
+ }
149
+ if (nextInput && this.autoFocus && !!input.value) {
150
+ nextInput.focus();
151
+ }
152
+ }
153
+ handleKeyDown(event) {
154
+ this.autoFocus = event.key !== "Backspace" /* BACKSPACE */;
155
+ }
156
+ handlePaste(event) {
157
+ event.preventDefault();
158
+ const pasteData = event.clipboardData?.getData("text") ?? "";
159
+ const charactersString = this.eatCharacters(pasteData.trim().slice(0, this.digits).split("").join(""));
160
+ const charactersArray = charactersString.split("");
161
+ charactersArray.forEach((character, index) => {
162
+ const input = this.inputElements[index];
163
+ if (input && !!character) {
164
+ input.value = character;
165
+ this.values[index] = character;
166
+ }
167
+ });
168
+ const lastFilled = this.inputElements[charactersArray.length - 1];
169
+ lastFilled?.focus();
170
+ this.value = this.values.join("");
171
+ this.determineCompleted();
172
+ }
173
+ };
174
+ KemetOtpInput.styles = [stylesBase];
175
+ __decorateClass([
176
+ (0, import_decorators.property)({ type: Number })
177
+ ], KemetOtpInput.prototype, "digits", 2);
178
+ __decorateClass([
179
+ (0, import_decorators.property)({ type: String, reflect: true })
180
+ ], KemetOtpInput.prototype, "value", 2);
181
+ __decorateClass([
182
+ (0, import_decorators.property)()
183
+ ], KemetOtpInput.prototype, "pattern", 2);
184
+ __decorateClass([
185
+ (0, import_decorators.state)()
186
+ ], KemetOtpInput.prototype, "autoFocus", 2);
187
+ __decorateClass([
188
+ (0, import_decorators.state)()
189
+ ], KemetOtpInput.prototype, "values", 2);
190
+ __decorateClass([
191
+ (0, import_decorators.state)()
192
+ ], KemetOtpInput.prototype, "lastInput", 2);
193
+ __decorateClass([
194
+ (0, import_decorators.state)()
195
+ ], KemetOtpInput.prototype, "completed", 2);
196
+ __decorateClass([
197
+ (0, import_decorators.queryAll)("input")
198
+ ], KemetOtpInput.prototype, "inputElements", 2);
199
+ KemetOtpInput = __decorateClass([
200
+ (0, import_decorators.customElement)("kemet-otp-input")
201
+ ], KemetOtpInput);
202
+ //# sourceMappingURL=otp-input.js.map