@operato/input 1.0.0-beta.12 → 1.0.0-beta.13
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/CHANGELOG.md +24 -0
- package/demo/index-multiple-colors.html +4 -1
- package/demo/index-partition-keys.html +2 -5
- package/demo/index.html +4 -0
- package/dist/src/locales/en.d.ts +8 -0
- package/dist/src/locales/en.js +8 -0
- package/dist/src/locales/en.js.map +1 -1
- package/dist/src/locales/ko.d.ts +8 -0
- package/dist/src/locales/ko.js +8 -0
- package/dist/src/locales/ko.js.map +1 -1
- package/dist/src/locales/ms.d.ts +8 -0
- package/dist/src/locales/ms.js +8 -0
- package/dist/src/locales/ms.js.map +1 -1
- package/dist/src/locales/zh.d.ts +8 -0
- package/dist/src/locales/zh.js +8 -0
- package/dist/src/locales/zh.js.map +1 -1
- package/dist/src/ox-input-3dish.js +24 -8
- package/dist/src/ox-input-3dish.js.map +1 -1
- package/dist/src/ox-input-color.js +16 -11
- package/dist/src/ox-input-color.js.map +1 -1
- package/dist/src/ox-input-crontab.js +13 -10
- package/dist/src/ox-input-crontab.js.map +1 -1
- package/dist/src/ox-input-multiple-colors.d.ts +1 -0
- package/dist/src/ox-input-multiple-colors.js +29 -21
- package/dist/src/ox-input-multiple-colors.js.map +1 -1
- package/dist/src/ox-input-options.d.ts +1 -0
- package/dist/src/ox-input-options.js +54 -14
- package/dist/src/ox-input-options.js.map +1 -1
- package/dist/src/ox-input-partition-keys.d.ts +1 -0
- package/dist/src/ox-input-partition-keys.js +51 -23
- package/dist/src/ox-input-partition-keys.js.map +1 -1
- package/dist/src/ox-input-search.js +7 -2
- package/dist/src/ox-input-search.js.map +1 -1
- package/dist/src/ox-input-unit.d.ts +17 -0
- package/dist/src/ox-input-unit.js +112 -0
- package/dist/src/ox-input-unit.js.map +1 -0
- package/dist/src/ox-input-work-shift.js +19 -17
- package/dist/src/ox-input-work-shift.js.map +1 -1
- package/dist/stories/ox-input-3dish.stories.d.ts +26 -0
- package/dist/stories/ox-input-3dish.stories.js +59 -0
- package/dist/stories/ox-input-3dish.stories.js.map +1 -0
- package/dist/stories/ox-input-barcode.stories.d.ts +33 -0
- package/dist/stories/ox-input-barcode.stories.js +22 -0
- package/dist/stories/ox-input-barcode.stories.js.map +1 -0
- package/dist/stories/ox-input-conntab.stories.d.ts +26 -0
- package/dist/stories/ox-input-conntab.stories.js +37 -0
- package/dist/stories/ox-input-conntab.stories.js.map +1 -0
- package/dist/stories/ox-input-multiple-colors.stories.d.ts +20 -0
- package/dist/stories/ox-input-multiple-colors.stories.js +167 -0
- package/dist/stories/ox-input-multiple-colors.stories.js.map +1 -0
- package/dist/stories/ox-input-options.stories.d.ts +25 -0
- package/dist/stories/ox-input-options.stories.js +33 -0
- package/dist/stories/ox-input-options.stories.js.map +1 -0
- package/dist/stories/ox-input-partition-keys.stories.d.ts +27 -0
- package/dist/stories/ox-input-partition-keys.stories.js +55 -0
- package/dist/stories/ox-input-partition-keys.stories.js.map +1 -0
- package/dist/stories/ox-input-range.stories.d.ts +37 -0
- package/dist/stories/ox-input-range.stories.js +25 -0
- package/dist/stories/ox-input-range.stories.js.map +1 -0
- package/dist/stories/ox-input-search.stories.d.ts +29 -0
- package/dist/stories/ox-input-search.stories.js +28 -0
- package/dist/stories/ox-input-search.stories.js.map +1 -0
- package/dist/stories/ox-input-unit.stories.d.ts +40 -0
- package/dist/stories/ox-input-unit.stories.js +41 -0
- package/dist/stories/ox-input-unit.stories.js.map +1 -0
- package/dist/stories/ox-input-work-shift.stories.d.ts +26 -0
- package/dist/stories/ox-input-work-shift.stories.js +59 -0
- package/dist/stories/ox-input-work-shift.stories.js.map +1 -0
- package/dist/stories/ox-select.stories.d.ts +30 -0
- package/dist/stories/ox-select.stories.js +82 -0
- package/dist/stories/ox-select.stories.js.map +1 -0
- package/dist/themes/common-grist-styles.d.ts +1 -0
- package/dist/themes/common-grist-styles.js +110 -0
- package/dist/themes/common-grist-styles.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/locales/en.ts +8 -0
- package/src/locales/ko.ts +8 -0
- package/src/locales/ms.ts +8 -0
- package/src/locales/zh.ts +8 -0
- package/src/ox-input-3dish.ts +24 -8
- package/src/ox-input-color.ts +17 -11
- package/src/ox-input-crontab.ts +13 -10
- package/src/ox-input-multiple-colors.ts +29 -21
- package/src/ox-input-options.ts +53 -13
- package/src/ox-input-partition-keys.ts +51 -22
- package/src/ox-input-search.ts +7 -2
- package/src/ox-input-unit.ts +112 -0
- package/src/ox-input-work-shift.ts +20 -17
- package/stories/ox-input-3dish.stories.ts +73 -0
- package/stories/ox-input-barcode.stories.ts +38 -0
- package/stories/ox-input-code.stories.ts_ +71 -0
- package/stories/ox-input-conntab.stories.ts +51 -0
- package/stories/ox-input-multiple-colors.stories.ts +178 -0
- package/stories/ox-input-options.stories.ts +47 -0
- package/stories/ox-input-partition-keys.stories.ts +71 -0
- package/stories/ox-input-range.stories.ts +42 -0
- package/stories/ox-input-search.stories.ts +43 -0
- package/stories/ox-input-unit.stories.ts +65 -0
- package/stories/ox-input-work-shift.stories.ts +73 -0
- package/stories/ox-select.stories.ts +100 -0
- package/themes/app-theme.css +142 -0
- package/themes/common-grist-styles.ts +110 -0
- package/themes/input-theme.css +19 -0
- package/xliff/en.xlf +24 -0
- package/xliff/ko.xlf +32 -0
- package/xliff/ms.xlf +24 -0
- package/xliff/zh.xlf +24 -0
- package/stories/index.stories.ts_ +0 -52
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-crontab.js","sourceRoot":"","sources":["../../src/ox-input-crontab.ts"],"names":[],"mappings":";AAAA,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,C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5G,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;YACxB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI,CAAC,KAAK;SACnB,CAAC,CACH,CAAA;IACH,CAAC;CACF,CAAA;AAtV6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAoB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAmB;AAErC;IAAR,KAAK,EAAE;+CAAuD;AAnJpD,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAie1B;SAjeY,cAAc","sourcesContent":["import '@material/mwc-button'\n\nimport { css, html, PropertyValues } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\nimport { OxFormField } from './ox-form-field'\n\nfunction createCronRegex(type: 'sec' | 'min' | 'hour' | 'day' | 'month' | 'dayOfWeek') {\n // https://gist.github.com/dkandalov/a2aed17cfdeb65243022\n var regexByField = {} as any\n regexByField['sec'] = '[0-5]?\\\\d'\n regexByField['min'] = '[0-5]?\\\\d'\n regexByField['hour'] = '[01]?\\\\d|2[0-3]'\n regexByField['day'] = '0?[1-9]|[12]\\\\d|3[01]'\n regexByField['month'] = '[1-9]|1[012]'\n regexByField['dayOfWeek'] = '[0-7]'\n\n var crontabFields = [type]\n if (!type) crontabFields = ['sec', 'min', 'hour', 'day', 'month', 'dayOfWeek']\n\n crontabFields.forEach(field => {\n var number = regexByField[field]\n var range =\n '(?:' +\n number +\n ')' +\n '(?:' +\n '(?:-|/|,' +\n ('dayOfWeek' === field ? '|#' : '') +\n ')' +\n '(?:' +\n number +\n ')' +\n ')?'\n if (field === 'dayOfWeek') range += '(?:L)?'\n if (field === 'month') range += '(?:L|W)?'\n regexByField[field] = '\\\\?|\\\\*|' + range + '(?:,' + range + ')*'\n })\n\n var monthValues = 'JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC'\n var monthRange = '(?:' + monthValues + ')(?:(?:-)(?:' + monthValues + '))?'\n regexByField['month'] += '|\\\\?|\\\\*|' + monthRange + '(?:,' + monthRange + ')*'\n\n var dayOfWeekValues = 'MON|TUE|WED|THU|FRI|SAT|SUN'\n var dayOfWeekRange = '(?:' + dayOfWeekValues + ')(?:(?:-)(?:' + dayOfWeekValues + '))?'\n regexByField['dayOfWeek'] += '|\\\\?|\\\\*|' + dayOfWeekRange + '(?:,' + dayOfWeekRange + ')*'\n\n if (!type)\n return (\n '^\\\\s*($' +\n '|#' +\n '|\\\\w+\\\\s*=' +\n '|' +\n '(' +\n regexByField['sec'] +\n ')\\\\s+' +\n '(' +\n regexByField['min'] +\n ')\\\\s+' +\n '(' +\n regexByField['hour'] +\n ')\\\\s+' +\n '(' +\n regexByField['day'] +\n ')\\\\s+' +\n '(' +\n regexByField['month'] +\n ')\\\\s+' +\n '(' +\n regexByField['dayOfWeek'] +\n ')(|\\\\s)+' +\n ')$'\n )\n else return `^${regexByField[type]}$`\n}\n\n@customElement('ox-input-crontab')\nexport class OxInputCrontab extends OxFormField {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n border: 0;\n background-color: var(--main-section-background-color);\n }\n\n :host * {\n box-sizing: border-box;\n }\n :host *:focus {\n outline: none;\n }\n\n form {\n display: grid;\n width: 100%;\n height: 100%;\n padding: 1rem;\n grid-template: auto auto 1fr auto / repeat(6, 1fr);\n grid-gap: 0.5rem;\n justify-content: center;\n align-items: center;\n overflow: auto;\n }\n\n label[for='example'] {\n text-align: right;\n grid-column: 3;\n font: normal 1em var(--theme-font);\n color: var(--secondary-color);\n text-transform: capitalize;\n }\n\n #example {\n grid-column: 4 / span 3;\n width: 100%;\n height: 100%;\n font: normal 0.9em var(--theme-font);\n text-transform: capitalize;\n border-radius: var(--border-radius);\n border: var(--border-dark-color);\n }\n\n input {\n width: 100%;\n margin-top: var(--margin-default);\n padding: 5px;\n border-radius: var(--border-radius);\n border: var(--border-dark-color);\n font: normal 1em var(--theme-font);\n }\n input:focus {\n border: 1px solid var(--primary-color);\n }\n\n input:invalid {\n border: 1px solid var(--status-danger-color);\n color: var(--status-danger-color);\n }\n\n label {\n width: 100%;\n height: 100%;\n font: normal 0.8em var(--theme-font);\n color: var(--primary-color);\n }\n\n label:not([for='example']) {\n text-align: center;\n }\n\n #input-wrapper {\n grid-column: span 6;\n display: flex;\n flex-wrap: wrap;\n margin: 0 -0.25rem;\n }\n\n #input-wrapper > div {\n flex: 1;\n display: grid;\n grid-template-rows: 1fr auto;\n grid-gap: 0.5rem;\n min-width: 60px;\n max-width: 33%;\n margin: 0.25rem;\n }\n\n #tooltip {\n grid-column: span 6;\n display: grid;\n grid-template-columns: auto 1fr;\n grid-gap: 0;\n margin: auto;\n grid-auto-rows: min-content;\n align-self: center;\n align-items: center;\n }\n\n #tooltip > div {\n padding: 0.25rem 0.5rem;\n border-bottom: #ccc 1px dashed;\n font: normal 0.9em var(--theme-font);\n }\n\n #tooltip > .crontab-value {\n text-align: right;\n color: var(--secondary-color);\n }\n\n #tooltip > .crontab-description {\n text-align: left;\n color: #585858;\n }\n\n #button-wrapper {\n grid-column: 1 / span 6;\n display: flex;\n flex-wrap: wrap-reverse;\n flex-direction: row-reverse;\n margin: -0.25rem;\n }\n\n mwc-button {\n background-color: var(--secondary-color);\n border-radius: var(--button-border-radius);\n --mdc-theme-primary: #fff;\n margin: 0.25rem;\n }\n mwc-button:hover,\n mwc-button:active {\n background-color: var(--primary-color);\n }\n `\n\n @property({ type: String }) value?: string\n @property({ type: String }) second?: string\n @property({ type: String }) minute?: string\n @property({ type: String }) hour?: string\n @property({ type: String }) dayOfMonth?: string\n @property({ type: String }) month?: string\n @property({ type: String }) dayOfWeek?: string\n\n @state() tooltip: { value: string; description: string }[] = []\n\n render() {\n return html`\n <form>\n <label for=\"example\">${i18next.t('label.examples')}</label>\n <select\n id=\"example\"\n @change=${(e: Event) => (this.value = (e.currentTarget as HTMLInputElement).value)}\n .value=${this.value}\n >\n <optgroup label=\"${i18next.t('label.second by second')}\">\n <option value=\"* * * * * *\">${i18next.t('text.every second')}</option>\n <option value=\"0/2 * * * * *\">${i18next.t('text.every 2 seconds')}</option>\n <option value=\"0/15 * * * * *\">${i18next.t('text.every 15 seconds')}</option>\n <option value=\"0/30 * * * * *\">${i18next.t('text.every 30 seconds')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.minute by minute')}\">\n <option value=\"0 * * * * *\">${i18next.t('text.every minute')}</option>\n <option value=\"0 0/2 * * * *\">${i18next.t('text.every 2 minutes')}</option>\n <option value=\"0 0/15 * * * *\">${i18next.t('text.every 15 minutes')}</option>\n <option value=\"0 0/30 * * * *\">${i18next.t('text.every half hour')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.hourly')}\">\n <option value=\"0 0 * * * *\">${i18next.t('text.every hour')}</option>\n <option value=\"0 0 0/2 * * *\">${i18next.t('text.every 2 hours')}</option>\n <option value=\"0 0 0/12 * * *\">${i18next.t('text.every 12 hours')}</option>\n <option value=\"0 0 10-19 * * *\">${i18next.t('text.every hour during working time')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.daily')}\">\n <option value=\"0 0 0 * * *\">${i18next.t('text.every day')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.weekly')}\">\n <option value=\"0 0 0 * * SUN\">${i18next.t('text.every sunday')}</option>\n <option value=\"0 0 0 * * 0\">${i18next.t('text.every sunday(2)')}</option>\n <option value=\"0 0 0 * * 1-5\">${i18next.t('text.every weekday')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.monthly')}\">\n <option value=\"0 0 0 1 * *\">${i18next.t('text.the first day of every month')}</option>\n <option value=\"0 0 10 21 * *\">${i18next.t('text.10 am on every payday')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.yearly')}\">\n <option value=\"0 0 0 1 1 *\">${i18next.t('text.the first day of every year')}</option>\n <option value=\"0 0 0 25 12 *\">${i18next.t('text.every christmas')}</option>\n </optgroup>\n </select>\n <div id=\"input-wrapper\">\n <div>\n <input\n id=\"second-input\"\n class=\"second\"\n type=\"text\"\n .value=${this.second || ''}\n @input=${(e: Event) => (this.second = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('second')\n }}\n pattern=${createCronRegex('sec')}\n required\n />\n <label for=\"second-input\" class=\"second\">${i18next.t('label.second')}</label>\n </div>\n <div>\n <input\n id=\"minute-input\"\n class=\"minute\"\n type=\"text\"\n .value=${this.minute || ''}\n @input=${(e: Event) => (this.minute = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('minute')\n }}\n pattern=${createCronRegex('min')}\n required\n />\n <label for=\"minute-input\" class=\"minute\">${i18next.t('label.minute')}</label>\n </div>\n <div>\n <input\n id=\"hour-input\"\n class=\"hour\"\n type=\"text\"\n .value=${this.hour || ''}\n @input=${(e: Event) => (this.hour = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('hour')\n }}\n pattern=${createCronRegex('hour')}\n required\n />\n <label for=\"hour-input\" class=\"hour\">${i18next.t('label.hour')}</label>\n </div>\n <div>\n <input\n id=\"day-of-month-input\"\n class=\"day-of-month\"\n type=\"text\"\n .value=${this.dayOfMonth || ''}\n @input=${(e: Event) => (this.dayOfMonth = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('dayOfMonth')\n }}\n pattern=${createCronRegex('day')}\n required\n />\n <label for=\"day-of-month-input\" class=\"day-of-month\">${i18next.t('label.day-of-month')}</label>\n </div>\n <div>\n <input\n id=\"month-input\"\n class=\"month\"\n type=\"text\"\n .value=${this.month || ''}\n @input=${(e: Event) => (this.month = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('month')\n }}\n pattern=${createCronRegex('month')}\n required\n />\n <label for=\"month-input\" class=\"month\">${i18next.t('label.month')}</label>\n </div>\n <div>\n <input\n id=\"day-of-week-input\"\n class=\"day-of-week\"\n type=\"text\"\n .value=${this.dayOfWeek || ''}\n @input=${(e: Event) => (this.dayOfWeek = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('dayOfWeek')\n }}\n pattern=${createCronRegex('dayOfWeek')}\n required\n />\n <label for=\"day-of-week-input\" class=\"day-of-week\">${i18next.t('label.day-of-week')}</label>\n </div>\n </div>\n <div id=\"tooltip\">\n ${this.tooltip.map(\n tip => html`\n <div class=\"crontab-value\">${tip.value}</div>\n <div class=\"crontab-description\">${i18next.t(`text.${tip.description}`)}</div>\n `\n )}\n </div>\n </form>\n `\n }\n\n get focusableElements(): HTMLElement[] {\n return Array.from(this.renderRoot.querySelectorAll('select, input, mwc-button'))\n }\n\n firstUpdated() {\n ;(this.renderRoot.querySelector('input') as HTMLInputElement).focus()\n this.renderRoot.addEventListener('change', this.onChange.bind(this))\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n var values = (this.value || '').split(' ')\n\n if (values.length == 1) values = ['*', '*', '*', '*', '*', '*']\n else if (values.length == 5) values = ['0'].concat(values)\n\n this.second = values[0]\n this.minute = values[1]\n this.hour = values[2]\n this.dayOfMonth = values[3]\n this.month = values[4]\n this.dayOfWeek = values[5]\n }\n }\n\n showTooltip(type: 'second' | 'minute' | 'hour' | 'dayOfMonth' | 'month' | 'dayOfWeek') {\n switch (type) {\n case 'second':\n case 'minute':\n this.tooltip = [\n {\n value: '*',\n description: 'any value'\n },\n {\n value: ',',\n description: 'value list separator'\n },\n {\n value: '-',\n description: 'range of values'\n },\n {\n value: '/',\n description: 'step values'\n },\n {\n value: '0-59',\n description: 'allowed values'\n }\n ]\n break\n case 'hour':\n this.tooltip = [\n {\n value: '*',\n description: 'any value'\n },\n {\n value: ',',\n description: 'value list separator'\n },\n {\n value: '-',\n description: 'range of values'\n },\n {\n value: '/',\n description: 'step values'\n },\n {\n value: '0-23',\n description: 'allowed values'\n }\n ]\n break\n\n case 'dayOfMonth':\n this.tooltip = [\n {\n value: '*',\n description: 'any value'\n },\n {\n value: ',',\n description: 'value list separator'\n },\n {\n value: '-',\n description: 'range of values'\n },\n {\n value: '/',\n description: 'step values'\n },\n {\n value: '1-31',\n description: 'allowed values'\n }\n ]\n break\n\n case 'month':\n this.tooltip = [\n {\n value: '*',\n description: 'any value'\n },\n {\n value: ',',\n description: 'value list separator'\n },\n {\n value: '-',\n description: 'range of values'\n },\n {\n value: '/',\n description: 'step values'\n },\n {\n value: '1-12',\n description: 'allowed values'\n },\n {\n value: 'JAN-DEC',\n description: 'alternative single values'\n }\n ]\n break\n\n case 'dayOfWeek':\n this.tooltip = [\n {\n value: '*',\n description: 'any value'\n },\n {\n value: ',',\n description: 'value list separator'\n },\n {\n value: '-',\n description: 'range of values'\n },\n {\n value: '/',\n description: 'step values'\n },\n {\n value: '0-6',\n description: 'allowed values'\n },\n {\n value: 'SUN-SAT',\n description: 'alternative single values'\n }\n ]\n break\n\n default:\n this.tooltip = []\n break\n }\n }\n\n onChange() {\n var form = this.renderRoot.querySelector('form') as HTMLFormElement\n var valid = form.checkValidity()\n if (!valid) {\n form.reportValidity()\n return\n }\n\n this.value = `${this.second} ${this.minute} ${this.hour} ${this.dayOfMonth} ${this.month} ${this.dayOfWeek}`\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ox-input-crontab.js","sourceRoot":"","sources":["../../src/ox-input-crontab.ts"],"names":[],"mappings":";AAAA,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,SAAS,eAAe,CAAC,IAA4D;IACnF,yDAAyD;IACzD,IAAI,YAAY,GAAG,EAAS,CAAA;IAC5B,YAAY,CAAC,KAAK,CAAC,GAAG,WAAW,CAAA;IACjC,YAAY,CAAC,KAAK,CAAC,GAAG,WAAW,CAAA;IACjC,YAAY,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAA;IACxC,YAAY,CAAC,KAAK,CAAC,GAAG,uBAAuB,CAAA;IAC7C,YAAY,CAAC,OAAO,CAAC,GAAG,cAAc,CAAA;IACtC,YAAY,CAAC,WAAW,CAAC,GAAG,OAAO,CAAA;IAEnC,IAAI,aAAa,GAAG,CAAC,IAAI,CAAC,CAAA;IAC1B,IAAI,CAAC,IAAI;QAAE,aAAa,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;IAE9E,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC5B,IAAI,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;QAChC,IAAI,KAAK,GACP,KAAK;YACL,MAAM;YACN,GAAG;YACH,KAAK;YACL,UAAU;YACV,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YACnC,GAAG;YACH,KAAK;Y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,CAAoB,CAAA;QACnE,IAAI,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QAChC,IAAI,CAAC,KAAK,EAAE;YACV,IAAI,CAAC,cAAc,EAAE,CAAA;YACrB,OAAM;SACP;QAED,IAAI,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE,CAAA;QAE5G,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;YACxB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI,CAAC,KAAK;SACnB,CAAC,CACH,CAAA;IACH,CAAC;CACF,CAAA;AAtV6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAoB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAmB;AAErC;IAAR,KAAK,EAAE;+CAAuD;AAtJpD,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAoe1B;SApeY,cAAc","sourcesContent":["import '@material/mwc-button'\n\nimport { css, html, PropertyValues } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\nimport { OxFormField } from './ox-form-field'\n\nfunction createCronRegex(type: 'sec' | 'min' | 'hour' | 'day' | 'month' | 'dayOfWeek') {\n // https://gist.github.com/dkandalov/a2aed17cfdeb65243022\n var regexByField = {} as any\n regexByField['sec'] = '[0-5]?\\\\d'\n regexByField['min'] = '[0-5]?\\\\d'\n regexByField['hour'] = '[01]?\\\\d|2[0-3]'\n regexByField['day'] = '0?[1-9]|[12]\\\\d|3[01]'\n regexByField['month'] = '[1-9]|1[012]'\n regexByField['dayOfWeek'] = '[0-7]'\n\n var crontabFields = [type]\n if (!type) crontabFields = ['sec', 'min', 'hour', 'day', 'month', 'dayOfWeek']\n\n crontabFields.forEach(field => {\n var number = regexByField[field]\n var range =\n '(?:' +\n number +\n ')' +\n '(?:' +\n '(?:-|/|,' +\n ('dayOfWeek' === field ? '|#' : '') +\n ')' +\n '(?:' +\n number +\n ')' +\n ')?'\n if (field === 'dayOfWeek') range += '(?:L)?'\n if (field === 'month') range += '(?:L|W)?'\n regexByField[field] = '\\\\?|\\\\*|' + range + '(?:,' + range + ')*'\n })\n\n var monthValues = 'JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC'\n var monthRange = '(?:' + monthValues + ')(?:(?:-)(?:' + monthValues + '))?'\n regexByField['month'] += '|\\\\?|\\\\*|' + monthRange + '(?:,' + monthRange + ')*'\n\n var dayOfWeekValues = 'MON|TUE|WED|THU|FRI|SAT|SUN'\n var dayOfWeekRange = '(?:' + dayOfWeekValues + ')(?:(?:-)(?:' + dayOfWeekValues + '))?'\n regexByField['dayOfWeek'] += '|\\\\?|\\\\*|' + dayOfWeekRange + '(?:,' + dayOfWeekRange + ')*'\n\n if (!type)\n return (\n '^\\\\s*($' +\n '|#' +\n '|\\\\w+\\\\s*=' +\n '|' +\n '(' +\n regexByField['sec'] +\n ')\\\\s+' +\n '(' +\n regexByField['min'] +\n ')\\\\s+' +\n '(' +\n regexByField['hour'] +\n ')\\\\s+' +\n '(' +\n regexByField['day'] +\n ')\\\\s+' +\n '(' +\n regexByField['month'] +\n ')\\\\s+' +\n '(' +\n regexByField['dayOfWeek'] +\n ')(|\\\\s)+' +\n ')$'\n )\n else return `^${regexByField[type]}$`\n}\n\n@customElement('ox-input-crontab')\nexport class OxInputCrontab extends OxFormField {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n border: 0;\n }\n\n :host * {\n box-sizing: border-box;\n }\n :host *:focus {\n outline: none;\n }\n\n form {\n display: grid;\n width: 100%;\n height: 100%;\n padding: 1rem;\n grid-template: auto auto 1fr auto / repeat(6, 1fr);\n grid-gap: 0.5rem;\n justify-content: center;\n align-items: center;\n overflow: auto;\n }\n\n label[for='example'] {\n text-align: right;\n grid-column: 3;\n font: normal 1em var(--theme-font);\n color: var(--secondary-color);\n text-transform: capitalize;\n }\n\n #example {\n grid-column: 4 / span 3;\n width: 100%;\n height: 100%;\n padding: var(--input-padding);\n border: 0;\n border-bottom: var(--border-dark-color);\n text-transform: capitalize;\n font: var(--label-font);\n color: var(--label-color);\n }\n\n input {\n width: 100%;\n margin-top: var(--margin-default);\n padding: 5px;\n border: 0;\n border-bottom: var(--border-dark-color);\n padding: var(--input-padding);\n font: var(--input-font);\n color: var(--primary-text-color);\n }\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n\n input:invalid {\n border-bottom: 1px solid var(--status-danger-color);\n color: var(--status-danger-color);\n }\n\n label {\n width: 100%;\n font: normal 0.8em var(--theme-font);\n color: var(--primary-color);\n }\n\n label:not([for='example']) {\n text-align: center;\n }\n\n #input-wrapper {\n grid-column: span 6;\n display: flex;\n flex-wrap: wrap;\n margin: 0 -0.25rem;\n }\n\n #input-wrapper > div {\n flex: 1;\n display: grid;\n grid-template-rows: 1fr auto;\n grid-gap: 0.5rem;\n min-width: 60px;\n max-width: 33%;\n margin: 0.25rem;\n }\n\n #tooltip {\n grid-column: span 6;\n display: grid;\n grid-template-columns: auto 1fr;\n grid-gap: 0;\n margin: auto;\n grid-auto-rows: min-content;\n align-self: center;\n align-items: center;\n }\n\n #tooltip > div {\n padding: 0.25rem 0.5rem;\n border-bottom: #ccc 1px dashed;\n font: normal 0.9em var(--theme-font);\n }\n\n #tooltip > .crontab-value {\n text-align: right;\n color: var(--secondary-color);\n }\n\n #tooltip > .crontab-description {\n text-align: left;\n color: #585858;\n }\n\n #button-wrapper {\n grid-column: 1 / span 6;\n display: flex;\n flex-wrap: wrap-reverse;\n flex-direction: row-reverse;\n margin: -0.25rem;\n }\n\n mwc-button {\n background-color: var(--secondary-color);\n border-radius: var(--button-border-radius);\n --mdc-theme-primary: #fff;\n margin: 0.25rem;\n }\n mwc-button:hover,\n mwc-button:active {\n background-color: var(--primary-color);\n }\n `\n\n @property({ type: String }) value?: string\n @property({ type: String }) second?: string\n @property({ type: String }) minute?: string\n @property({ type: String }) hour?: string\n @property({ type: String }) dayOfMonth?: string\n @property({ type: String }) month?: string\n @property({ type: String }) dayOfWeek?: string\n\n @state() tooltip: { value: string; description: string }[] = []\n\n render() {\n return html`\n <form>\n <label for=\"example\">${i18next.t('label.examples')}</label>\n <select\n id=\"example\"\n @change=${(e: Event) => (this.value = (e.currentTarget as HTMLInputElement).value)}\n .value=${this.value}\n >\n <optgroup label=\"${i18next.t('label.second by second')}\">\n <option value=\"* * * * * *\">${i18next.t('text.every second')}</option>\n <option value=\"0/2 * * * * *\">${i18next.t('text.every 2 seconds')}</option>\n <option value=\"0/15 * * * * *\">${i18next.t('text.every 15 seconds')}</option>\n <option value=\"0/30 * * * * *\">${i18next.t('text.every 30 seconds')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.minute by minute')}\">\n <option value=\"0 * * * * *\">${i18next.t('text.every minute')}</option>\n <option value=\"0 0/2 * * * *\">${i18next.t('text.every 2 minutes')}</option>\n <option value=\"0 0/15 * * * *\">${i18next.t('text.every 15 minutes')}</option>\n <option value=\"0 0/30 * * * *\">${i18next.t('text.every half hour')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.hourly')}\">\n <option value=\"0 0 * * * *\">${i18next.t('text.every hour')}</option>\n <option value=\"0 0 0/2 * * *\">${i18next.t('text.every 2 hours')}</option>\n <option value=\"0 0 0/12 * * *\">${i18next.t('text.every 12 hours')}</option>\n <option value=\"0 0 10-19 * * *\">${i18next.t('text.every hour during working time')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.daily')}\">\n <option value=\"0 0 0 * * *\">${i18next.t('text.every day')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.weekly')}\">\n <option value=\"0 0 0 * * SUN\">${i18next.t('text.every sunday')}</option>\n <option value=\"0 0 0 * * 0\">${i18next.t('text.every sunday(2)')}</option>\n <option value=\"0 0 0 * * 1-5\">${i18next.t('text.every weekday')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.monthly')}\">\n <option value=\"0 0 0 1 * *\">${i18next.t('text.the first day of every month')}</option>\n <option value=\"0 0 10 21 * *\">${i18next.t('text.10 am on every payday')}</option>\n </optgroup>\n <optgroup label=\"${i18next.t('label.yearly')}\">\n <option value=\"0 0 0 1 1 *\">${i18next.t('text.the first day of every year')}</option>\n <option value=\"0 0 0 25 12 *\">${i18next.t('text.every christmas')}</option>\n </optgroup>\n </select>\n <div id=\"input-wrapper\">\n <div>\n <input\n id=\"second-input\"\n class=\"second\"\n type=\"text\"\n .value=${this.second || ''}\n @input=${(e: Event) => (this.second = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('second')\n }}\n pattern=${createCronRegex('sec')}\n required\n />\n <label for=\"second-input\" class=\"second\">${i18next.t('label.second')}</label>\n </div>\n <div>\n <input\n id=\"minute-input\"\n class=\"minute\"\n type=\"text\"\n .value=${this.minute || ''}\n @input=${(e: Event) => (this.minute = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('minute')\n }}\n pattern=${createCronRegex('min')}\n required\n />\n <label for=\"minute-input\" class=\"minute\">${i18next.t('label.minute')}</label>\n </div>\n <div>\n <input\n id=\"hour-input\"\n class=\"hour\"\n type=\"text\"\n .value=${this.hour || ''}\n @input=${(e: Event) => (this.hour = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('hour')\n }}\n pattern=${createCronRegex('hour')}\n required\n />\n <label for=\"hour-input\" class=\"hour\">${i18next.t('label.hour')}</label>\n </div>\n <div>\n <input\n id=\"day-of-month-input\"\n class=\"day-of-month\"\n type=\"text\"\n .value=${this.dayOfMonth || ''}\n @input=${(e: Event) => (this.dayOfMonth = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('dayOfMonth')\n }}\n pattern=${createCronRegex('day')}\n required\n />\n <label for=\"day-of-month-input\" class=\"day-of-month\">${i18next.t('label.day-of-month')}</label>\n </div>\n <div>\n <input\n id=\"month-input\"\n class=\"month\"\n type=\"text\"\n .value=${this.month || ''}\n @input=${(e: Event) => (this.month = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('month')\n }}\n pattern=${createCronRegex('month')}\n required\n />\n <label for=\"month-input\" class=\"month\">${i18next.t('label.month')}</label>\n </div>\n <div>\n <input\n id=\"day-of-week-input\"\n class=\"day-of-week\"\n type=\"text\"\n .value=${this.dayOfWeek || ''}\n @input=${(e: Event) => (this.dayOfWeek = (e.currentTarget as HTMLInputElement).value)}\n @focus=${(e: Event) => {\n this.showTooltip('dayOfWeek')\n }}\n pattern=${createCronRegex('dayOfWeek')}\n required\n />\n <label for=\"day-of-week-input\" class=\"day-of-week\">${i18next.t('label.day-of-week')}</label>\n </div>\n </div>\n <div id=\"tooltip\">\n ${this.tooltip.map(\n tip => html`\n <div class=\"crontab-value\">${tip.value}</div>\n <div class=\"crontab-description\">${i18next.t(`text.${tip.description}`)}</div>\n `\n )}\n </div>\n </form>\n `\n }\n\n get focusableElements(): HTMLElement[] {\n return Array.from(this.renderRoot.querySelectorAll('select, input, mwc-button'))\n }\n\n firstUpdated() {\n ;(this.renderRoot.querySelector('input') as HTMLInputElement).focus()\n this.renderRoot.addEventListener('change', this.onChange.bind(this))\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n var values = (this.value || '').split(' ')\n\n if (values.length == 1) values = ['*', '*', '*', '*', '*', '*']\n else if (values.length == 5) values = ['0'].concat(values)\n\n this.second = values[0]\n this.minute = values[1]\n this.hour = values[2]\n this.dayOfMonth = values[3]\n this.month = values[4]\n this.dayOfWeek = values[5]\n }\n }\n\n showTooltip(type: 'second' | 'minute' | 'hour' | 'dayOfMonth' | 'month' | 'dayOfWeek') {\n switch (type) {\n case 'second':\n case 'minute':\n this.tooltip = [\n {\n value: '*',\n description: 'any value'\n },\n {\n value: ',',\n description: 'value list separator'\n },\n {\n value: '-',\n description: 'range of values'\n },\n {\n value: '/',\n description: 'step values'\n },\n {\n value: '0-59',\n description: 'allowed values'\n }\n ]\n break\n case 'hour':\n this.tooltip = [\n {\n value: '*',\n description: 'any value'\n },\n {\n value: ',',\n description: 'value list separator'\n },\n {\n value: '-',\n description: 'range of values'\n },\n {\n value: '/',\n description: 'step values'\n },\n {\n value: '0-23',\n description: 'allowed values'\n }\n ]\n break\n\n case 'dayOfMonth':\n this.tooltip = [\n {\n value: '*',\n description: 'any value'\n },\n {\n value: ',',\n description: 'value list separator'\n },\n {\n value: '-',\n description: 'range of values'\n },\n {\n value: '/',\n description: 'step values'\n },\n {\n value: '1-31',\n description: 'allowed values'\n }\n ]\n break\n\n case 'month':\n this.tooltip = [\n {\n value: '*',\n description: 'any value'\n },\n {\n value: ',',\n description: 'value list separator'\n },\n {\n value: '-',\n description: 'range of values'\n },\n {\n value: '/',\n description: 'step values'\n },\n {\n value: '1-12',\n description: 'allowed values'\n },\n {\n value: 'JAN-DEC',\n description: 'alternative single values'\n }\n ]\n break\n\n case 'dayOfWeek':\n this.tooltip = [\n {\n value: '*',\n description: 'any value'\n },\n {\n value: ',',\n description: 'value list separator'\n },\n {\n value: '-',\n description: 'range of values'\n },\n {\n value: '/',\n description: 'step values'\n },\n {\n value: '0-6',\n description: 'allowed values'\n },\n {\n value: 'SUN-SAT',\n description: 'alternative single values'\n }\n ]\n break\n\n default:\n this.tooltip = []\n break\n }\n }\n\n onChange() {\n var form = this.renderRoot.querySelector('form') as HTMLFormElement\n var valid = form.checkValidity()\n if (!valid) {\n form.reportValidity()\n return\n }\n\n this.value = `${this.second} ${this.minute} ${this.hour} ${this.dayOfMonth} ${this.month} ${this.dayOfWeek}`\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n}\n"]}
|
@@ -3,6 +3,7 @@
|
|
3
3
|
*/
|
4
4
|
import { __decorate } from "tslib";
|
5
5
|
import './ox-input-color.js';
|
6
|
+
import '@material/mwc-icon';
|
6
7
|
import { css, html } from 'lit';
|
7
8
|
import { customElement, property, query, queryAll } from 'lit/decorators.js';
|
8
9
|
import { OxFormField } from './ox-form-field.js';
|
@@ -26,29 +27,38 @@ let OxInputMultipleColors = class OxInputMultipleColors extends OxFormField {
|
|
26
27
|
:host {
|
27
28
|
display: inline-block;
|
28
29
|
}
|
29
|
-
|
30
30
|
#colors-container > div {
|
31
31
|
display: grid;
|
32
|
-
grid-template-columns:
|
33
|
-
grid-gap:
|
32
|
+
grid-template-columns: 34px 1fr 34px;
|
33
|
+
grid-gap: var(--margin-default);
|
34
34
|
align-items: center;
|
35
35
|
justify-content: left;
|
36
|
+
margin-bottom: var(--margin-narrow);
|
36
37
|
}
|
37
38
|
|
38
39
|
ox-input-color {
|
39
|
-
height: 25px;
|
40
40
|
width: 100%;
|
41
41
|
}
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
border:
|
47
|
-
|
48
|
-
padding
|
49
|
-
|
50
|
-
color:
|
51
|
-
|
43
|
+
button {
|
44
|
+
height: 100%;
|
45
|
+
border: var(--button-border);
|
46
|
+
border-radius: var(--border-radius);
|
47
|
+
background-color: var(--button-background-color);
|
48
|
+
padding: var(--padding-narrow) var(--padding-default);
|
49
|
+
line-height: 0.8;
|
50
|
+
color: var(--button-color);
|
51
|
+
cursor: pointer;
|
52
|
+
}
|
53
|
+
button mwc-icon {
|
54
|
+
font-size: var(--fontsize-default);
|
55
|
+
}
|
56
|
+
button:focus,
|
57
|
+
button:hover,
|
58
|
+
button:active {
|
59
|
+
border: var(--button-activ-border);
|
60
|
+
background-color: var(--button-background-focus-color);
|
61
|
+
color: var(--theme-white-color);
|
52
62
|
}
|
53
63
|
`; }
|
54
64
|
firstUpdated() {
|
@@ -59,18 +69,16 @@ let OxInputMultipleColors = class OxInputMultipleColors extends OxFormField {
|
|
59
69
|
<div id="colors-container">
|
60
70
|
${(this.value || []).map((item, index) => html `
|
61
71
|
<div>
|
62
|
-
<
|
63
|
-
|
72
|
+
<button @click=${() => this._appendEditorColor()} data-index=${index}>
|
73
|
+
<mwc-icon>add</mwc-icon>
|
74
|
+
</button>
|
64
75
|
<ox-input-color .value=${item}> </ox-input-color>
|
65
76
|
|
66
77
|
${(this.value || []).length > 1
|
67
78
|
? html `
|
68
|
-
<
|
69
|
-
|
70
|
-
|
71
|
-
@click=${(e) => this._removeEditorColor(e)}
|
72
|
-
data-index=${index}
|
73
|
-
/>
|
79
|
+
<button @click=${(e) => this._removeEditorColor(e)} data-index=${index}>
|
80
|
+
<mwc-icon>remove</mwc-icon>
|
81
|
+
</button>
|
74
82
|
`
|
75
83
|
: html ``}
|
76
84
|
</div>
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-multiple-colors.js","sourceRoot":"","sources":["../../src/ox-input-multiple-colors.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,qBAAqB,CAAA;
|
1
|
+
{"version":3,"file":"ox-input-multiple-colors.js","sourceRoot":"","sources":["../../src/ox-input-multiple-colors.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,qBAAqB,CAAA;AAC5B,OAAO,oBAAo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AC,KAAM,CAAC,CAAA;IACjE,CAAC;IAED,kBAAkB;QAChB,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAErC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;IAED,kBAAkB,CAAC,CAAQ;QACzB,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1C,IAAI,CAAC,IAAI,MAAM,CAAE,CAAC,CAAC,MAAsB,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,SAAQ;;gBAC7D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;SAChC;QAED,IAAI,CAAC,KAAK,GAAG,MAAM,CAAA;QACnB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;CACF,CAAA;AAtD4B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;oDAAqB;AAEnB;IAA3B,KAAK,CAAC,mBAAmB,CAAC;8DAAiC;AAChC;IAA3B,QAAQ,CAAC,gBAAgB,CAAC;qDAAkC;AA3ClD,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CA8FjC;SA9FY,qBAAqB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-input-color.js'\nimport '@material/mwc-icon'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query, queryAll } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field.js'\nimport { OxInputColor } from './ox-input-color.js'\n\n/**\n색상 배열을 편집하는 컴포넌트이다.\n\n새로운 색상을 추가하고자 할 때는 `+` 버튼을 클릭한다.<br />\n색상을 제거하고자 할 때는 `-` 버튼을 클릭한다.<br />\n\nExample:\n\n <ox-input-multiple-colors values=${values}>\n </ox-input-multiple-colors>\n*/\n\n@customElement('ox-input-multiple-colors')\nexport class OxInputMultipleColors extends OxFormField {\n static styles = css`\n :host {\n display: inline-block;\n }\n #colors-container > div {\n display: grid;\n grid-template-columns: 34px 1fr 34px;\n grid-gap: var(--margin-default);\n align-items: center;\n justify-content: left;\n margin-bottom: var(--margin-narrow);\n }\n\n ox-input-color {\n width: 100%;\n }\n\n button {\n height: 100%;\n border: var(--button-border);\n border-radius: var(--border-radius);\n background-color: var(--button-background-color);\n padding: var(--padding-narrow) var(--padding-default);\n line-height: 0.8;\n color: var(--button-color);\n cursor: pointer;\n }\n button mwc-icon {\n font-size: var(--fontsize-default);\n }\n button:focus,\n button:hover,\n button:active {\n border: var(--button-activ-border);\n background-color: var(--button-background-focus-color);\n color: var(--theme-white-color);\n }\n `\n\n @property({ type: Array }) value: string[] = []\n\n @query('#colors-container') colorsContainer!: HTMLDivElement\n @queryAll('ox-input-color') colors!: NodeListOf<OxInputColor>\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onValueChanged.bind(this))\n }\n\n render() {\n return html`\n <div id=\"colors-container\">\n ${(this.value || []).map(\n (item, index) => html`\n <div>\n <button @click=${() => this._appendEditorColor()} data-index=${index}>\n <mwc-icon>add</mwc-icon>\n </button>\n <ox-input-color .value=${item}> </ox-input-color>\n\n ${(this.value || []).length > 1\n ? html`\n <button @click=${(e: Event) => this._removeEditorColor(e)} data-index=${index}>\n <mwc-icon>remove</mwc-icon>\n </button>\n `\n : html``}\n </div>\n `\n )}\n </div>\n `\n }\n\n _onValueChanged() {\n this.value = Array.from(this.colors).map(color => color.value!)\n }\n\n _appendEditorColor() {\n this.value = [...this.value, 'black']\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n _removeEditorColor(e: Event) {\n var values = []\n for (var i = 0; i < this.value.length; i++) {\n if (i == Number((e.target as HTMLElement).dataset.index)) continue\n else values.push(this.value[i])\n }\n\n this.value = values\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
|
@@ -1,7 +1,8 @@
|
|
1
|
+
import { __decorate } from "tslib";
|
1
2
|
/**
|
2
3
|
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
4
|
*/
|
4
|
-
import
|
5
|
+
import '@material/mwc-icon';
|
5
6
|
import { css, html } from 'lit';
|
6
7
|
import { customElement, property } from 'lit/decorators.js';
|
7
8
|
import { OxFormField } from './ox-form-field';
|
@@ -12,23 +13,58 @@ let OxInputOptions = class OxInputOptions extends OxFormField {
|
|
12
13
|
this._changingNow = false;
|
13
14
|
}
|
14
15
|
static { this.styles = css `
|
15
|
-
|
16
|
-
display:
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
:host {
|
17
|
+
display: flex;
|
18
|
+
flex-direction: column;
|
19
|
+
overflow: hidden;
|
20
|
+
margin-bottom: var(--margin-wide);
|
20
21
|
}
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
div {
|
24
|
+
display: flex;
|
25
|
+
flex-flow: row nowrap;
|
26
|
+
gap: var(--margin-default);
|
27
|
+
margin-bottom: var(--margin-narrow);
|
24
28
|
}
|
25
29
|
|
26
|
-
|
27
|
-
|
30
|
+
button {
|
31
|
+
border: var(--button-border);
|
32
|
+
border-radius: var(--border-radius);
|
33
|
+
background-color: var(--button-background-color);
|
34
|
+
padding: var(--padding-narrow) var(--padding-default);
|
35
|
+
line-height: 0.8;
|
36
|
+
color: var(--button-color);
|
37
|
+
cursor: pointer;
|
38
|
+
}
|
39
|
+
button + button {
|
40
|
+
margin-left: -5px;
|
41
|
+
}
|
42
|
+
button mwc-icon {
|
43
|
+
font-size: var(--fontsize-default);
|
44
|
+
}
|
45
|
+
button:focus,
|
46
|
+
button:hover,
|
47
|
+
button:active {
|
48
|
+
border: var(--button-activ-border);
|
49
|
+
background-color: var(--button-background-focus-color);
|
50
|
+
color: var(--theme-white-color);
|
28
51
|
}
|
29
52
|
|
30
|
-
|
31
|
-
|
53
|
+
input {
|
54
|
+
flex: 1;
|
55
|
+
border: 0;
|
56
|
+
border-bottom: var(--border-dark-color);
|
57
|
+
padding: var(--input-padding);
|
58
|
+
font: var(--input-font);
|
59
|
+
color: var(--primary-text-color);
|
60
|
+
}
|
61
|
+
input:focus {
|
62
|
+
outline: none;
|
63
|
+
border-bottom: 1px solid var(--primary-color);
|
64
|
+
}
|
65
|
+
button.hidden {
|
66
|
+
opacity: 0;
|
67
|
+
cursor: default;
|
32
68
|
}
|
33
69
|
`; }
|
34
70
|
firstUpdated() {
|
@@ -41,14 +77,18 @@ let OxInputOptions = class OxInputOptions extends OxFormField {
|
|
41
77
|
<div data-record="">
|
42
78
|
<input type="text" data-text="" placeholder="text" .value=${item.text} />
|
43
79
|
<input type="text" data-value="" placeholder="value" .value=${item.value} />
|
44
|
-
<button class="record-action" @click=${(e) => this._delete(e)} tabindex="-1"
|
80
|
+
<button class="record-action" @click=${(e) => this._delete(e)} tabindex="-1">
|
81
|
+
<mwc-icon>remove</mwc-icon>
|
82
|
+
</button>
|
45
83
|
</div>
|
46
84
|
`)}
|
47
85
|
|
48
86
|
<div data-record-new="">
|
49
87
|
<input type="text" data-text="" placeholder="text" value="" />
|
50
88
|
<input type="text" data-value="" placeholder="value" value="" @change=${(e) => this._add()} />
|
51
|
-
<button class="record-action" @click=${(e) => this._add()} tabindex="-1"
|
89
|
+
<button class="record-action" @click=${(e) => this._add()} tabindex="-1">
|
90
|
+
<mwc-icon>add</mwc-icon>
|
91
|
+
</button>
|
52
92
|
</div>
|
53
93
|
`;
|
54
94
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-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AAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAwJ1B;SAxJY,cAAc","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\n\ntype Option = { text: string; value: string }\n\n@customElement('ox-input-options')\nexport class OxInputOptions extends OxFormField {\n static styles = css`\n div {\n display: grid;\n grid-template-columns: repeat(10, 1fr);\n grid-gap: 5px;\n grid-auto-rows: minmax(24px, auto);\n }\n\n input[data-text] {\n grid-column: span 5;\n }\n\n input[data-value] {\n grid-column: span 4;\n }\n\n button {\n grid-column: span 1;\n }\n `\n\n @property({ type: Array }) value: Option[] = []\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const options = this.value instanceof Array ? this.value : []\n\n return html`\n ${(options || []).map(\n item => html`\n <div data-record=\"\">\n <input type=\"text\" data-text=\"\" placeholder=\"text\" .value=${item.text} />\n <input type=\"text\" data-value=\"\" placeholder=\"value\" .value=${item.value} />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._delete(e)} tabindex=\"-1\">-</button>\n </div>\n `\n )}\n\n <div data-record-new=\"\">\n <input type=\"text\" data-text=\"\" placeholder=\"text\" value=\"\" />\n <input type=\"text\" data-value=\"\" placeholder=\"value\" value=\"\" @change=${(e: Event) => this._add()} />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">+</button>\n </div>\n `\n }\n\n private _changingNow: boolean = false\n\n _onChange(e: Event) {\n if (this._changingNow) return\n\n this._changingNow = true\n\n var input = e.target as HTMLInputElement\n var value = input.value\n\n var div = input.parentElement\n\n if (div && div.hasAttribute('data-record')) {\n var dataList = div.querySelectorAll('[data-value]:not([hidden])') as NodeListOf<HTMLInputElement>\n\n for (var i = 0; i < dataList.length; i++) {\n if (dataList[i] !== input) {\n dataList[i].value = value || ''\n }\n }\n }\n\n if (div && div.hasAttribute('data-record')) this._build(true)\n else if (div && div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) this._add()\n\n e.stopPropagation()\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: any) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newoptions: Option[] = []\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n var text = (record.querySelector('[data-text]') as HTMLInputElement).value\n var inputs = record.querySelectorAll('[data-value]:not([style*=\"display: none\"])') as NodeListOf<HTMLInputElement>\n if (!inputs || inputs.length == 0) continue\n\n var input = inputs[inputs.length - 1]\n var value = input.value\n\n if (text) newoptions.push({ text: text, value: value || text })\n }\n\n this.value = newoptions\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n sort() {\n var sorter = function (a: Option, b: Option) {\n return b.text < a.text ? 1 : -1\n }\n\n this.value = [...this.value.sort(sorter)]\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n _add() {\n this._build(true)\n\n var inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: Event) {\n const record = (e.target as HTMLElement).parentElement\n const input = record && (record.querySelector('[data-text]') as HTMLInputElement)\n\n if (input) {\n input.value = ''\n }\n\n this._build()\n }\n\n protected appendFormData({ formData }: FormDataEvent): void {\n if (!this.name) return\n\n const value = this.value\n\n formData.append(\n this.name!,\n typeof value === 'string' ? value : value === undefined || value === null ? '' : JSON.stringify(value)\n )\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ox-input-options.js","sourceRoot":"","sources":["../../src/ox-input-options.ts"],"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6CAAqB;AAzDpC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA+L1B;SA/LY,cAAc","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\nimport '@material/mwc-icon'\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\n\ntype Option = { text: string; value: string }\n\n@customElement('ox-input-options')\nexport class OxInputOptions extends OxFormField {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n margin-bottom: var(--margin-wide);\n }\n\n div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--margin-default);\n margin-bottom: var(--margin-narrow);\n }\n\n button {\n border: var(--button-border);\n border-radius: var(--border-radius);\n background-color: var(--button-background-color);\n padding: var(--padding-narrow) var(--padding-default);\n line-height: 0.8;\n color: var(--button-color);\n cursor: pointer;\n }\n button + button {\n margin-left: -5px;\n }\n button mwc-icon {\n font-size: var(--fontsize-default);\n }\n button:focus,\n button:hover,\n button:active {\n border: var(--button-activ-border);\n background-color: var(--button-background-focus-color);\n color: var(--theme-white-color);\n }\n\n input {\n flex: 1;\n border: 0;\n border-bottom: var(--border-dark-color);\n padding: var(--input-padding);\n font: var(--input-font);\n color: var(--primary-text-color);\n }\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n button.hidden {\n opacity: 0;\n cursor: default;\n }\n `\n\n @property({ type: Array }) value: Option[] = []\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const options = this.value instanceof Array ? this.value : []\n\n return html`\n ${(options || []).map(\n item => html`\n <div data-record=\"\">\n <input type=\"text\" data-text=\"\" placeholder=\"text\" .value=${item.text} />\n <input type=\"text\" data-value=\"\" placeholder=\"value\" .value=${item.value} />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._delete(e)} tabindex=\"-1\">\n <mwc-icon>remove</mwc-icon>\n </button>\n </div>\n `\n )}\n\n <div data-record-new=\"\">\n <input type=\"text\" data-text=\"\" placeholder=\"text\" value=\"\" />\n <input type=\"text\" data-value=\"\" placeholder=\"value\" value=\"\" @change=${(e: Event) => this._add()} />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">\n <mwc-icon>add</mwc-icon>\n </button>\n </div>\n `\n }\n\n private _changingNow: boolean = false\n\n _onChange(e: Event) {\n if (this._changingNow) return\n\n this._changingNow = true\n\n var input = e.target as HTMLInputElement\n var value = input.value\n\n var div = input.parentElement\n\n if (div && div.hasAttribute('data-record')) {\n var dataList = div.querySelectorAll('[data-value]:not([hidden])') as NodeListOf<HTMLInputElement>\n\n for (var i = 0; i < dataList.length; i++) {\n if (dataList[i] !== input) {\n dataList[i].value = value || ''\n }\n }\n }\n\n if (div && div.hasAttribute('data-record')) this._build(true)\n else if (div && div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) this._add()\n\n e.stopPropagation()\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: any) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newoptions: Option[] = []\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n var text = (record.querySelector('[data-text]') as HTMLInputElement).value\n var inputs = record.querySelectorAll('[data-value]:not([style*=\"display: none\"])') as NodeListOf<HTMLInputElement>\n if (!inputs || inputs.length == 0) continue\n\n var input = inputs[inputs.length - 1]\n var value = input.value\n\n if (text) newoptions.push({ text: text, value: value || text })\n }\n\n this.value = newoptions\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n sort() {\n var sorter = function (a: Option, b: Option) {\n return b.text < a.text ? 1 : -1\n }\n\n this.value = [...this.value.sort(sorter)]\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n _add() {\n this._build(true)\n\n var inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: Event) {\n const record = (e.target as HTMLElement).parentElement\n const input = record && (record.querySelector('[data-text]') as HTMLInputElement)\n\n if (input) {\n input.value = ''\n }\n\n this._build()\n }\n\n protected appendFormData({ formData }: FormDataEvent): void {\n if (!this.name) return\n\n const value = this.value\n\n formData.append(\n this.name!,\n typeof value === 'string' ? value : value === undefined || value === null ? '' : JSON.stringify(value)\n )\n }\n}\n"]}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
3
|
*/
|
4
4
|
import { __decorate } from "tslib";
|
5
|
+
import '@material/mwc-icon';
|
5
6
|
import { css, html } from 'lit';
|
6
7
|
import { customElement, property, queryAll } from 'lit/decorators.js';
|
7
8
|
import { OxFormField } from './ox-form-field';
|
@@ -24,38 +25,55 @@ let OxInputPartitionKeys = class OxInputPartitionKeys extends OxFormField {
|
|
24
25
|
:host {
|
25
26
|
display: flex;
|
26
27
|
flex-direction: column;
|
27
|
-
align-content: center;
|
28
|
-
|
29
|
-
width: 100%;
|
30
28
|
overflow: hidden;
|
31
|
-
|
29
|
+
margin-bottom: var(--margin-wide);
|
32
30
|
}
|
33
31
|
|
34
32
|
div {
|
35
33
|
display: flex;
|
36
34
|
flex-flow: row nowrap;
|
37
|
-
|
38
|
-
|
39
|
-
border-bottom: 1px solid #c0c0c0;
|
40
|
-
}
|
41
|
-
|
42
|
-
div:last-child {
|
43
|
-
border-bottom: none;
|
44
|
-
}
|
45
|
-
|
46
|
-
div > * {
|
47
|
-
min-width: 0px;
|
48
|
-
margin: 2px;
|
49
|
-
padding: 0;
|
35
|
+
gap: var(--margin-default);
|
36
|
+
margin-bottom: var(--margin-narrow);
|
50
37
|
}
|
51
38
|
|
52
39
|
button {
|
53
|
-
|
54
|
-
|
40
|
+
border: var(--button-border);
|
41
|
+
border-radius: var(--border-radius);
|
42
|
+
background-color: var(--button-background-color);
|
43
|
+
padding: var(--padding-narrow) var(--padding-default);
|
44
|
+
line-height: 0.8;
|
45
|
+
color: var(--button-color);
|
46
|
+
cursor: pointer;
|
47
|
+
}
|
48
|
+
button + button {
|
49
|
+
margin-left: -5px;
|
50
|
+
}
|
51
|
+
button mwc-icon {
|
52
|
+
font-size: var(--fontsize-default);
|
53
|
+
}
|
54
|
+
button:focus,
|
55
|
+
button:hover,
|
56
|
+
button:active {
|
57
|
+
border: var(--button-activ-border);
|
58
|
+
background-color: var(--button-background-focus-color);
|
59
|
+
color: var(--theme-white-color);
|
55
60
|
}
|
56
61
|
|
57
62
|
input {
|
58
63
|
flex: 1;
|
64
|
+
border: 0;
|
65
|
+
border-bottom: var(--border-dark-color);
|
66
|
+
padding: var(--input-padding);
|
67
|
+
font: var(--input-font);
|
68
|
+
color: var(--primary-text-color);
|
69
|
+
}
|
70
|
+
input:focus {
|
71
|
+
outline: none;
|
72
|
+
border-bottom: 1px solid var(--primary-color);
|
73
|
+
}
|
74
|
+
button.hidden {
|
75
|
+
opacity: 0;
|
76
|
+
cursor: default;
|
59
77
|
}
|
60
78
|
`; }
|
61
79
|
firstUpdated() {
|
@@ -68,16 +86,26 @@ let OxInputPartitionKeys = class OxInputPartitionKeys extends OxFormField {
|
|
68
86
|
<div data-record>
|
69
87
|
<input type="text" data-key placeholder="key" .value=${item.key} />
|
70
88
|
<input type="text" data-value placeholder="value" .value=${item.value} list="value-template" />
|
71
|
-
<button class="record-action" @click=${(e) => this._delete(e)} tabindex="-1"
|
72
|
-
|
73
|
-
|
89
|
+
<button class="record-action" @click=${(e) => this._delete(e)} tabindex="-1">
|
90
|
+
<mwc-icon>remove</mwc-icon>
|
91
|
+
</button>
|
92
|
+
<button class="record-action" @click=${(e) => this._up(e)} tabindex="-1">
|
93
|
+
<mwc-icon>arrow_upward</mwc-icon>
|
94
|
+
</button>
|
95
|
+
<button class="record-action" @click=${(e) => this._down(e)} tabindex="-1">
|
96
|
+
<mwc-icon>arrow_downward</mwc-icon>
|
97
|
+
</button>
|
74
98
|
</div>
|
75
99
|
`)}
|
76
100
|
|
77
101
|
<div data-record-new>
|
78
102
|
<input type="text" data-key placeholder="key" value="" />
|
79
103
|
<input type="text" data-value placeholder="value" value="" list="value-template" />
|
80
|
-
<button class="record-action" @click=${(e) => this._add()} tabindex="-1"
|
104
|
+
<button class="record-action" @click=${(e) => this._add()} tabindex="-1">
|
105
|
+
<mwc-icon>add</mwc-icon>
|
106
|
+
</button>
|
107
|
+
<button class="hidden"><mwc-icon>add</mwc-icon></button>
|
108
|
+
<button class="hidden"><mwc-icon>add</mwc-icon></button>
|
81
109
|
</div>
|
82
110
|
|
83
111
|
<datalist id="value-template">
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-partition-keys.js","sourceRoot":"","sources":["../../src/ox-input-partition-keys.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAK7C;;;;;;;;GAQG;AAEH,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,WAAW;IAArD;;QAwC8B,UAAK,GAAkB,EAAE,CAAA;QAE7C,iBAAY,GAAY,KAAK,CAAA;IAkLvC,CAAC;aA3NQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqClB,CAAA;IAMD,YAAY;QACV,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IA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,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACxC,MAAM,GAAG,GAAI,MAAM,CAAC,aAAa,CAAC,YAAY,CAAsB,CAAC,KAAK,CAAA;YAC1E,MAAM,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,cAAc,CAAsB,CAAC,KAAK,CAAA;YAE9E,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;YAChB,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAA+B,CAAC,CAAA;QAEnC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACtG,CAAC;CACF,CAAA;AApL6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAA0B;AAqI1B;IAA1B,QAAQ,CAAC,eAAe,CAAC;qDAAkC;AA7KjD,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CA4NhC;SA5NY,oBAAoB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html } from 'lit'\nimport { customElement, property, queryAll } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\n\ntype PartitionKeys = { [key: string]: any }\ntype ArrayedPartitionKeys = { key: string; value: any }\n\n/**\n key-value map for partitions editor element\n \n Example:\n \n <ox-input-partition-keys \n value=${map}\n </ox-input-partition-keys>\n */\n@customElement('ox-input-partition-keys')\nexport class OxInputPartitionKeys extends OxFormField {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n align-content: center;\n\n width: 100%;\n overflow: hidden;\n border: 1px solid #ccc;\n }\n\n div {\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n\n border-bottom: 1px solid #c0c0c0;\n }\n\n div:last-child {\n border-bottom: none;\n }\n\n div > * {\n min-width: 0px;\n margin: 2px;\n padding: 0;\n }\n\n button {\n width: 20px;\n text-align: center;\n }\n\n input {\n flex: 1;\n }\n `\n\n @property({ type: Object }) value: PartitionKeys = {}\n\n private _changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const value = !this.value || typeof this.value !== 'object' ? {} : this.value\n\n return html`\n ${this._toArray(value).map(\n item => html`\n <div data-record>\n <input type=\"text\" data-key placeholder=\"key\" .value=${item.key} />\n <input type=\"text\" data-value placeholder=\"value\" .value=${item.value} list=\"value-template\" />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._delete(e)} tabindex=\"-1\">-</button>\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._up(e)} tabindex=\"-1\">↑</button>\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._down(e)} tabindex=\"-1\">↓</button>\n </div>\n `\n )}\n\n <div data-record-new>\n <input type=\"text\" data-key placeholder=\"key\" value=\"\" />\n <input type=\"text\" data-value placeholder=\"value\" value=\"\" list=\"value-template\" />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">+</button>\n </div>\n\n <datalist id=\"value-template\">\n <option value=\"%YYYY\">year</option>\n <option value=\"%MM\">month</option>\n <option value=\"%DD\">day</option>\n <option value=\"%YYYYMMDD\">date</option>\n </datalist>\n `\n }\n\n _onChange(e: Event) {\n if (this._changingNow) {\n return\n }\n\n this._changingNow = true\n\n const input = e.target as HTMLInputElement\n var value = input.value\n\n const record = (e.target as Element).closest('[data-record],[data-record-new]') as HTMLElement\n\n if (record.hasAttribute('data-record')) {\n this._build()\n } else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newmap: PartitionKeys = {}\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const inputs = record.querySelectorAll(\n '[data-value]:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n if (!inputs || inputs.length == 0) {\n continue\n }\n\n var input = inputs[inputs.length - 1]\n\n var value = input.value\n\n if (key) {\n newmap[key] = value || ''\n }\n }\n\n this.value = newmap\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */\n _toArray(map: PartitionKeys) {\n var array: ArrayedPartitionKeys[] = []\n\n for (var key in map) {\n array.push({\n key: key,\n value: map[key]\n })\n }\n\n return array\n }\n\n _add() {\n this._build(true)\n\n const inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement & { value: any }>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n\n if (input.type == 'checkbox') input.checked = false\n else input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n\n ;(record!.querySelector('[data-key]') as HTMLInputElement)!.value = ''\n\n this._build()\n }\n\n @queryAll('[data-record]') records!: NodeListOf<HTMLElement>\n\n _up(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record) - 1\n\n if (index < 0) {\n return\n }\n\n const deleted = array.splice(index, 1)\n array.splice(index + 1, 0, ...deleted)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = value\n return sum\n }, {} as { [key: string]: string })\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n _down(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record)\n\n if (index > array.length) {\n return\n }\n\n array.splice(index, 1)\n array.splice(index + 1, 0, record)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = value\n return sum\n }, {} as { [key: string]: string })\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ox-input-partition-keys.js","sourceRoot":"","sources":["../../src/ox-input-partition-keys.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAK7C;;;;;;;;GAQG;AAEH,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,WAAW;IAArD;;QAyD8B,UAAK,GAAkB,EAAE,CAAA;QAE7C,iBAAY,GAAY,KAAK,CAAA;IA4LvC,CAAC;aAtPQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDlB,CAAA;IAMD,YAAY;QACV,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACvE,CAAC;IAED,MAAM;QACJ,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC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A;YAC1E,MAAM,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,cAAc,CAAsB,CAAC,KAAK,CAAA;YAE9E,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;YAChB,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAA+B,CAAC,CAAA;QAEnC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACtG,CAAC;CACF,CAAA;AA9L6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAA0B;AA+I1B;IAA1B,QAAQ,CAAC,eAAe,CAAC;qDAAkC;AAxMjD,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAuPhC;SAvPY,oBAAoB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/mwc-icon'\n\nimport { css, html } from 'lit'\nimport { customElement, property, queryAll } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\n\ntype PartitionKeys = { [key: string]: any }\ntype ArrayedPartitionKeys = { key: string; value: any }\n\n/**\n key-value map for partitions editor element\n \n Example:\n \n <ox-input-partition-keys \n value=${map}\n </ox-input-partition-keys>\n */\n@customElement('ox-input-partition-keys')\nexport class OxInputPartitionKeys extends OxFormField {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n margin-bottom: var(--margin-wide);\n }\n\n div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--margin-default);\n margin-bottom: var(--margin-narrow);\n }\n\n button {\n border: var(--button-border);\n border-radius: var(--border-radius);\n background-color: var(--button-background-color);\n padding: var(--padding-narrow) var(--padding-default);\n line-height: 0.8;\n color: var(--button-color);\n cursor: pointer;\n }\n button + button {\n margin-left: -5px;\n }\n button mwc-icon {\n font-size: var(--fontsize-default);\n }\n button:focus,\n button:hover,\n button:active {\n border: var(--button-activ-border);\n background-color: var(--button-background-focus-color);\n color: var(--theme-white-color);\n }\n\n input {\n flex: 1;\n border: 0;\n border-bottom: var(--border-dark-color);\n padding: var(--input-padding);\n font: var(--input-font);\n color: var(--primary-text-color);\n }\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n button.hidden {\n opacity: 0;\n cursor: default;\n }\n `\n\n @property({ type: Object }) value: PartitionKeys = {}\n\n private _changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const value = !this.value || typeof this.value !== 'object' ? {} : this.value\n\n return html`\n ${this._toArray(value).map(\n item => html`\n <div data-record>\n <input type=\"text\" data-key placeholder=\"key\" .value=${item.key} />\n <input type=\"text\" data-value placeholder=\"value\" .value=${item.value} list=\"value-template\" />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._delete(e)} tabindex=\"-1\">\n <mwc-icon>remove</mwc-icon>\n </button>\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._up(e)} tabindex=\"-1\">\n <mwc-icon>arrow_upward</mwc-icon>\n </button>\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._down(e)} tabindex=\"-1\">\n <mwc-icon>arrow_downward</mwc-icon>\n </button>\n </div>\n `\n )}\n\n <div data-record-new>\n <input type=\"text\" data-key placeholder=\"key\" value=\"\" />\n <input type=\"text\" data-value placeholder=\"value\" value=\"\" list=\"value-template\" />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">\n <mwc-icon>add</mwc-icon>\n </button>\n <button class=\"hidden\"><mwc-icon>add</mwc-icon></button>\n <button class=\"hidden\"><mwc-icon>add</mwc-icon></button>\n </div>\n\n <datalist id=\"value-template\">\n <option value=\"%YYYY\">year</option>\n <option value=\"%MM\">month</option>\n <option value=\"%DD\">day</option>\n <option value=\"%YYYYMMDD\">date</option>\n </datalist>\n `\n }\n\n _onChange(e: Event) {\n if (this._changingNow) {\n return\n }\n\n this._changingNow = true\n\n const input = e.target as HTMLInputElement\n var value = input.value\n\n const record = (e.target as Element).closest('[data-record],[data-record-new]') as HTMLElement\n\n if (record.hasAttribute('data-record')) {\n this._build()\n } else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newmap: PartitionKeys = {}\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const inputs = record.querySelectorAll(\n '[data-value]:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n if (!inputs || inputs.length == 0) {\n continue\n }\n\n var input = inputs[inputs.length - 1]\n\n var value = input.value\n\n if (key) {\n newmap[key] = value || ''\n }\n }\n\n this.value = newmap\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */\n _toArray(map: PartitionKeys) {\n var array: ArrayedPartitionKeys[] = []\n\n for (var key in map) {\n array.push({\n key: key,\n value: map[key]\n })\n }\n\n return array\n }\n\n _add() {\n this._build(true)\n\n const inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement & { value: any }>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n\n if (input.type == 'checkbox') input.checked = false\n else input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n\n ;(record!.querySelector('[data-key]') as HTMLInputElement)!.value = ''\n\n this._build()\n }\n\n @queryAll('[data-record]') records!: NodeListOf<HTMLElement>\n\n _up(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record) - 1\n\n if (index < 0) {\n return\n }\n\n const deleted = array.splice(index, 1)\n array.splice(index + 1, 0, ...deleted)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = value\n return sum\n }, {} as { [key: string]: string })\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n _down(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record)\n\n if (index > array.length) {\n return\n }\n\n array.splice(index, 1)\n array.splice(index + 1, 0, record)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = value\n return sum\n }, {} as { [key: string]: string })\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n}\n"]}
|