@aquera/nile-elements 0.0.5-9 → 0.0.6

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 (43) hide show
  1. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.d.ts +1 -0
  2. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js +1 -0
  3. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js.map +1 -1
  4. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/index.d.ts +1 -0
  5. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/index.js +2 -0
  6. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/index.js.map +1 -0
  7. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.d.ts +12 -0
  8. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +35 -0
  9. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js.map +1 -0
  10. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.d.ts +60 -0
  11. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +124 -0
  12. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -0
  13. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
  14. package/dist/index.cjs.js +1 -1
  15. package/dist/index.esm.js +1 -1
  16. package/dist/index.iife.js +57 -1
  17. package/dist/nile-switcher/index.cjs.js +2 -0
  18. package/dist/nile-switcher/index.cjs.js.map +1 -0
  19. package/dist/nile-switcher/index.esm.js +1 -0
  20. package/dist/nile-switcher/nile-switcher.cjs.js +2 -0
  21. package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -0
  22. package/dist/nile-switcher/nile-switcher.css.cjs.js +2 -0
  23. package/dist/nile-switcher/nile-switcher.css.cjs.js.map +1 -0
  24. package/dist/nile-switcher/nile-switcher.css.esm.js +23 -0
  25. package/dist/nile-switcher/nile-switcher.esm.js +30 -0
  26. package/dist/src/index.d.ts +1 -0
  27. package/dist/src/index.js +1 -0
  28. package/dist/src/index.js.map +1 -1
  29. package/dist/src/nile-switcher/index.d.ts +1 -0
  30. package/dist/src/nile-switcher/index.js +2 -0
  31. package/dist/src/nile-switcher/index.js.map +1 -0
  32. package/dist/src/nile-switcher/nile-switcher.css.d.ts +12 -0
  33. package/dist/src/nile-switcher/nile-switcher.css.js +35 -0
  34. package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -0
  35. package/dist/src/nile-switcher/nile-switcher.d.ts +60 -0
  36. package/dist/src/nile-switcher/nile-switcher.js +124 -0
  37. package/dist/src/nile-switcher/nile-switcher.js.map +1 -0
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +1 -1
  40. package/src/index.ts +2 -1
  41. package/src/nile-switcher/index.ts +1 -0
  42. package/src/nile-switcher/nile-switcher.css.ts +37 -0
  43. package/src/nile-switcher/nile-switcher.ts +185 -0
