ranui 0.1.0-alpha

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 (54) hide show
  1. package/.vitepress/config.ts +26 -0
  2. package/.vitepress/theme/index.ts +9 -0
  3. package/assets/image/failImage.ts +4 -0
  4. package/assets/svgs/check-circle.svg +4 -0
  5. package/assets/svgs/close-circle.svg +4 -0
  6. package/assets/svgs/eye-close.svg +4 -0
  7. package/assets/svgs/eye.svg +4 -0
  8. package/assets/svgs/info-circle.svg +5 -0
  9. package/assets/svgs/lock.svg +4 -0
  10. package/assets/svgs/unlock.svg +4 -0
  11. package/assets/svgs/user.svg +3 -0
  12. package/components/button/index.less +95 -0
  13. package/components/button/index.ts +64 -0
  14. package/components/form/index.less +0 -0
  15. package/components/form/index.ts +36 -0
  16. package/components/image/index.less +0 -0
  17. package/components/image/index.ts +62 -0
  18. package/components/input/index.less +114 -0
  19. package/components/input/index.ts +367 -0
  20. package/components/modal/index.less +0 -0
  21. package/components/modal/index.ts +118 -0
  22. package/components/tabPane/index.less +0 -0
  23. package/components/tabPane/index.ts +71 -0
  24. package/components/tabs/index.less +47 -0
  25. package/components/tabs/index.ts +207 -0
  26. package/dist/assets/image/failImage.d.ts +2 -0
  27. package/dist/components/button/index.d.ts +2 -0
  28. package/dist/components/image/index.d.ts +2 -0
  29. package/dist/components/input/index.d.ts +2 -0
  30. package/dist/components/modal/index.d.ts +2 -0
  31. package/dist/components/tabPane/index.d.ts +2 -0
  32. package/dist/components/tabs/index.d.ts +2 -0
  33. package/dist/index.d.ts +0 -0
  34. package/dist/index.js +677 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/index.umd.cjs +2 -0
  37. package/dist/index.umd.cjs.map +1 -0
  38. package/dist/style.css +1 -0
  39. package/dist/typings.d.ts +4 -0
  40. package/dist/utils/index.d.ts +7 -0
  41. package/docs/button/index.md +25 -0
  42. package/docs/image/index.md +9 -0
  43. package/docs/input/index.md +146 -0
  44. package/docs/tabs/index.md +121 -0
  45. package/index.html +67 -0
  46. package/index.md +1 -0
  47. package/index.ts +6 -0
  48. package/package.json +33 -0
  49. package/plugins/auto-import-file.ts +59 -0
  50. package/plugins/load-style.ts +31 -0
  51. package/tsconfig.json +31 -0
  52. package/typings.d.ts +4 -0
  53. package/utils/index.ts +12 -0
  54. package/vite.config.ts +58 -0
