@pairbo/ui-kit 0.0.1 → 0.0.3
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/pairbo.es.js +15027 -0
- package/dist/pairbo.umd.js +1633 -0
- package/dist/src/components/button/button.component.d.ts +32 -0
- package/dist/src/components/button/button.d.ts +8 -0
- package/dist/src/components/button/button.styles.d.ts +2 -0
- package/dist/src/components/button-group/button-group.component.d.ts +23 -0
- package/dist/src/components/button-group/button-group.d.ts +8 -0
- package/dist/src/components/button-group/button-group.styles.d.ts +2 -0
- package/dist/src/components/card-selection/card-selection.component.d.ts +23 -0
- package/dist/src/components/card-selection/card-selection.d.ts +8 -0
- package/dist/src/components/card-selection/card-selection.styles.d.ts +2 -0
- package/dist/src/components/category/category.component.d.ts +13 -0
- package/dist/src/components/category/category.d.ts +8 -0
- package/dist/src/components/category/category.styles.d.ts +2 -0
- package/dist/src/components/category-image/category-image.component.d.ts +23 -0
- package/dist/src/components/category-image/category-image.d.ts +8 -0
- package/dist/src/components/category-image/category-image.styles.d.ts +2 -0
- package/dist/src/components/drawer/drawer.component.d.ts +28 -0
- package/dist/src/components/drawer/drawer.d.ts +8 -0
- package/dist/src/components/drawer/drawer.styles.d.ts +2 -0
- package/dist/src/components/editor/editor.component.d.ts +24 -0
- package/dist/src/components/editor/editor.d.ts +8 -0
- package/dist/src/components/editor/editor.styles.d.ts +2 -0
- package/dist/src/components/fabric-example/fabric-example.component.d.ts +26 -0
- package/dist/src/components/fabric-example/fabric-example.d.ts +8 -0
- package/dist/src/components/fabric-example/fabric-example.styles.d.ts +2 -0
- package/dist/src/components/image-slider/editor-card-slider.component.d.ts +41 -0
- package/dist/src/components/image-slider/editor-card-slider.d.ts +8 -0
- package/dist/src/components/image-slider/editor-card-slider.styles.d.ts +2 -0
- package/dist/src/components/main.d.ts +15 -0
- package/dist/src/components/message-selector/message-selector.component.d.ts +38 -0
- package/dist/src/components/message-selector/message-selector.d.ts +8 -0
- package/dist/src/components/message-selector/message-selector.styles.d.ts +2 -0
- package/dist/src/components/message-selector/message-selector.test.d.ts +1 -0
- package/dist/src/components/page-manager/page-manager.component.d.ts +41 -0
- package/dist/src/components/page-manager/page-manager.d.ts +8 -0
- package/dist/src/components/page-manager/page-manager.styles.d.ts +2 -0
- package/dist/src/components/radio-button/radio-button.component.d.ts +37 -0
- package/dist/src/components/radio-button/radio-button.d.ts +8 -0
- package/dist/src/components/radio-button/radio-button.styles.d.ts +2 -0
- package/dist/src/components/radio-group/radio-group.component.d.ts +56 -0
- package/dist/src/components/radio-group/radio-group.d.ts +8 -0
- package/dist/src/components/radio-group/radio-group.styles.d.ts +2 -0
- package/dist/src/components/selector/selector.component.d.ts +18 -0
- package/dist/src/components/selector/selector.d.ts +8 -0
- package/dist/src/components/selector/selector.styles.d.ts +2 -0
- package/dist/src/components/textarea/textarea.component.d.ts +78 -0
- package/dist/src/components/textarea/textarea.d.ts +8 -0
- package/dist/src/components/textarea/textarea.styles.d.ts +2 -0
- package/dist/src/components/type-form/type-form.component.d.ts +48 -0
- package/dist/src/components/type-form/type-form.d.ts +8 -0
- package/dist/src/components/type-form/type-form.styles.d.ts +2 -0
- package/dist/src/events/events.d.ts +1 -0
- package/dist/src/events/pbo-category-card-select.d.ts +8 -0
- package/dist/src/internal/form.d.ts +43 -0
- package/{src/internal/pairbo-element.ts → dist/src/internal/pairbo-element.d.ts} +21 -46
- package/dist/src/internal/slots.d.ts +12 -0
- package/dist/src/internal/watch.d.ts +28 -0
- package/dist/src/styles/component.styles.d.ts +2 -0
- package/dist/src/styles/form-control.styles.d.ts +2 -0
- package/package.json +12 -8
- package/.husky/pre-commit +0 -1
- package/.prettierignore +0 -16
- package/.prettierrc.json +0 -17
- package/cspell.json +0 -9
- package/dev.html +0 -101
- package/docs/README.md +0 -1
- package/docs/_includes/component.njk +0 -16
- package/docs/_includes/default.njk +0 -39
- package/docs/_includes/sidebar.njk +0 -16
- package/docs/eleventy.config.mjs +0 -72
- package/docs/pages/components/message-selector.md +0 -17
- package/docs/pages/fabric-example.html +0 -46
- package/docs/pages/fabric-example.js +0 -28
- package/docs/pages/index.md +0 -76
- package/eslint.config.mjs +0 -32
- package/ignote_temp +0 -3
- package/index.html +0 -162
- package/lint-stage.confg.js +0 -6
- package/pages/card-selection.html +0 -65
- package/pages/drawer.html +0 -47
- package/pages/editor.html +0 -45
- package/pages/page-mgn.html +0 -51
- package/pages/test_build.html +0 -47
- package/scripts/plop/plopfile.js +0 -51
- package/scripts/plop/templates/components/component.hbs +0 -34
- package/scripts/plop/templates/components/define.hbs +0 -10
- package/scripts/plop/templates/components/styles.hbs +0 -7
- package/src/components/button/button.component.ts +0 -93
- package/src/components/button/button.styles.ts +0 -273
- package/src/components/button/button.ts +0 -10
- package/src/components/button-group/button-group.component.ts +0 -36
- package/src/components/button-group/button-group.styles.ts +0 -7
- package/src/components/button-group/button-group.ts +0 -10
- package/src/components/card-selection/card-selection.component.ts +0 -43
- package/src/components/card-selection/card-selection.styles.ts +0 -7
- package/src/components/card-selection/card-selection.ts +0 -10
- package/src/components/category/category.component.ts +0 -91
- package/src/components/category/category.styles.ts +0 -27
- package/src/components/category/category.ts +0 -10
- package/src/components/category-image/category-image.component.ts +0 -38
- package/src/components/category-image/category-image.styles.ts +0 -11
- package/src/components/category-image/category-image.ts +0 -10
- package/src/components/drawer/drawer.component.ts +0 -82
- package/src/components/drawer/drawer.styles.ts +0 -54
- package/src/components/drawer/drawer.ts +0 -10
- package/src/components/editor/editor.component.ts +0 -135
- package/src/components/editor/editor.styles.ts +0 -13
- package/src/components/editor/editor.ts +0 -10
- package/src/components/fabric-example/fabric-example.component.ts +0 -268
- package/src/components/fabric-example/fabric-example.styles.ts +0 -23
- package/src/components/fabric-example/fabric-example.ts +0 -12
- package/src/components/image-slider/editor-card-slider.component.ts +0 -136
- package/src/components/image-slider/editor-card-slider.styles.ts +0 -46
- package/src/components/image-slider/editor-card-slider.ts +0 -9
- package/src/components/main.ts +0 -17
- package/src/components/message-selector/message-selector.component.ts +0 -154
- package/src/components/message-selector/message-selector.styles.ts +0 -16
- package/src/components/message-selector/message-selector.test.ts +0 -64
- package/src/components/message-selector/message-selector.ts +0 -13
- package/src/components/page-manager/page-manager.component.ts +0 -228
- package/src/components/page-manager/page-manager.styles.ts +0 -9
- package/src/components/page-manager/page-manager.ts +0 -10
- package/src/components/radio-button/radio-button.component.ts +0 -118
- package/src/components/radio-button/radio-button.styles.ts +0 -13
- package/src/components/radio-button/radio-button.ts +0 -10
- package/src/components/radio-group/radio-group.component.ts +0 -203
- package/src/components/radio-group/radio-group.styles.ts +0 -19
- package/src/components/radio-group/radio-group.ts +0 -10
- package/src/components/selector/selector.component.ts +0 -115
- package/src/components/selector/selector.styles.ts +0 -9
- package/src/components/selector/selector.ts +0 -10
- package/src/components/textarea/textarea.component.ts +0 -234
- package/src/components/textarea/textarea.styles.ts +0 -178
- package/src/components/textarea/textarea.ts +0 -10
- package/src/components/type-form/type-form.component.ts +0 -121
- package/src/components/type-form/type-form.styles.ts +0 -7
- package/src/components/type-form/type-form.ts +0 -10
- package/src/declaration.d.ts +0 -44
- package/src/events/events.ts +0 -1
- package/src/events/pbo-category-card-select.ts +0 -7
- package/src/internal/form.ts +0 -376
- package/src/internal/slots.ts +0 -54
- package/src/internal/watch.ts +0 -79
- package/src/styles/component.styles.ts +0 -17
- package/src/styles/form-control.styles.ts +0 -59
- package/temp +0 -20
- package/tsconfig.json +0 -28
- package/vite.config.ts +0 -26
- /package/{public → dist}/Greeting Card from Pairbo.png +0 -0
- /package/{src/components/fabric-example/fabric-example.test.ts → dist/src/components/fabric-example/fabric-example.test.d.ts} +0 -0
- /package/{src → dist/src}/themes/default.css +0 -0
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
export default css`
|
|
4
|
-
:host {
|
|
5
|
-
display: block;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.visually-hidden {
|
|
9
|
-
position: absolute;
|
|
10
|
-
width: 1px;
|
|
11
|
-
height: 1px;
|
|
12
|
-
padding: 0;
|
|
13
|
-
margin: -1px;
|
|
14
|
-
overflow: hidden;
|
|
15
|
-
clip: rect(0, 0, 0, 0);
|
|
16
|
-
white-space: nowrap;
|
|
17
|
-
border: 0;
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { customElement, property, query } from "lit/decorators.js";
|
|
2
|
-
import { html, LitElement, css, unsafeCSS } from "lit";
|
|
3
|
-
import type { CSSResultGroup, ReactiveController } from "lit";
|
|
4
|
-
import componentStyles from "../../styles/component.styles.js";
|
|
5
|
-
import styles from "./selector.styles.js";
|
|
6
|
-
import Choices from "choices.js";
|
|
7
|
-
import choicesStyles from "choices.js/public/assets/styles/choices.css?inline";
|
|
8
|
-
|
|
9
|
-
interface FontOption {
|
|
10
|
-
value: string;
|
|
11
|
-
label: string;
|
|
12
|
-
font: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@customElement("pbo-selector")
|
|
16
|
-
export default class PboSelector extends LitElement {
|
|
17
|
-
static styles: CSSResultGroup = [componentStyles, styles, unsafeCSS(choicesStyles)];
|
|
18
|
-
@property({ type: Array }) fonts: FontOption[] = [
|
|
19
|
-
{ value: "comic", label: "🖊️ Comic Sans", font: "'Comic Sans MS', cursive" },
|
|
20
|
-
{ value: "times", label: "🔤 Times New Roman", font: "'Times New Roman', serif" },
|
|
21
|
-
{ value: "arial", label: "📜 Arial", font: "'Arial', sans-serif" },
|
|
22
|
-
{ value: "mono", label: "💻 Monospace", font: "'Courier New', monospace" },
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
get value() {
|
|
26
|
-
return this._choices?.getValue().value;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@query(".js-choice") choiceEl!: HTMLSelectElement;
|
|
30
|
-
private _choices?: Choices;
|
|
31
|
-
|
|
32
|
-
firstUpdated() {
|
|
33
|
-
this._initializeChoices();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
updated = (changedProperties: Map<string, any>) => {
|
|
37
|
-
if (changedProperties.has("fonts")) {
|
|
38
|
-
this._initializeChoices();
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
private _initializeChoices() {
|
|
43
|
-
// Destroy existing instance if it exists
|
|
44
|
-
this._choices?.destroy();
|
|
45
|
-
|
|
46
|
-
// Create new instance with current fonts
|
|
47
|
-
this._choices = new Choices(this.choiceEl, {
|
|
48
|
-
allowHTML: true,
|
|
49
|
-
searchEnabled: false,
|
|
50
|
-
shouldSort: false,
|
|
51
|
-
removeItemButton: false,
|
|
52
|
-
shadowRoot: this.shadowRoot,
|
|
53
|
-
choices: this.fonts.map((font, index) => ({
|
|
54
|
-
value: font.value,
|
|
55
|
-
label: font.label,
|
|
56
|
-
customProperties: { font: font.font },
|
|
57
|
-
selected: index === 0, // Select the first option by default
|
|
58
|
-
})),
|
|
59
|
-
placeholder: false,
|
|
60
|
-
shouldSortItems: false,
|
|
61
|
-
// callbackOnCreateTemplates: function (template, escapeForTemplate, getClassNames) {
|
|
62
|
-
// return {
|
|
63
|
-
// item: ({ classNames }, data) => {
|
|
64
|
-
// const templateClassNames = [
|
|
65
|
-
// getClassNames(classNames.item).join(" "),
|
|
66
|
-
// getClassNames(data.highlighted ? classNames.highlightedState : classNames.itemSelectable).join(" "),
|
|
67
|
-
// ].join(" ");
|
|
68
|
-
// return template(`
|
|
69
|
-
// <div class="${templateClassNames}"
|
|
70
|
-
// data-item data-id="${data.id}" data-value="${escapeForTemplate(data.value)}" ${
|
|
71
|
-
// data.active ? 'aria-selected="true"' : ""
|
|
72
|
-
// } ${data.disabled ? 'aria-disabled="true"' : ""}
|
|
73
|
-
// style="font-family: ${data.customProperties?.font || "inherit"}">
|
|
74
|
-
// ${data.label}
|
|
75
|
-
// </div>
|
|
76
|
-
// `);
|
|
77
|
-
// },
|
|
78
|
-
// choice: ({ classNames }, data) => {
|
|
79
|
-
// const templateClassNames = [
|
|
80
|
-
// getClassNames(classNames.item).join(" "),
|
|
81
|
-
// getClassNames(classNames.itemChoice).join(" "),
|
|
82
|
-
// getClassNames(data.disabled ? classNames.itemDisabled : classNames.itemSelectable).join(" "),
|
|
83
|
-
// ].join(" ");
|
|
84
|
-
// return template(`
|
|
85
|
-
// <div class="${templateClassNames}"
|
|
86
|
-
// data-select-text="${this.config.itemSelectText}" data-choice ${
|
|
87
|
-
// data.disabled ? 'data-choice-disabled aria-disabled="true"' : "data-choice-selectable"
|
|
88
|
-
// } data-id="${data.id}" data-value="${escapeForTemplate(data.value)}" ${
|
|
89
|
-
// data.groupId > 0 ? 'role="treeitem"' : 'role="option"'
|
|
90
|
-
// }
|
|
91
|
-
// style="font-family: ${data.customProperties?.font || "inherit"}">
|
|
92
|
-
// ${data.label} choice
|
|
93
|
-
// </div>
|
|
94
|
-
// `);
|
|
95
|
-
// },
|
|
96
|
-
// };
|
|
97
|
-
// },
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
this.choiceEl.addEventListener("change", (event: Event) => {
|
|
101
|
-
const target = event.target as HTMLSelectElement;
|
|
102
|
-
this.dispatchEvent(
|
|
103
|
-
new CustomEvent("pbo-change", {
|
|
104
|
-
detail: { value: target.value },
|
|
105
|
-
bubbles: true,
|
|
106
|
-
composed: true,
|
|
107
|
-
})
|
|
108
|
-
);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
render() {
|
|
113
|
-
return html`<select part="base" class="js-choice"></select>`;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { customElement, property, query, state } from "lit/decorators.js";
|
|
2
|
-
import { html } from "lit";
|
|
3
|
-
import type { CSSResultGroup } from "lit";
|
|
4
|
-
import componentStyles from "../../styles/component.styles.js";
|
|
5
|
-
import PairboElement, { PairboFormControl } from "../../internal/pairbo-element.js";
|
|
6
|
-
import styles from "./textarea.styles.js";
|
|
7
|
-
import { FormControlController } from "../../internal/form.js";
|
|
8
|
-
import { ifDefined } from "lit/directives/if-defined.js";
|
|
9
|
-
import { live } from "lit/directives/live.js";
|
|
10
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
11
|
-
import formControlStyles from "../../styles/form-control.styles.js";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @summary Short summary of the component's intended use.
|
|
15
|
-
* @status experimental
|
|
16
|
-
*
|
|
17
|
-
* @dependency pbo-example
|
|
18
|
-
*
|
|
19
|
-
* @event pbo-event-name - Emitted as an example.
|
|
20
|
-
*
|
|
21
|
-
* @slot - The default slot.
|
|
22
|
-
* @slot example - An example slot.
|
|
23
|
-
*
|
|
24
|
-
* @csspart base - The component's base wrapper.
|
|
25
|
-
*
|
|
26
|
-
* @cssproperty --example - An example CSS custom property.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
@customElement("pbo-textarea")
|
|
30
|
-
export default class PboTextarea extends PairboElement implements PairboFormControl {
|
|
31
|
-
static styles: CSSResultGroup = [componentStyles, styles, formControlStyles];
|
|
32
|
-
|
|
33
|
-
private readonly formControlController = new FormControlController(this, {
|
|
34
|
-
assumeInteractionOn: ["pbo-input"],
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// private resizeObserver: ResizeObserver;
|
|
38
|
-
|
|
39
|
-
defaultValue?: unknown;
|
|
40
|
-
defaultChecked?: boolean | undefined;
|
|
41
|
-
pattern?: string | undefined;
|
|
42
|
-
min?: string | number | Date | undefined;
|
|
43
|
-
max?: string | number | Date | undefined;
|
|
44
|
-
step?: number | "any" | undefined;
|
|
45
|
-
|
|
46
|
-
@query(".textarea__control") input: HTMLTextAreaElement;
|
|
47
|
-
@query(".textarea__size-adjuster") sizeAdjuster: HTMLTextAreaElement;
|
|
48
|
-
|
|
49
|
-
@state() hasFocus = false;
|
|
50
|
-
|
|
51
|
-
@property() name = "";
|
|
52
|
-
@property() value = "";
|
|
53
|
-
@property({ reflect: true }) size: "small" | "medium" | "large" = "medium";
|
|
54
|
-
@property({ type: Boolean, reflect: true }) filled = false;
|
|
55
|
-
@property() placeholder = "";
|
|
56
|
-
@property({ type: Number }) rows = 4;
|
|
57
|
-
@property() resize: "none" | "vertical" | "auto" = "vertical";
|
|
58
|
-
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
59
|
-
@property({ type: Boolean, reflect: true }) readonly = false;
|
|
60
|
-
|
|
61
|
-
@property({ reflect: true }) form = "";
|
|
62
|
-
@property({ type: Boolean, reflect: true }) required = false;
|
|
63
|
-
@property({ type: Number }) minlength: number;
|
|
64
|
-
@property({ type: Number }) maxlength: number;
|
|
65
|
-
|
|
66
|
-
get validity() {
|
|
67
|
-
return this.input.validity;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
get validationMessage() {
|
|
71
|
-
return this.input.validationMessage;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
firstUpdated() {
|
|
75
|
-
this.formControlController.updateValidity();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private handleChange() {
|
|
79
|
-
this.value = this.input.value;
|
|
80
|
-
this.emit("pbo-change");
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private handleBlur() {
|
|
84
|
-
this.hasFocus = false;
|
|
85
|
-
this.emit("pbo-blur");
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private handleFocus() {
|
|
89
|
-
this.hasFocus = true;
|
|
90
|
-
this.emit("pbo-focus");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private handleInput() {
|
|
94
|
-
this.value = this.input.value;
|
|
95
|
-
this.emit("pbo-input");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
private handleInvalid(event: Event) {
|
|
99
|
-
this.formControlController.setValidity(false);
|
|
100
|
-
this.formControlController.emitInvalidEvent(event);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** Sets focus on the textarea. */
|
|
104
|
-
focus(options?: FocusOptions) {
|
|
105
|
-
this.input.focus(options);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** Removes focus from the textarea. */
|
|
109
|
-
blur() {
|
|
110
|
-
this.input.blur();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** Selects all the text in the textarea. */
|
|
114
|
-
select() {
|
|
115
|
-
this.input.select();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** Gets or sets the textarea's scroll position. */
|
|
119
|
-
scrollPosition(position?: { top?: number; left?: number }): { top: number; left: number } | undefined {
|
|
120
|
-
if (position) {
|
|
121
|
-
if (typeof position.top === "number") this.input.scrollTop = position.top;
|
|
122
|
-
if (typeof position.left === "number") this.input.scrollLeft = position.left;
|
|
123
|
-
return undefined;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
top: this.input.scrollTop,
|
|
128
|
-
left: this.input.scrollTop,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** Sets the start and end positions of the text selection (0-based). */
|
|
133
|
-
setSelectionRange(
|
|
134
|
-
selectionStart: number,
|
|
135
|
-
selectionEnd: number,
|
|
136
|
-
selectionDirection: "forward" | "backward" | "none" = "none"
|
|
137
|
-
) {
|
|
138
|
-
this.input.setSelectionRange(selectionStart, selectionEnd, selectionDirection);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** Replaces a range of text with a new string. */
|
|
142
|
-
setRangeText(
|
|
143
|
-
replacement: string,
|
|
144
|
-
start?: number,
|
|
145
|
-
end?: number,
|
|
146
|
-
selectMode: "select" | "start" | "end" | "preserve" = "preserve"
|
|
147
|
-
) {
|
|
148
|
-
const selectionStart = start ?? this.input.selectionStart;
|
|
149
|
-
const selectionEnd = end ?? this.input.selectionEnd;
|
|
150
|
-
|
|
151
|
-
this.input.setRangeText(replacement, selectionStart, selectionEnd, selectMode);
|
|
152
|
-
|
|
153
|
-
if (this.value !== this.input.value) {
|
|
154
|
-
this.value = this.input.value;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
|
|
159
|
-
checkValidity() {
|
|
160
|
-
return this.input.checkValidity();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/** Gets the associated form, if one exists. */
|
|
164
|
-
getForm(): HTMLFormElement | null {
|
|
165
|
-
return this.formControlController.getForm();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
169
|
-
reportValidity() {
|
|
170
|
-
return this.input.reportValidity();
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/** Sets a custom validation message. Pass an empty string to restore validity. */
|
|
174
|
-
setCustomValidity(message: string) {
|
|
175
|
-
this.input.setCustomValidity(message);
|
|
176
|
-
this.formControlController.updateValidity();
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
render() {
|
|
180
|
-
return html` <div
|
|
181
|
-
part="form-control"
|
|
182
|
-
class=${classMap({
|
|
183
|
-
"form-control": true,
|
|
184
|
-
"form-control--small": this.size === "small",
|
|
185
|
-
"form-control--medium": this.size === "medium",
|
|
186
|
-
"form-control--large": this.size === "large",
|
|
187
|
-
})}
|
|
188
|
-
>
|
|
189
|
-
<div part="form-control-input" class="form-control-input">
|
|
190
|
-
<div
|
|
191
|
-
part="base"
|
|
192
|
-
class=${classMap({
|
|
193
|
-
textarea: true,
|
|
194
|
-
"textarea--small": this.size === "small",
|
|
195
|
-
"textarea--medium": this.size === "medium",
|
|
196
|
-
"textarea--large": this.size === "large",
|
|
197
|
-
"textarea--standard": !this.filled,
|
|
198
|
-
"textarea--filled": this.filled,
|
|
199
|
-
"textarea--disabled": this.disabled,
|
|
200
|
-
"textarea--focused": this.hasFocus,
|
|
201
|
-
"textarea--empty": !this.value,
|
|
202
|
-
"textarea--resize-none": this.resize === "none",
|
|
203
|
-
"textarea--resize-vertical": this.resize === "vertical",
|
|
204
|
-
"textarea--resize-auto": this.resize === "auto",
|
|
205
|
-
})}
|
|
206
|
-
>
|
|
207
|
-
<textarea
|
|
208
|
-
part="textarea"
|
|
209
|
-
id="input"
|
|
210
|
-
class="textarea__control"
|
|
211
|
-
title=${this.title /* An empty title prevents browser validation tooltips from appearing on hover */}
|
|
212
|
-
name=${ifDefined(this.name)}
|
|
213
|
-
.value=${live(this.value)}
|
|
214
|
-
?disabled=${this.disabled}
|
|
215
|
-
?readonly=${this.readonly}
|
|
216
|
-
?required=${this.required}
|
|
217
|
-
placeholder=${ifDefined(this.placeholder)}
|
|
218
|
-
rows=${ifDefined(this.rows)}
|
|
219
|
-
minlength=${ifDefined(this.minlength)}
|
|
220
|
-
maxlength=${ifDefined(this.maxlength)}
|
|
221
|
-
aria-describedby="help-text"
|
|
222
|
-
@change=${this.handleChange}
|
|
223
|
-
@input=${this.handleInput}
|
|
224
|
-
@invalid=${this.handleInvalid}
|
|
225
|
-
@focus=${this.handleFocus}
|
|
226
|
-
@blur=${this.handleBlur}
|
|
227
|
-
></textarea>
|
|
228
|
-
<!-- This "adjuster" exists to prevent layout shifting. https://github.com/shoelace-style/shoelace/issues/2180 -->
|
|
229
|
-
<div part="textarea-adjuster" class="textarea__size-adjuster" ?hidden=${this.resize !== "auto"}></div>
|
|
230
|
-
</div>
|
|
231
|
-
</div>
|
|
232
|
-
</div>`;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
export default css`
|
|
4
|
-
:host {
|
|
5
|
-
display: block;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.textarea {
|
|
9
|
-
display: grid;
|
|
10
|
-
align-items: center;
|
|
11
|
-
position: relative;
|
|
12
|
-
width: 100%;
|
|
13
|
-
font-family: var(--sl-input-font-family);
|
|
14
|
-
font-weight: var(--sl-input-font-weight);
|
|
15
|
-
line-height: var(--sl-line-height-normal);
|
|
16
|
-
letter-spacing: var(--sl-input-letter-spacing);
|
|
17
|
-
vertical-align: middle;
|
|
18
|
-
transition:
|
|
19
|
-
var(--sl-transition-fast) color,
|
|
20
|
-
var(--sl-transition-fast) border,
|
|
21
|
-
var(--sl-transition-fast) box-shadow,
|
|
22
|
-
var(--sl-transition-fast) background-color;
|
|
23
|
-
cursor: text;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* Standard textareas */
|
|
27
|
-
.textarea--standard {
|
|
28
|
-
background-color: var(--sl-input-background-color);
|
|
29
|
-
border: solid var(--sl-input-border-width) var(--sl-input-border-color);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.textarea--standard:hover:not(.textarea--disabled) {
|
|
33
|
-
background-color: var(--sl-input-background-color-hover);
|
|
34
|
-
border-color: var(--sl-input-border-color-hover);
|
|
35
|
-
}
|
|
36
|
-
.textarea--standard:hover:not(.textarea--disabled) .textarea__control {
|
|
37
|
-
color: var(--sl-input-color-hover);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.textarea--standard.textarea--focused:not(.textarea--disabled) {
|
|
41
|
-
background-color: var(--sl-input-background-color-focus);
|
|
42
|
-
border-color: var(--sl-input-border-color-focus);
|
|
43
|
-
color: var(--sl-input-color-focus);
|
|
44
|
-
box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-input-focus-ring-color);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.textarea--standard.textarea--focused:not(.textarea--disabled) .textarea__control {
|
|
48
|
-
color: var(--sl-input-color-focus);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.textarea--standard.textarea--disabled {
|
|
52
|
-
background-color: var(--sl-input-background-color-disabled);
|
|
53
|
-
border-color: var(--sl-input-border-color-disabled);
|
|
54
|
-
opacity: 0.5;
|
|
55
|
-
cursor: not-allowed;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.textarea__control,
|
|
59
|
-
.textarea__size-adjuster {
|
|
60
|
-
grid-area: 1 / 1 / 2 / 2;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.textarea__size-adjuster {
|
|
64
|
-
visibility: hidden;
|
|
65
|
-
pointer-events: none;
|
|
66
|
-
opacity: 0;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.textarea--standard.textarea--disabled .textarea__control {
|
|
70
|
-
color: var(--sl-input-color-disabled);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.textarea--standard.textarea--disabled .textarea__control::placeholder {
|
|
74
|
-
color: var(--sl-input-placeholder-color-disabled);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* Filled textareas */
|
|
78
|
-
.textarea--filled {
|
|
79
|
-
border: none;
|
|
80
|
-
background-color: var(--sl-input-filled-background-color);
|
|
81
|
-
color: var(--sl-input-color);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.textarea--filled:hover:not(.textarea--disabled) {
|
|
85
|
-
background-color: var(--sl-input-filled-background-color-hover);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.textarea--filled.textarea--focused:not(.textarea--disabled) {
|
|
89
|
-
background-color: var(--sl-input-filled-background-color-focus);
|
|
90
|
-
outline: var(--sl-focus-ring);
|
|
91
|
-
outline-offset: var(--sl-focus-ring-offset);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.textarea--filled.textarea--disabled {
|
|
95
|
-
background-color: var(--sl-input-filled-background-color-disabled);
|
|
96
|
-
opacity: 0.5;
|
|
97
|
-
cursor: not-allowed;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.textarea__control {
|
|
101
|
-
font-family: inherit;
|
|
102
|
-
font-size: inherit;
|
|
103
|
-
font-weight: inherit;
|
|
104
|
-
line-height: 1.4;
|
|
105
|
-
color: var(--sl-input-color);
|
|
106
|
-
border: none;
|
|
107
|
-
background: none;
|
|
108
|
-
box-shadow: none;
|
|
109
|
-
cursor: inherit;
|
|
110
|
-
-webkit-appearance: none;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.textarea__control::-webkit-search-decoration,
|
|
114
|
-
.textarea__control::-webkit-search-cancel-button,
|
|
115
|
-
.textarea__control::-webkit-search-results-button,
|
|
116
|
-
.textarea__control::-webkit-search-results-decoration {
|
|
117
|
-
-webkit-appearance: none;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.textarea__control::placeholder {
|
|
121
|
-
color: var(--sl-input-placeholder-color);
|
|
122
|
-
user-select: none;
|
|
123
|
-
-webkit-user-select: none;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.textarea__control:focus {
|
|
127
|
-
outline: none;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/*
|
|
131
|
-
* Size modifiers
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
.textarea--small {
|
|
135
|
-
border-radius: var(--sl-input-border-radius-small);
|
|
136
|
-
font-size: var(--sl-input-font-size-small);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.textarea--small .textarea__control {
|
|
140
|
-
padding: 0.5em var(--sl-input-spacing-small);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.textarea--medium {
|
|
144
|
-
border-radius: var(--sl-input-border-radius-medium);
|
|
145
|
-
font-size: var(--sl-input-font-size-medium);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.textarea--medium .textarea__control {
|
|
149
|
-
padding: 0.5em var(--sl-input-spacing-medium);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.textarea--large {
|
|
153
|
-
border-radius: var(--sl-input-border-radius-large);
|
|
154
|
-
font-size: var(--sl-input-font-size-large);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.textarea--large .textarea__control {
|
|
158
|
-
padding: 0.5em var(--sl-input-spacing-large);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/*
|
|
162
|
-
* Resize types
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
.textarea--resize-none .textarea__control {
|
|
166
|
-
resize: none;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.textarea--resize-vertical .textarea__control {
|
|
170
|
-
resize: vertical;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.textarea--resize-auto .textarea__control {
|
|
174
|
-
height: auto;
|
|
175
|
-
resize: none;
|
|
176
|
-
overflow-y: hidden;
|
|
177
|
-
}
|
|
178
|
-
`;
|