@@ -0,0 +1,30 @@
1
+ import{__decorate as e}from"tslib";import{x as t}from"../index-cd2f9c12.esm.js";import{customElement as i}from"lit/decorators.js";import{s as n}from"./nile-switcher.css.esm.js";import{N as l}from"../internal/nile-element.esm.js";import{choose as s}from"lit/directives/choose.js";import{classMap as r}from"lit/directives/class-map.js";import{n as o}from"../property-09139d3c.esm.js";import"lit";let c=class extends l{connectedCallback(){super.connectedCallback(),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}renderNileText(e){const{value:i,label:n,placeholder:l}=e;return t`<nile-input
2
+ .value=${i}
3
+ .label=${n}
4
+ .placeholder=${l}
5
+ @nile-input=${this.handleChange}
6
+ ></nile-input>`}renderNileTextArea(e){const{value:i}=e;return t`<nile-textarea
7
+ .value=${i}
8
+ @nile-input=${this.handleChange}
9
+ ></nile-textarea>`}renderNileCheckBox(e){const{value:i,label:n}=e;return t`<nile-checkbox
10
+ .checked=${i}
11
+ .label=${n}
12
+ @valueChange="${this.handleChangeCheckbox}"
13
+ ></nile-checkbox>`}handleChange(e){this.emit("nile-change",{value:e.detail.value})}handleChangeCheckbox(e){this.emit("nile-change",{value:e.detail.checked})}renderDropdown(e){const{options:i,multiple:n,placeholder:l}=e;return t`<nile-select
14
+ .placeholder=${l}
15
+ .multiple="${n}"
16
+ @nile-change="${this.handleChange}"
17
+ >
18
+ ${i&&i.map((e=>t`<nile-option .value="${e}">${e} </nile-option>`))}
19
+ </nile-select>`}renderIcon(){const e=this.nileSwitchConfig.toggleSwitch?"stringinput":"header-functions";return t`<nile-icon
20
+ size="14"
21
+ class=${r({"pointer-cursor":!0,"flex-start":"stringinput"===e})}
22
+ .name=${e}
23
+ color="#005EA6"
24
+ @click=${this.toggleField}
25
+ ></nile-icon>`}toggleField(){this.nileSwitchConfig={...this.nileSwitchConfig,toggleSwitch:!this.nileSwitchConfig.toggleSwitch}}singleFieldSwitcher(e,i,n){const l=e.inputType,r=i.inputType;return t`
26
+ ${n?s(r,[["text-area",()=>this.renderNileTextArea(i)]],(()=>this.renderNileTextArea(i))):s(l,[["text",()=>this.renderNileText(e)],["checkbox",()=>this.renderNileCheckBox(e)],["dropdown",()=>this.renderDropdown(this.nileSwitchConfig.defaultInput)]],(()=>this.renderNileText(e)))}
27
+ ${this.renderIcon()}
28
+ `}render(){const{toggleSwitch:e,defaultInput:i,switchInput:n}=this.nileSwitchConfig;return t`<div class="input-container">
29
+ ${this.singleFieldSwitcher(i,n,e)}
30
+ </div>`}};c.styles=n,e([o()],c.prototype,"nileSwitchConfig",void 0),c=e([i("nile-switcher")],c);export{c as N};
@@ -30,3 +30,4 @@ export { NileFormErrorMessage } from './nile-form-error-message';
30
30
  export { NileFormHelpText } from './nile-form-help-text';
31
31
  export { NileCalendar } from './nile-calendar';
32
32
  export { NileLink } from './nile-link';
33
+ export { NileSwitcher } from './nile-switcher';
package/dist/src/index.js CHANGED
@@ -30,4 +30,5 @@ export { NileFormErrorMessage } from './nile-form-error-message';
30
30
  export { NileFormHelpText } from './nile-form-help-text';
31
31
  export { NileCalendar } from './nile-calendar';
32
32
  export { NileLink } from './nile-link';