@@ -0,0 +1,26 @@
1
+ const sidebar = {
2
+ "/": [
3
+ { text: "快速开始", link: "/" },
4
+ {
5
+ text: "通用",
6
+ children: [
7
+ { text: "Button 按钮", link: "/docs/button/" },
8
+ { text: "Input 输入框", link: "/docs/input/" },
9
+ { text: "Image 图片", link: "/docs/image/" },
10
+ ],
11
+ },
12
+ { text: "导航" },
13
+ { text: "反馈" },
14
+ { text: "数据录入" },
15
+ { text: "数据展示" },
16
+ { text: "布局" },
17
+ ],
18
+ };
19
+ const config = {
20
+ title: "RanUI",
21
+ themeConfig: {
22
+ sidebar,
23
+ },
24
+ };
25
+
26
+ export default config;
@@ -0,0 +1,9 @@
1
+ import DefaultTheme from 'vitepress/theme'
2
+ import '../../index'
3
+
4
+ export default {
5
+ ...DefaultTheme,
6
+ enhanceApp({ app }) {
7
+ app.config.compilerOptions.isCustomElement = (tag) => tag.includes('r-')
8
+ }
9
+ }
@@ -0,0 +1,4 @@
1
+ const failImage = `
2
+ data:image/png;base64,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
3
+ `;
4
+ export default failImage;
@@ -0,0 +1,4 @@
1
+ <svg t="1665313196617" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7485" width="200" height="200">
2
+ <path d="M699 353h-46.9c-10.2 0-19.9 4.9-25.9 13.3L469 584.3l-71.2-98.8c-6-8.3-15.6-13.3-25.9-13.3H325c-6.5 0-10.3 7.4-6.5 12.7l124.6 172.8c12.7 17.7 39 17.7 51.7 0l210.6-292c3.9-5.3 0.1-12.7-6.4-12.7z" p-id="7486"></path>
3
+ <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" p-id="7487"></path>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg t="1665313468275" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7625" width="200" height="200">
2
+ <path d="M685.4 354.8c0-4.4-3.6-8-8-8l-66 0.3L512 465.6l-99.3-118.4-66.1-0.3c-4.4 0-8 3.5-8 8 0 1.9 0.7 3.7 1.9 5.2l130.1 155L340.5 670c-1.2 1.5-1.9 3.3-1.9 5.2 0 4.4 3.6 8 8 8l66.1-0.3L512 564.4l99.3 118.4 66 0.3c4.4 0 8-3.5 8-8 0-1.9-0.7-3.7-1.9-5.2L553.5 515l130.1-155c1.2-1.4 1.8-3.3 1.8-5.2z" p-id="7626"></path>
3
+ <path d="M512 65C264.6 65 64 265.6 64 513s200.6 448 448 448 448-200.6 448-448S759.4 65 512 65z m0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" p-id="7627"></path>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg t="1665473540543" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7485" width="200" height="200">
2
+ <path d="M942.3 486.4l-0.1-0.1-0.1-0.1c-36.4-76.7-80-138.7-130.7-186L760.7 351c43.7 40.2 81.5 93.7 114.1 160.9C791.5 684.2 673.4 766 512 766c-51.3 0-98.3-8.3-141.2-25.1l-54.7 54.7C374.6 823.8 439.8 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0.1-51.3zM878.3 154.2l-42.4-42.4c-3.1-3.1-8.2-3.1-11.3 0L707.8 228.5C649.4 200.2 584.2 186 512 186c-192.2 0-335.4 100.5-430.2 300.3v0.1c-7.7 16.2-7.7 35.2 0 51.5 36.4 76.7 80 138.7 130.7 186.1L111.8 824.5c-3.1 3.1-3.1 8.2 0 11.3l42.4 42.4c3.1 3.1 8.2 3.1 11.3 0l712.8-712.8c3.1-3 3.1-8.1 0-11.2zM398.9 537.4c-1.9-8.2-2.9-16.7-2.9-25.4 0-61.9 50.1-112 112-112 8.7 0 17.3 1 25.4 2.9L398.9 537.4z m184.5-184.5C560.5 342.1 535 336 508 336c-97.2 0-176 78.8-176 176 0 27 6.1 52.5 16.9 75.4L263.3 673c-43.7-40.2-81.5-93.7-114.1-160.9C232.6 339.8 350.7 258 512 258c51.3 0 98.3 8.3 141.2 25.1l-69.8 69.8z" p-id="7486"></path>
3
+ <path d="M508 624c-6.4 0-12.7-0.5-18.8-1.6l-51.1 51.1c21.4 9.3 45.1 14.4 69.9 14.4 97.2 0 176-78.8 176-176 0-24.8-5.1-48.5-14.4-69.9l-51.1 51.1c1 6.1 1.6 12.4 1.6 18.8C620 573.9 569.9 624 508 624z" p-id="7487"></path>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg t="1665473580103" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7625" width="200" height="200">
2
+ <path d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3-7.7 16.2-7.7 35.2 0 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766z" p-id="7626"></path>
3
+ <path d="M508 336c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176z m0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z" p-id="7627"></path>
4
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg t="1665313505832" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7765" width="200" height="200">
2
+ <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" p-id="7766"></path>
3
+ <path d="M512 336m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z" p-id="7767"></path>
4
+ <path d="M536 448h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z" p-id="7768"></path>
5
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg t="1665313581686" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8045" width="200" height="200">
2
+ <path d="M832 464h-68V240c0-70.7-57.3-128-128-128H388c-70.7 0-128 57.3-128 128v224h-68c-17.7 0-32 14.3-32 32v384c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V496c0-17.7-14.3-32-32-32zM332 240c0-30.9 25.1-56 56-56h248c30.9 0 56 25.1 56 56v224H332V240z m460 600H232V536h560v304z" p-id="8046"></path>
3
+ <path d="M484 701v53c0 4.4 3.6 8 8 8h40c4.4 0 8-3.6 8-8v-53c12.1-8.7 20-22.9 20-39 0-26.5-21.5-48-48-48s-48 21.5-48 48c0 16.1 7.9 30.3 20 39z" p-id="8047"></path>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg t="1665313601302" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8185" width="200" height="200">
2
+ <path d="M832 464H332V240c0-30.9 25.1-56 56-56h248c30.9 0 56 25.1 56 56v68c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-68c0-70.7-57.3-128-128-128H388c-70.7 0-128 57.3-128 128v224h-68c-17.7 0-32 14.3-32 32v384c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V496c0-17.7-14.3-32-32-32z m-40 376H232V536h560v304z" p-id="8186"></path>
3
+ <path d="M484 701v53c0 4.4 3.6 8 8 8h40c4.4 0 8-3.6 8-8v-53c12.1-8.7 20-22.9 20-39 0-26.5-21.5-48-48-48s-48 21.5-48 48c0 16.1 7.9 30.3 20 39z" p-id="8187"></path>
4
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg t="1665313543054" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7906" width="200" height="200">
2
+ <path d="M858.5 763.6c-18.9-44.8-46.1-85-80.6-119.5-34.5-34.5-74.7-61.6-119.5-80.6-0.4-0.2-0.8-0.3-1.2-0.5C719.5 518 760 444.7 760 362c0-137-111-248-248-248S264 225 264 362c0 82.7 40.5 156 102.8 201.1-0.4 0.2-0.8 0.3-1.2 0.5-44.8 18.9-85 46-119.5 80.6-34.5 34.5-61.6 74.7-80.6 119.5C146.9 807.5 137 854 136 901.8c-0.1 4.5 3.5 8.2 8 8.2h60c4.4 0 7.9-3.5 8-7.8 2-77.2 33-149.5 87.8-204.3 56.7-56.7 132-87.9 212.2-87.9s155.5 31.2 212.2 87.9C779 752.7 810 825 812 902.2c0.1 4.4 3.6 7.8 8 7.8h60c4.5 0 8.1-3.7 8-8.2-1-47.8-10.9-94.3-29.5-138.2zM512 534c-45.9 0-89.1-17.9-121.6-50.4S340 407.9 340 362c0-45.9 17.9-89.1 50.4-121.6S466.1 190 512 190s89.1 17.9 121.6 50.4S684 316.1 684 362c0 45.9-17.9 89.1-50.4 121.6S557.9 534 512 534z" p-id="7907"></path>
3
+ </svg>
@@ -0,0 +1,95 @@
1
+ :host {
2
+ position: relative;
3
+ display: inline-block;
4
+ font-weight: 400;
5
+ white-space: nowrap;
6
+ text-align: center;
7
+ background-image: none;
8
+ border: 1px solid transparent;
9
+ box-shadow: 0 2px #00000004;
10
+ cursor: pointer;
11
+ transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
12
+ -webkit-user-select: none;
13
+ -moz-user-select: none;
14
+ -ms-user-select: none;
15
+ user-select: none;
16
+ touch-action: manipulation;
17
+ line-height: 22px;
18
+ font-size: 14px;
19
+ border-radius: 2px;
20
+ color: #000000d9;
21
+ border-color: #d9d9d9;
22
+ background: #fff;
23
+ overflow: hidden;
24
+ pointer-events: auto;
25
+ &,
26
+ &(:active),
27
+ &(:focus) {
28
+ outline: 0;
29
+ }
30
+ &(:not([disabled]):hover) {
31
+ border-color: #1890ff;
32
+ color: #1890ff;
33
+ }
34
+ &([type="primary"]) {
35
+ border-color: #1890ff;
36
+ background-color: #1890ff;
37
+ color: #fff;
38
+ }
39
+ &([type="primary"]:not([disabled]))::after {
40
+ background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
41
+ }
42
+ &([type="primary"]:not([disabled]):hover) {
43
+ background-color: #40a9ff;
44
+ color: #fff;
45
+ }
46
+ &([type="warning"]) {
47
+ border-color: #ff4d4f;
48
+ background-color: #ff4d4f;
49
+ color: #fff;
50
+ }
51
+ &([type="warning"]:not([disabled]))::after {
52
+ background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
53
+ }
54
+ &([type="warning"]:not([disabled]):hover) {
55
+ border-color: #ff4d4f;
56
+ background-color: #ff4d4f;
57
+ color: #fff;
58
+ }
59
+ &([type="text"]) {
60
+ border: none;
61
+ }
62
+ &([disabled]) {
63
+ cursor: not-allowed;
64
+ pointer-events: all;
65
+ opacity: 0.6;
66
+ }
67
+ &(:not([disabled]):active)::after {
68
+ transform: translate(-50%, -50%) scale(0);
69
+ opacity: 0.3;
70
+ transition: 0s;
71
+ }
72
+ &(:active) .btn::before {
73
+ opacity: 0.2;
74
+ }
75
+ &(:not([disabled]))::after {
76
+ content: "";
77
+ display: block;
78
+ position: absolute;
79
+ width: 100%;
80
+ height: 100%;
81
+ left: var(--ran-x, 0);
82
+ top: var(--ran-y, 0);
83
+ pointer-events: none;
84
+ background-image: radial-gradient(circle, #1890ff 10%, transparent 10.01%);
85
+ background-repeat: no-repeat;
86
+ background-position: 50%;
87
+ transform: translate(-50%, -50%) scale(10);
88
+ opacity: 0;
89
+ transition: transform 0.3s, opacity 0.8s;
90
+ }
91
+ .slot {
92
+ display: block;
93
+ margin: 4px 15px;
94
+ }
95
+ }
@@ -0,0 +1,64 @@
1
+ import { isDisabled } from '@/utils/index'
2
+
3
+ class CustomElement extends HTMLElement {
4
+ static get observedAttributes() {
5
+ return ["disabled", "type"];
6
+ }
7
+ _btn: HTMLDivElement;
8
+ constructor() {
9
+ super();
10
+ const slot = document.createElement("slot");
11
+ this._btn = document.createElement("div");
12
+ this._btn.appendChild(slot);
13
+ slot.setAttribute("class", "slot");
14
+ const shadowRoot = this.attachShadow({ mode: "closed" });
15
+ shadowRoot.appendChild(this._btn);
16
+ }
17
+ get disabled() {
18
+ return isDisabled(this)
19
+ }
20
+ set disabled(value: boolean | string | undefined | null) {
21
+ if (!value || value === "false") {
22
+ this.removeAttribute("disabled");
23
+ } else {
24
+ this.setAttribute("disabled", '');
25
+ }
26
+ }
27
+ mousedown = (event: MouseEvent) => {
28
+ if (!this.disabled || this.disabled === 'false') {
29
+ const { left, top } = this.getBoundingClientRect();
30
+ this.style.setProperty("--ran-x", event.clientX - left + "px");
31
+ this.style.setProperty("--ran-y", event.clientY - top + "px");
32
+ }
33
+ };
34
+ mouseLeave = () => {
35
+ this.style.removeProperty("--ran-x");
36
+ this.style.removeProperty("--ran-y");
37
+ };
38
+ connectedCallback() {
39
+ this._btn.addEventListener("mousedown", this.mousedown);
40
+ this._btn.addEventListener("mouseleave", this.mouseLeave);
41
+ }
42
+ disconnectCallback() {
43
+ this._btn.removeEventListener("mousedown", this.mousedown);
44
+ this._btn.removeEventListener("mouseleave", this.mouseLeave);
45
+ }
46
+ attributeChangedCallback(name: string, oldValue: string, newValue: string) {
47
+ if (name == "disabled" && this._btn) {
48
+ if (!newValue || newValue === "false") {
49
+ this._btn.setAttribute("disabled", '');
50
+ } else {
51
+ this._btn.removeAttribute("disabled");
52
+
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ function Custom() {
59
+ if (!customElements.get("r-button")) {
60
+ customElements.define("r-button", CustomElement);
61
+ }
62
+ }
63
+
64
+ export default Custom()
File without changes
@@ -0,0 +1,36 @@
1
+ function Component() {
2
+ const template = document.createElement('template');
3
+ const slot = document.createElement('slot');
4
+ const form = document.createElement('form');
5
+ form.setAttribute('class', 'r-form');
6
+ slot.setAttribute('name', 'r-form_content');
7
+ form.appendChild(slot);
8
+ template.appendChild(form);
9
+ class CustomElement extends HTMLElement {
10
+ _form: HTMLFormElement;
11
+ constructor() {
12
+ super();
13
+ this._form = form.cloneNode(true) as HTMLFormElement
14
+ const shadowRoot = this.attachShadow({ mode: 'closed' });
15
+ const jsonData: Record<string, any> = {}
16
+ const formData = new FormData(this._form)
17
+ formData.forEach((value, key) => {
18
+ if (!jsonData[key]) {
19
+ jsonData[key] = formData.getAll(key).length > 1 ? formData.getAll(key) : formData.get(key);
20
+ }
21
+ });
22
+ this._form.addEventListener("submit", () => {
23
+ this.value = JSON.stringify(jsonData)
24
+ });
25
+ shadowRoot.appendChild(this._form);
26
+ }
27
+ get value() {
28
+ return this.getAttribute("value");
29
+ }
30
+ set value(value) {
31
+ if (value !== null) this.setAttribute("value", value);
32
+ }
33
+ }
34
+ window.customElements.define('r-form', CustomElement)
35
+ }
36
+ export default Component()
File without changes
@@ -0,0 +1,62 @@
1
+ import failImage from "@/assets/image/failImage";
2
+
3
+ class CustomElement extends HTMLElement {
4
+ static get observedAttributes() {
5
+ return ["fallback"];
6
+ }
7
+ _image: HTMLImageElement | undefined;
8
+ _container: Element;
9
+ constructor() {
10
+ super();
11
+ this._container = document.createElement("div");
12
+ this._container.setAttribute("class", "r-image");
13
+ const shadowRoot = this.attachShadow({ mode: "closed" });
14
+ shadowRoot.appendChild(this._container);
15
+ }
16
+ get fallback() {
17
+ return this.getAttribute("fallback");
18
+ }
19
+ set fallback(value) {
20
+ if (value) {
21
+ this.setAttribute("fallback", value);
22
+ } else {
23
+ this.removeAttribute("fallback");
24
+ }
25
+ }
26
+
27
+ listenFallback(name: string, value: string) {
28
+ if (name === "fallback" && this._image) {
29
+ if (value) {
30
+ this._image.setAttribute("fallback", value);
31
+ } else {
32
+ this._image.removeAttribute("fallback");
33
+ }
34
+ }
35
+ }
36
+
37
+ connectedCallback() {
38
+ const src = this.getAttribute("src") || "";
39
+ this._image = new Image();
40
+ this._image.src = src;
41
+ this._image.addEventListener("error", () => {
42
+ if (this._image && this.fallback) {
43
+ this._image.src = this.fallback;
44
+ }
45
+ });
46
+ this._image.addEventListener("load", () => {
47
+ if (this._image) {
48
+ this._container.appendChild(this._image);
49
+ }
50
+ });
51
+ }
52
+ attributeChangedCallback(name: string, oldValue: string, newValue: string) {
53
+ this.listenFallback(name, newValue);
54
+ }
55
+ }
56
+ function Custom() {
57
+ if (!customElements.get("r-img")) {
58
+ customElements.define("r-img", CustomElement);
59
+ }
60
+ }
61
+
62
+ export default Custom();
@@ -0,0 +1,114 @@
1
+ .input {
2
+ position: relative;
3
+ display: inline-block;
4
+ width: 100%;
5
+ min-width: 0;
6
+ padding: 2px 8px;
7
+ color: #000000d9;
8
+ font-size: 12px;
9
+ line-height: 1.5715;
10
+ background-color: #fff;
11
+ background-image: none;
12
+ border: 1px solid #d9d9d9;
13
+ border-radius: 2px;
14
+ transition: all 0.3s;
15
+ &:active {
16
+ border-color: #40a9ff;
17
+ box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
18
+ border-right-width: 1px;
19
+ outline: 0;
20
+ }
21
+ &:hover {
22
+ border-color: #40a9ff;
23
+ border-right-width: 1px;
24
+ }
25
+ & > .input-main:hover ~ .input-label {
26
+ color: #40a9ff;
27
+ }
28
+ &[value] > .input-label {
29
+ transform: translateY(calc(-50% - 0.43em)) scale(0.8);
30
+ color: #00000040;
31
+ }
32
+ &[disabled] {
33
+ color: #00000040;
34
+ background-color: #f5f5f5;
35
+ border-color: #d9d9d9;
36
+ box-shadow: none;
37
+ cursor: not-allowed;
38
+ opacity: 1;
39
+ & > .input-main {
40
+ color: #00000040;
41
+ background-color: #f5f5f5;
42
+ border-color: #d9d9d9;
43
+ box-shadow: none;
44
+ cursor: not-allowed;
45
+ opacity: 1;
46
+ }
47
+ & > .input-main:hover ~ .input-label {
48
+ color: #999;
49
+ }
50
+ & > .input-label {
51
+ color: #999;
52
+ border-color: #d9d9d9;
53
+ box-shadow: none;
54
+ cursor: not-allowed;
55
+ }
56
+ }
57
+ &-main {
58
+ writing-mode: horizontal-tb;
59
+ text-rendering: auto;
60
+ letter-spacing: normal;
61
+ word-spacing: normal;
62
+ text-transform: none;
63
+ text-indent: 0px;
64
+ text-shadow: none;
65
+ text-align: start;
66
+ -webkit-rtl-ordering: logical;
67
+ cursor: text;
68
+ touch-action: manipulation;
69
+ -webkit-appearance: none;
70
+ text-overflow: ellipsis;
71
+ box-sizing: border-box;
72
+ margin: 0;
73
+ font-variant: tabular-nums;
74
+ list-style: none;
75
+ font-feature-settings: "tnum";
76
+ position: relative;
77
+ border: none;
78
+ width: 100%;
79
+ min-width: 0;
80
+ color: #000000d9;
81
+ font-size: 14px;
82
+ line-height: 1.5715;
83
+ background-color: #fff;
84
+ background-image: none;
85
+ transition: all 0.3s;
86
+ &:focus,
87
+ &:hover {
88
+ border: none;
89
+ outline: 0;
90
+ }
91
+ &::placeholder {
92
+ color: #999;
93
+ }
94
+ &:placeholder-shown ~ .input-label {
95
+ transform: translateY(calc(-50% - 0.43em)) scale(0.8);
96
+ }
97
+ &:focus ~ .input-label {
98
+ transform: translateY(calc(-50% - 0.43em)) scale(0.8);
99
+ }
100
+ }
101
+ &-label {
102
+ pointer-events: none;
103
+ position: absolute;
104
+ font-size: 14px;
105
+ left: 8px;
106
+ transition: transform 0.3s, color 0.3s, background-color 0.3s;
107
+ transform-origin: left;
108
+ padding: 0 0.2em;
109
+ color: #999;
110
+ // background: #fff;
111
+ backdrop-filter: blur(10px);
112
+ opacity: 0.9;
113
+ }
114
+ }