33
+ export { NileSwitcher } from './nile-switcher';
33
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC","sourcesContent":["export { NileButton } from './nile-button';\nexport { NileHeading } from './nile-heading';\nexport { NileIcon } from './nile-icon';\nexport { NileInput } from './nile-input';\nexport { NileSidebar } from './nile-sidebar';\nexport { NileMenu } from './nile-menu';\nexport { NileBadge } from './nile-badge';\nexport { NileDrawer } from './nile-drawer';\nexport { NileCheckbox } from './nile-checkbox';\nexport { NileRadio } from './nile-radio';\nexport { NileRadioGroup } from './nile-radio-group';\nexport { NilePopup } from './nile-popup';\nexport { NileTooltip } from './nile-tooltip';\nexport { NileSlideToggle } from './nile-slide-toggle';\nexport { NileLoader } from './nile-loader';\nexport { NileProgressBar } from './nile-progress-bar';\nexport { NileSpinner } from './nile-spinner';\nexport { NileSelect } from './nile-select';\nexport { NileOption } from './nile-option';\nexport { NileTag } from './nile-tag';\nexport { NileIconButton } from './nile-icon-button';\nexport { NileMenuItem } from './nile-menu-item';\nexport { NileDropdown } from './nile-dropdown';\nexport { NileAutoComplete } from './nile-auto-complete';\nexport { NileChip } from './nile-chip';\nexport { NileTextarea } from './nile-textarea';\nexport { NileDatePicker } from './nile-date-picker';\nexport { NileErrorMessage } from './nile-error-message';\nexport { NileFormErrorMessage } from './nile-form-error-message';\nexport { NileFormHelpText } from './nile-form-help-text';\nexport { NileCalendar } from './nile-calendar';\nexport { NileLink} from './nile-link';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { NileButton } from './nile-button';\nexport { NileHeading } from './nile-heading';\nexport { NileIcon } from './nile-icon';\nexport { NileInput } from './nile-input';\nexport { NileSidebar } from './nile-sidebar';\nexport { NileMenu } from './nile-menu';\nexport { NileBadge } from './nile-badge';\nexport { NileDrawer } from './nile-drawer';\nexport { NileCheckbox } from './nile-checkbox';\nexport { NileRadio } from './nile-radio';\nexport { NileRadioGroup } from './nile-radio-group';\nexport { NilePopup } from './nile-popup';\nexport { NileTooltip } from './nile-tooltip';\nexport { NileSlideToggle } from './nile-slide-toggle';\nexport { NileLoader } from './nile-loader';\nexport { NileProgressBar } from './nile-progress-bar';\nexport { NileSpinner } from './nile-spinner';\nexport { NileSelect } from './nile-select';\nexport { NileOption } from './nile-option';\nexport { NileTag } from './nile-tag';\nexport { NileIconButton } from './nile-icon-button';\nexport { NileMenuItem } from './nile-menu-item';\nexport { NileDropdown } from './nile-dropdown';\nexport { NileAutoComplete } from './nile-auto-complete';\nexport { NileChip } from './nile-chip';\nexport { NileTextarea } from './nile-textarea';\nexport { NileDatePicker } from './nile-date-picker';\nexport { NileErrorMessage } from './nile-error-message';\nexport { NileFormErrorMessage } from './nile-form-error-message';\nexport { NileFormHelpText } from './nile-form-help-text';\nexport { NileCalendar } from './nile-calendar';\nexport { NileLink } from './nile-link';\nexport { NileSwitcher } from './nile-switcher';\n"]}
@@ -0,0 +1 @@
1
+ export { NileSwitcher } from './nile-switcher';
@@ -0,0 +1,2 @@
1
+ export { NileSwitcher } from './nile-switcher';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nile-switcher/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { NileSwitcher } from './nile-switcher';\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * FieldGenerator CSS
9
+ */
10
+ export declare const styles: import("lit-element").CSSResult;
11
+ declare const _default: import("lit-element").CSSResult[];
12
+ export default _default;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { css } from 'lit-element';
8
+ /**
9
+ * FieldGenerator CSS
10
+ */
11
+ export const styles = css `
12
+ :host {
13
+ display: inline-block;
14
+ width: 100%;
15
+ box-sizing: border-box;
16
+ }
17
+
18
+ .pointer-cursor {
19
+ cursor: pointer;
20
+ }
21
+ .input-container {
22
+ display: flex;
23
+ }
24
+
25
+ .input-container > :first-child {
26
+ width: 100%;
27
+ padding-right: 12px;
28
+ }
29
+ .flex-start {
30
+ align-items: flex-start;
31
+ padding-top: 10px;
32
+ }
33
+ `;
34
+ export default [styles];
35
+ //# sourceMappingURL=nile-switcher.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-switcher.css.js","sourceRoot":"","sources":["../../../src/nile-switcher/nile-switcher.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;CAsBxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit-element';\n\n/**\n * FieldGenerator CSS\n */\nexport const styles = css`\n :host {\n display: inline-block;\n width: 100%;\n box-sizing: border-box;\n }\n\n .pointer-cursor {\n cursor: pointer;\n }\n .input-container {\n display: flex;\n }\n\n .input-container > :first-child {\n width: 100%;\n padding-right: 12px;\n }\n .flex-start {\n align-items: flex-start;\n padding-top: 10px;\n }\n`;\n\nexport default [styles];\n"]}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { TemplateResult } from 'lit-element';
8
+ import NileElement from '../internal/nile-element';
9
+ import { CSSResultGroup } from 'lit';
10
+ /**
11
+ * @summary Allows you to switch between nile elements
12
+
13
+ * @dependency nile-icon
14
+ * @dependency nile-input
15
+ * @dependency nile-checkbox
16
+ * @dependency nile-dropdown
17
+ * @dependency nile-textarea
18
+ *
19
+
20
+ * @event nile-change - Emitted when the control's value changes.
21
+ */
22
+ export interface switchconfig {
23
+ toggleSwitch: boolean;
24
+ defaultInput: switchInputType;
25
+ switchInput: switchInputType;
26
+ }
27
+ export interface switchInputType {
28
+ inputType: 'dropdown' | 'text' | 'checkbox' | 'text-area';
29
+ value?: String | boolean;
30
+ label?: String;
31
+ placeholder?: string;
32
+ options?: Array<any>;
33
+ multiple?: boolean;
34
+ }
35
+ export declare class NileSwitcher extends NileElement {
36
+ /**
37
+ * The styles for nile switcher
38
+ * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
39
+ */
40
+ static styles: CSSResultGroup;
41
+ nileSwitchConfig: switchconfig;
42
+ connectedCallback(): void;
43
+ disconnectedCallback(): void;
44
+ renderNileText(defaultInput: switchInputType): TemplateResult<1>;
45
+ renderNileTextArea(switchInput: switchInputType): TemplateResult<1>;
46
+ renderNileCheckBox(defaultInput: switchInputType): TemplateResult<1>;
47
+ handleChange(event: CustomEvent): void;
48
+ handleChangeCheckbox(event: CustomEvent): void;
49
+ renderDropdown(defaultInput: switchInputType): TemplateResult<1>;
50
+ renderIcon(): TemplateResult<1>;
51
+ toggleField(): void;
52
+ singleFieldSwitcher(defaultInput: switchInputType, switchInput: switchInputType, toggleField: boolean): TemplateResult<1>;
53
+ render(): TemplateResult;
54
+ }
55
+ export default NileSwitcher;
56
+ declare global {
57
+ interface HTMLElementTagNameMap {
58
+ 'nile-switcher': NileSwitcher;
59
+ }
60
+ }
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { __decorate } from "tslib";
8
+ import { html, property } from 'lit-element';
9
+ import { customElement } from 'lit/decorators.js';
10
+ import { styles } from './nile-switcher.css';
11
+ import NileElement from '../internal/nile-element';
12
+ import { choose } from 'lit/directives/choose.js';
13
+ import { classMap } from 'lit/directives/class-map.js';
14
+ let NileSwitcher = class NileSwitcher extends NileElement {
15
+ connectedCallback() {
16
+ super.connectedCallback();
17
+ this.emit('nile-init');
18
+ }
19
+ disconnectedCallback() {
20
+ super.disconnectedCallback();
21
+ this.emit('nile-destroy');
22
+ }
23
+ renderNileText(defaultInput) {
24
+ const { value, label, placeholder } = defaultInput;
25
+ return html `<nile-input
26
+ .value=${value}
27
+ .label=${label}
28
+ .placeholder=${placeholder}
29
+ @nile-input=${this.handleChange}
30
+ ></nile-input>`;
31
+ }
32
+ renderNileTextArea(switchInput) {
33
+ const { value } = switchInput;
34
+ return html `<nile-textarea
35
+ .value=${value}
36
+ @nile-input=${this.handleChange}
37
+ ></nile-textarea>`;
38
+ }
39
+ renderNileCheckBox(defaultInput) {
40
+ const { value, label } = defaultInput;
41
+ return html `<nile-checkbox
42
+ .checked=${value}
43
+ .label=${label}
44
+ @valueChange="${this.handleChangeCheckbox}"
45
+ ></nile-checkbox>`;
46
+ }
47
+ handleChange(event) {
48
+ this.emit('nile-change', { value: event.detail.value });
49
+ }
50
+ handleChangeCheckbox(event) {
51
+ this.emit('nile-change', { value: event.detail.checked });
52
+ }
53
+ renderDropdown(defaultInput) {
54
+ const { options, multiple, placeholder } = defaultInput;
55
+ return html `<nile-select
56
+ .placeholder=${placeholder}
57
+ .multiple="${multiple}"
58
+ @nile-change="${this.handleChange}"
59
+ >
60
+ ${options &&
61
+ options.map((option) => {
62
+ return html `<nile-option .value="${option}">${option} </nile-option>`;
63
+ })}
64
+ </nile-select>`;
65
+ }
66
+ renderIcon() {
67
+ const icon = !this.nileSwitchConfig.toggleSwitch
68
+ ? 'header-functions'
69
+ : 'stringinput';
70
+ return html `<nile-icon
71
+ size="14"
72
+ class=${classMap({
73
+ 'pointer-cursor': true,
74
+ 'flex-start': icon === 'stringinput',
75
+ })}
76
+ .name=${icon}
77
+ color="#005EA6"
78
+ @click=${this.toggleField}
79
+ ></nile-icon>`;
80
+ }
81
+ toggleField() {
82
+ this.nileSwitchConfig = {
83
+ ...this.nileSwitchConfig,
84
+ toggleSwitch: !this.nileSwitchConfig.toggleSwitch,
85
+ };
86
+ }
87
+ singleFieldSwitcher(defaultInput, switchInput, toggleField) {
88
+ const defaultInputType = defaultInput.inputType;
89
+ const switchInputType = switchInput.inputType;
90
+ return html `
91
+ ${!toggleField
92
+ ? choose(defaultInputType, [
93
+ ['text', () => this.renderNileText(defaultInput)],
94
+ ['checkbox', () => this.renderNileCheckBox(defaultInput)],
95
+ [
96
+ 'dropdown',
97
+ () => this.renderDropdown(this.nileSwitchConfig.defaultInput),
98
+ ],
99
+ ], () => this.renderNileText(defaultInput))
100
+ : choose(switchInputType, [['text-area', () => this.renderNileTextArea(switchInput)]], () => this.renderNileTextArea(switchInput))}
101
+ ${this.renderIcon()}
102
+ `;
103
+ }
104
+ render() {
105
+ const { toggleSwitch: toggleField, defaultInput, switchInput, } = this.nileSwitchConfig;
106
+ return html `<div class="input-container">
107
+ ${this.singleFieldSwitcher(defaultInput, switchInput, toggleField)}
108
+ </div>`;
109
+ }
110
+ };
111
+ /**
112
+ * The styles for nile switcher
113
+ * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
114
+ */
115
+ NileSwitcher.styles = styles;
116
+ __decorate([
117
+ property()
118
+ ], NileSwitcher.prototype, "nileSwitchConfig", void 0);
119
+ NileSwitcher = __decorate([
120
+ customElement('nile-switcher')
121
+ ], NileSwitcher);
122
+ export { NileSwitcher };
123
+ export default NileSwitcher;
124
+ //# sourceMappingURL=nile-switcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-switcher.js","sourceRoot":"","sources":["../../../src/nile-switcher/nile-switcher.ts"],"names":[],"mappings":"AAAA;;;;;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C,CAAC,MAAM,CACJ,gBAAgB,EAChB;gBACE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;gBACjD,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;gBACzD;oBACE,UAAU;oBACV,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC;iBAC9D;aACF,EACD,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CACxC;YACH,CAAC,CAAC,MAAM,CACJ,eAAe,EACf,CAAC,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,EAE3D,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAC3C;QACH,IAAI,CAAC,UAAU,EAAE;KACpB,CAAC;IACJ,CAAC;IACM,MAAM;QACX,MAAM,EACJ,YAAY,EAAE,WAAW,EACzB,YAAY,EACZ,WAAW,GACZ,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAE1B,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,mBAAmB,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,CAAC;WAC7D,CAAC;IACV,CAAC;;AAlID;;;GAGG;AACI,mBAAM,GAAmB,MAAM,CAAC;AAC3B;IAAX,QAAQ,EAAE;sDAAgC;AANhC,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAoIxB;SApIY,YAAY;AAsIzB,eAAe,YAAY,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, property, TemplateResult } from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport { styles } from './nile-switcher.css';\nimport NileElement from '../internal/nile-element';\nimport { CSSResultGroup } from 'lit';\nimport { choose } from 'lit/directives/choose.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\n/**\n * @summary Allows you to switch between nile elements\n\n * @dependency nile-icon\n * @dependency nile-input\n * @dependency nile-checkbox\n * @dependency nile-dropdown\n * @dependency nile-textarea\n *\n \n * @event nile-change - Emitted when the control's value changes.\n */\n\nexport interface switchconfig {\n toggleSwitch: boolean;\n defaultInput: switchInputType;\n switchInput: switchInputType;\n}\n\nexport interface switchInputType {\n inputType: 'dropdown' | 'text' | 'checkbox' | 'text-area';\n value?: String | boolean;\n label?: String;\n placeholder?: string;\n options?: Array<any>;\n multiple?: boolean;\n}\n\n@customElement('nile-switcher')\nexport class NileSwitcher extends NileElement {\n /**\n * The styles for nile switcher\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n static styles: CSSResultGroup = styles;\n @property() nileSwitchConfig: switchconfig;\n\n connectedCallback() {\n super.connectedCallback();\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n renderNileText(defaultInput: switchInputType) {\n const { value, label, placeholder } = defaultInput;\n return html`<nile-input\n .value=${value}\n .label=${label}\n .placeholder=${placeholder}\n @nile-input=${this.handleChange}\n ></nile-input>`;\n }\n\n renderNileTextArea(switchInput: switchInputType) {\n const { value } = switchInput;\n return html`<nile-textarea\n .value=${value}\n @nile-input=${this.handleChange}\n ></nile-textarea>`;\n }\n\n renderNileCheckBox(defaultInput: switchInputType) {\n const { value, label } = defaultInput;\n\n return html`<nile-checkbox\n .checked=${value}\n .label=${label}\n @valueChange=\"${this.handleChangeCheckbox}\"\n ></nile-checkbox>`;\n }\n\n handleChange(event: CustomEvent) {\n this.emit('nile-change', { value: event.detail.value });\n }\n\n handleChangeCheckbox(event: CustomEvent) {\n this.emit('nile-change', { value: event.detail.checked });\n }\n\n renderDropdown(defaultInput: switchInputType) {\n const { options, multiple, placeholder } = defaultInput;\n return html`<nile-select\n .placeholder=${placeholder}\n .multiple=\"${multiple}\"\n @nile-change=\"${this.handleChange}\"\n >\n ${options &&\n options.map((option: any) => {\n return html`<nile-option .value=\"${option}\">${option} </nile-option>`;\n })}\n </nile-select>`;\n }\n\n renderIcon() {\n const icon = !this.nileSwitchConfig.toggleSwitch\n ? 'header-functions'\n : 'stringinput';\n return html`<nile-icon\n size=\"14\"\n class=${classMap({\n 'pointer-cursor': true,\n 'flex-start': icon === 'stringinput',\n })}\n .name=${icon}\n color=\"#005EA6\"\n @click=${this.toggleField}\n ></nile-icon>`;\n }\n\n toggleField() {\n this.nileSwitchConfig = {\n ...this.nileSwitchConfig,\n toggleSwitch: !this.nileSwitchConfig.toggleSwitch,\n };\n }\n\n singleFieldSwitcher(\n defaultInput: switchInputType,\n switchInput: switchInputType,\n toggleField: boolean\n ) {\n const defaultInputType = defaultInput.inputType;\n const switchInputType = switchInput.inputType;\n return html`\n ${!toggleField\n ? choose(\n defaultInputType,\n [\n ['text', () => this.renderNileText(defaultInput)],\n ['checkbox', () => this.renderNileCheckBox(defaultInput)],\n [\n 'dropdown',\n () => this.renderDropdown(this.nileSwitchConfig.defaultInput),\n ],\n ],\n () => this.renderNileText(defaultInput)\n )\n : choose(\n switchInputType,\n [['text-area', () => this.renderNileTextArea(switchInput)]],\n\n () => this.renderNileTextArea(switchInput)\n )}\n ${this.renderIcon()}\n `;\n }\n public render(): TemplateResult {\n const {\n toggleSwitch: toggleField,\n defaultInput,\n switchInput,\n } = this.nileSwitchConfig;\n\n return html`<div class=\"input-container\">\n ${this.singleFieldSwitcher(defaultInput, switchInput, toggleField)}\n </div>`;\n }\n}\n\nexport default NileSwitcher;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-switcher': NileSwitcher;\n }\n}\n"]}