@aquera/nile-elements 0.0.5-9 → 0.0.6-2
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/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button/nile-button.css.js +2 -2
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button/nile-button.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-date-picker/nile-date-picker.css.js +0 -162
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-date-picker/nile-date-picker.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-date-picker/nile-date-picker.d.ts +5 -21
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-date-picker/nile-date-picker.js +21 -141
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-date-picker/nile-date-picker.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/index.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/index.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/index.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.d.ts +12 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +35 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.d.ts +60 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +124 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +80 -187
- package/dist/nile-button/nile-button.css.cjs.js +1 -1
- package/dist/nile-button/nile-button.css.cjs.js.map +1 -1
- package/dist/nile-button/nile-button.css.esm.js +2 -2
- package/dist/nile-date-picker/index.cjs.js +1 -1
- package/dist/nile-date-picker/index.esm.js +1 -1
- package/dist/nile-date-picker/nile-date-picker.cjs.js +1 -1
- package/dist/nile-date-picker/nile-date-picker.cjs.js.map +1 -1
- package/dist/nile-date-picker/nile-date-picker.css.cjs.js +1 -1
- package/dist/nile-date-picker/nile-date-picker.css.cjs.js.map +1 -1
- package/dist/nile-date-picker/nile-date-picker.css.esm.js +2 -164
- package/dist/nile-date-picker/nile-date-picker.esm.js +3 -4
- package/dist/nile-switcher/index.cjs.js +2 -0
- package/dist/nile-switcher/index.cjs.js.map +1 -0
- package/dist/nile-switcher/index.esm.js +1 -0
- package/dist/nile-switcher/nile-switcher.cjs.js +2 -0
- package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -0
- package/dist/nile-switcher/nile-switcher.css.cjs.js +2 -0
- package/dist/nile-switcher/nile-switcher.css.cjs.js.map +1 -0
- package/dist/nile-switcher/nile-switcher.css.esm.js +23 -0
- package/dist/nile-switcher/nile-switcher.esm.js +30 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-button/nile-button.css.js +2 -2
- package/dist/src/nile-button/nile-button.css.js.map +1 -1
- package/dist/src/nile-date-picker/nile-date-picker.css.js +0 -162
- package/dist/src/nile-date-picker/nile-date-picker.css.js.map +1 -1
- package/dist/src/nile-date-picker/nile-date-picker.d.ts +5 -21
- package/dist/src/nile-date-picker/nile-date-picker.js +21 -141
- package/dist/src/nile-date-picker/nile-date-picker.js.map +1 -1
- package/dist/src/nile-switcher/index.d.ts +1 -0
- package/dist/src/nile-switcher/index.js +2 -0
- package/dist/src/nile-switcher/index.js.map +1 -0
- package/dist/src/nile-switcher/nile-switcher.css.d.ts +12 -0
- package/dist/src/nile-switcher/nile-switcher.css.js +35 -0
- package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -0
- package/dist/src/nile-switcher/nile-switcher.d.ts +60 -0
- package/dist/src/nile-switcher/nile-switcher.js +124 -0
- package/dist/src/nile-switcher/nile-switcher.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/nile-button/nile-button.css.ts +2 -2
- package/src/nile-date-picker/nile-date-picker.css.ts +0 -162
- package/src/nile-date-picker/nile-date-picker.ts +20 -160
- package/src/nile-switcher/index.ts +1 -0
- package/src/nile-switcher/nile-switcher.css.ts +37 -0
- package/src/nile-switcher/nile-switcher.ts +185 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -29,4 +29,5 @@ export { NileErrorMessage } from './nile-error-message';
|
|
|
29
29
|
export { NileFormErrorMessage } from './nile-form-error-message';
|
|
30
30
|
export { NileFormHelpText } from './nile-form-help-text';
|
|
31
31
|
export { NileCalendar } from './nile-calendar';
|
|
32
|
-
export { NileLink} from './nile-link';
|
|
32
|
+
export { NileLink } from './nile-link';
|
|
33
|
+
export { NileSwitcher } from './nile-switcher';
|
|
@@ -146,7 +146,7 @@ export const styles = css`
|
|
|
146
146
|
.button--standard.button--tertiary {
|
|
147
147
|
background-color: var(--nile-colors-white-base);
|
|
148
148
|
border-color: var(--nile-colors-neutral-500);
|
|
149
|
-
color: var(--nile-colors-
|
|
149
|
+
color: var(--nile-colors-dark-900);
|
|
150
150
|
box-shadow: 0px 2px 4px var(--nile-colors-dark-200);
|
|
151
151
|
}
|
|
152
152
|
|
|
@@ -218,7 +218,7 @@ export const styles = css`
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
.button--outline.button--secondary:active:not(.button--disabled) {
|
|
221
|
-
border-color: var(--nile-colors-
|
|
221
|
+
border-color: var(--nile-colors-neutral-700);
|
|
222
222
|
color: var(--nile-colors-white-base);
|
|
223
223
|
}
|
|
224
224
|
|
|
@@ -13,168 +13,6 @@ import { css } from 'lit-element';
|
|
|
13
13
|
export const styles = css`
|
|
14
14
|
:host {
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
.calendar-container {
|
|
18
|
-
font-family: Colfax-regular;
|
|
19
|
-
width: 365px;
|
|
20
|
-
height: auto;
|
|
21
|
-
text-align: center;
|
|
22
|
-
background: white;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.calendar-container.with-margin {
|
|
26
|
-
margin-right: 20px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.calendar-header {
|
|
30
|
-
display: flex;
|
|
31
|
-
justify-content: space-between;
|
|
32
|
-
padding: 10px;
|
|
33
|
-
padding: 22px 20px;
|
|
34
|
-
font-size: 14px;
|
|
35
|
-
font-weight: 600;
|
|
36
|
-
line-height: 14px;
|
|
37
|
-
letter-spacing: 0.2px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.divider {
|
|
41
|
-
width: 100%;
|
|
42
|
-
height: 1px;
|
|
43
|
-
background: #c7ced4;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.day-names {
|
|
47
|
-
font-size: 14px;
|
|
48
|
-
font-weight: 600;
|
|
49
|
-
line-height: 14px;
|
|
50
|
-
letter-spacing: 0.2px;
|
|
51
|
-
height: 50px;
|
|
52
|
-
margin-top: 10px;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.day-names,
|
|
56
|
-
.days {
|
|
57
|
-
display: flex;
|
|
58
|
-
flex-wrap: wrap;
|
|
59
|
-
justify-content: flex-start;
|
|
60
|
-
height: auto;
|
|
61
|
-
align-items: center;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.days {
|
|
65
|
-
height: auto;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.day {
|
|
69
|
-
flex-basis: calc(100% / 7);
|
|
70
|
-
box-sizing: border-box;
|
|
71
|
-
width: 48px;
|
|
72
|
-
align-items: center;
|
|
73
|
-
padding: 10px;
|
|
74
|
-
height: 32px;
|
|
75
|
-
margin-top: 6px;
|
|
76
|
-
margin-bottom: 6px;
|
|
77
|
-
display: flex;
|
|
78
|
-
justify-content: center;
|
|
79
|
-
align-items: center;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.filler {
|
|
83
|
-
color: grey;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.selected-date {
|
|
87
|
-
color: white;
|
|
88
|
-
border-radius: 4px;
|
|
89
|
-
background: #a5d3f3;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
.calendar-wrapper {
|
|
95
|
-
background: white;
|
|
96
|
-
display: flex;
|
|
97
|
-
justify-content: space-between;
|
|
98
|
-
width: 730px;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.selected-date,
|
|
102
|
-
.range-start,
|
|
103
|
-
.range-end {
|
|
104
|
-
border-radius: 4px;
|
|
105
|
-
background: #a5d3f3;
|
|
106
|
-
color: white;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
.range-start {
|
|
111
|
-
background: #a5d3f3;
|
|
112
|
-
border-radius: 4px 0 0 4px;
|
|
113
|
-
color: white;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.range-end {
|
|
117
|
-
background: #a5d3f3;
|
|
118
|
-
border-radius: 0 4px 4px 0;
|
|
119
|
-
color: white;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.range-middle {
|
|
123
|
-
background: #a5d3f3;
|
|
124
|
-
color: white;
|
|
125
|
-
border-radius: 0;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.day.selected {
|
|
129
|
-
background: #a5d3f3;
|
|
130
|
-
color: white;
|
|
131
|
-
border-radius: 4px;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.day.in-range {
|
|
135
|
-
background: #a5d3f3;
|
|
136
|
-
color: white;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.selected-date {
|
|
140
|
-
color: white;
|
|
141
|
-
border-radius: 4px;
|
|
142
|
-
background: #a5d3f3;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.base {
|
|
146
|
-
background-color: white;
|
|
147
|
-
border-radius: 4px;
|
|
148
|
-
padding-bottom: 20px
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.calender-input{
|
|
152
|
-
padding: 20px;
|
|
153
|
-
padding-bottom: 0px;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.from {
|
|
157
|
-
display: flex;
|
|
158
|
-
justify-content: space-between;
|
|
159
|
-
gap: 20px;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.manual-input{
|
|
163
|
-
width:100%;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.manual-input-label{
|
|
167
|
-
font-size: 12px;
|
|
168
|
-
font-style: normal;
|
|
169
|
-
font-weight: 500;
|
|
170
|
-
margin-bottom: 10px;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.apply-button {
|
|
174
|
-
text-align: right;
|
|
175
|
-
display: block;
|
|
176
|
-
padding-top: 20px;
|
|
177
|
-
}
|
|
178
16
|
`;
|
|
179
17
|
|
|
180
18
|
export default [styles];
|
|
@@ -12,25 +12,9 @@ import {
|
|
|
12
12
|
CSSResultArray,
|
|
13
13
|
TemplateResult,
|
|
14
14
|
} from 'lit-element';
|
|
15
|
-
import { customElement } from 'lit/decorators.js';
|
|
15
|
+
import { customElement, query } from 'lit/decorators.js';
|
|
16
16
|
import { styles } from './nile-date-picker.css';
|
|
17
|
-
import { animateTo, stopAnimations } from '../internal/animate';
|
|
18
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
19
|
-
import { query } from 'lit/decorators.js';
|
|
20
|
-
import {
|
|
21
|
-
getAnimation,
|
|
22
|
-
setDefaultAnimation,
|
|
23
|
-
} from '../utilities/animation-registry';
|
|
24
|
-
import { getTabbableBoundary } from '../internal/tabbable';
|
|
25
|
-
import { waitForEvent } from '../internal/event';
|
|
26
|
-
import { watch } from '../internal/watch';
|
|
27
17
|
import NileElement from '../internal/nile-element';
|
|
28
|
-
import type { CSSResultGroup, PropertyValues } from 'lit';
|
|
29
|
-
import type NileButton from '../nile-button/nile-button';
|
|
30
|
-
import type NileIconButton from '../nile-icon-button/nile-icon-button';
|
|
31
|
-
import type { NileMenu } from '../nile-menu';
|
|
32
|
-
import type { NilePopup } from '../nile-popup';
|
|
33
|
-
import '../nile-popup';
|
|
34
18
|
import { NileDropdown } from '../nile-dropdown';
|
|
35
19
|
|
|
36
20
|
/**
|
|
@@ -49,123 +33,32 @@ export class NileDatePicker extends NileElement {
|
|
|
49
33
|
return [styles];
|
|
50
34
|
}
|
|
51
35
|
|
|
52
|
-
private currentMonth: number = new Date().getMonth();
|
|
53
|
-
private currentYear: number = new Date().getFullYear();
|
|
54
|
-
|
|
55
|
-
@query('nile-dropdown') dropdown: NileDropdown;
|
|
56
|
-
|
|
57
|
-
@property({ type: Boolean, reflect: true }) dropDownOpened = false;
|
|
58
|
-
|
|
59
|
-
@property({ type: Object }) value : any;
|
|
60
|
-
|
|
61
|
-
@property({ type: Object }) rangeValue : any;
|
|
62
|
-
|
|
63
|
-
@property({ type: String, attribute: 'value' }) valueAttribute:
|
|
64
|
-
| string
|
|
65
|
-
| null = null;
|
|
66
|
-
|
|
67
|
-
@property({ type: String, attribute: 'value' }) formattedDate: string | null =
|
|
68
|
-
null;
|
|
69
|
-
|
|
70
|
-
@property({ type: Object }) startDate: Date | null = null;
|
|
71
|
-
@property({ type: Object }) endDate: Date | null = null;
|
|
72
|
-
@property({ type: Boolean }) isSelectingStart = true; // flag to indicate what we're selecting
|
|
73
|
-
|
|
74
36
|
@property({ type: Boolean }) range = false;
|
|
75
37
|
|
|
76
|
-
@
|
|
77
|
-
valueChanged() {
|
|
78
|
-
|
|
79
|
-
if (this.range && this.value) {
|
|
80
|
-
this.rangeValue = this.value;
|
|
81
|
-
this.value = null;
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (this.value && !isNaN(this.value.getTime())) {
|
|
86
|
-
const offset = this.value.getTimezoneOffset();
|
|
87
|
-
const localDate = new Date(this.value.getTime() - offset * 60 * 1000);
|
|
88
|
-
if (!isNaN(localDate.getTime())) {
|
|
89
|
-
this.valueAttribute = localDate.toISOString().split('T')[0];
|
|
90
|
-
this.formattedDate = `${String(localDate.getDate()).padStart(
|
|
91
|
-
2,
|
|
92
|
-
'0'
|
|
93
|
-
)}/${String(localDate.getMonth() + 1).padStart(
|
|
94
|
-
2,
|
|
95
|
-
'0'
|
|
96
|
-
)}/${localDate.getFullYear()}`;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
updated(changedProperties: PropertyValues) {
|
|
103
|
-
super.updated(changedProperties);
|
|
38
|
+
@property() value: any;
|
|
104
39
|
|
|
105
|
-
|
|
106
|
-
const date = new Date(this.valueAttribute || '');
|
|
107
|
-
if (!isNaN(date.getTime())) {
|
|
108
|
-
const offset = date.getTimezoneOffset();
|
|
109
|
-
this.value = new Date(date.getTime() - offset * 60 * 1000);
|
|
110
|
-
this.currentMonth = this.value.getMonth();
|
|
111
|
-
this.currentYear = this.value.getFullYear();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
static get observedAttributes() {
|
|
117
|
-
return ['value', 'range'];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
attributeChangedCallback(name: string, oldValue: string, newValue: string) {
|
|
121
|
-
if (name === 'value') {
|
|
122
|
-
this.valueAttribute = newValue;
|
|
123
|
-
this.initializeValue();
|
|
124
|
-
} else if (name === 'range') {
|
|
125
|
-
this.range = newValue !== null;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
initializeValue() {
|
|
130
|
-
if (this.range) {
|
|
131
|
-
try {
|
|
132
|
-
const rangeValue = JSON.parse(this.valueAttribute || '');
|
|
133
|
-
this.startDate = new Date(rangeValue.startDate);
|
|
134
|
-
this.endDate = new Date(rangeValue.endDate);
|
|
135
|
-
|
|
136
|
-
// Convert to local time
|
|
137
|
-
this.startDate = new Date(this.startDate.getTime());
|
|
138
|
-
this.endDate = new Date(this.endDate.getTime());
|
|
139
|
-
|
|
140
|
-
this.rangeValue = {
|
|
141
|
-
startDate: this.startDate,
|
|
142
|
-
endDate: this.endDate,
|
|
143
|
-
};
|
|
144
|
-
this.value = null;
|
|
145
|
-
} catch (e) {
|
|
146
|
-
// console.error('Invalid range value');
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
if (this.valueAttribute) {
|
|
150
|
-
let date: Date;
|
|
151
|
-
|
|
152
|
-
date = new Date(this.valueAttribute);
|
|
40
|
+
@query('nile-dropdown') dropdown: NileDropdown;
|
|
153
41
|
|
|
154
|
-
date = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
|
|
155
42
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Render method
|
|
45
|
+
* @slot This is a slot test
|
|
46
|
+
*/
|
|
47
|
+
render(): TemplateResult {
|
|
48
|
+
return html`
|
|
49
|
+
<nile-dropdown .hoist="${true}">
|
|
50
|
+
<slot
|
|
51
|
+
slot="trigger"
|
|
52
|
+
part="trigger"
|
|
53
|
+
name="trigger"
|
|
54
|
+
></slot>
|
|
55
|
+
<nile-calendar value="${this.value}" .range="${this.range}" @nile-changed="${this.handleChanged}"></nile-calendar>
|
|
56
|
+
</nile-dropdown>
|
|
57
|
+
`;
|
|
165
58
|
}
|
|
166
59
|
|
|
167
|
-
handleChanged(event:any) {
|
|
168
|
-
this.emit('nile-changed',
|
|
60
|
+
handleChanged(event: any) {
|
|
61
|
+
this.emit('nile-changed', event.detail);
|
|
169
62
|
if (this.dropdown) {
|
|
170
63
|
this.dropdown.hide();
|
|
171
64
|
}
|
|
@@ -173,16 +66,6 @@ export class NileDatePicker extends NileElement {
|
|
|
173
66
|
|
|
174
67
|
connectedCallback() {
|
|
175
68
|
super.connectedCallback();
|
|
176
|
-
this.initializeValue();
|
|
177
|
-
|
|
178
|
-
if (this.valueAttribute) {
|
|
179
|
-
const date = new Date(this.valueAttribute);
|
|
180
|
-
if (!isNaN(date.getTime())) {
|
|
181
|
-
this.value = date;
|
|
182
|
-
this.currentMonth = this.value.getMonth();
|
|
183
|
-
this.currentYear = this.value.getFullYear();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
69
|
this.emit('nile-init');
|
|
187
70
|
}
|
|
188
71
|
|
|
@@ -190,29 +73,6 @@ export class NileDatePicker extends NileElement {
|
|
|
190
73
|
super.disconnectedCallback();
|
|
191
74
|
this.emit('nile-destroy');
|
|
192
75
|
}
|
|
193
|
-
|
|
194
|
-
/* #endregion */
|
|
195
|
-
|
|
196
|
-
/* #region Methods */
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Render method
|
|
200
|
-
* @slot This is a slot test
|
|
201
|
-
*/
|
|
202
|
-
render(): TemplateResult {
|
|
203
|
-
|
|
204
|
-
return html`
|
|
205
|
-
<nile-dropdown .hoist="${true}">
|
|
206
|
-
<slot
|
|
207
|
-
slot="trigger"
|
|
208
|
-
part="trigger"
|
|
209
|
-
name="trigger"
|
|
210
|
-
></slot>
|
|
211
|
-
|
|
212
|
-
<nile-calendar .value="${this.range}" .range="${this.range}" @nile-changed="${this.handleChanged}"> </nile-calendar>
|
|
213
|
-
</nile-dropdown>
|
|
214
|
-
`;
|
|
215
|
-
}
|
|
216
76
|
}
|
|
217
77
|
|
|
218
78
|
export default NileDatePicker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NileSwitcher } from './nile-switcher';
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import { css } from 'lit-element';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* FieldGenerator CSS
|
|
12
|
+
*/
|
|
13
|
+
export const styles = css`
|
|
14
|
+
:host {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
width: 100%;
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.pointer-cursor {
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
}
|
|
23
|
+
.input-container {
|
|
24
|
+
display: flex;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.input-container > :first-child {
|
|
28
|
+
width: 100%;
|
|
29
|
+
padding-right: 12px;
|
|
30
|
+
}
|
|
31
|
+
.flex-start {
|
|
32
|
+
align-items: flex-start;
|
|
33
|
+
padding-top: 10px;
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
export default [styles];
|
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
import { html, property, TemplateResult } 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 { CSSResultGroup } from 'lit';
|
|
13
|
+
import { choose } from 'lit/directives/choose.js';
|
|
14
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @summary Allows you to switch between nile elements
|
|
18
|
+
|
|
19
|
+
* @dependency nile-icon
|
|
20
|
+
* @dependency nile-input
|
|
21
|
+
* @dependency nile-checkbox
|
|
22
|
+
* @dependency nile-dropdown
|
|
23
|
+
* @dependency nile-textarea
|
|
24
|
+
*
|
|
25
|
+
|
|
26
|
+
* @event nile-change - Emitted when the control's value changes.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
export interface switchconfig {
|
|
30
|
+
toggleSwitch: boolean;
|
|
31
|
+
defaultInput: switchInputType;
|
|
32
|
+
switchInput: switchInputType;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface switchInputType {
|
|
36
|
+
inputType: 'dropdown' | 'text' | 'checkbox' | 'text-area';
|
|
37
|
+
value?: String | boolean;
|
|
38
|
+
label?: String;
|
|
39
|
+
placeholder?: string;
|
|
40
|
+
options?: Array<any>;
|
|
41
|
+
multiple?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@customElement('nile-switcher')
|
|
45
|
+
export class NileSwitcher extends NileElement {
|
|
46
|
+
/**
|
|
47
|
+
* The styles for nile switcher
|
|
48
|
+
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
|
49
|
+
*/
|
|
50
|
+
static styles: CSSResultGroup = styles;
|
|
51
|
+
@property() nileSwitchConfig: switchconfig;
|
|
52
|
+
|
|
53
|
+
connectedCallback() {
|
|
54
|
+
super.connectedCallback();
|
|
55
|
+
this.emit('nile-init');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
disconnectedCallback() {
|
|
59
|
+
super.disconnectedCallback();
|
|
60
|
+
this.emit('nile-destroy');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
renderNileText(defaultInput: switchInputType) {
|
|
64
|
+
const { value, label, placeholder } = defaultInput;
|
|
65
|
+
return html`<nile-input
|
|
66
|
+
.value=${value}
|
|
67
|
+
.label=${label}
|
|
68
|
+
.placeholder=${placeholder}
|
|
69
|
+
@nile-input=${this.handleChange}
|
|
70
|
+
></nile-input>`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
renderNileTextArea(switchInput: switchInputType) {
|
|
74
|
+
const { value } = switchInput;
|
|
75
|
+
return html`<nile-textarea
|
|
76
|
+
.value=${value}
|
|
77
|
+
@nile-input=${this.handleChange}
|
|
78
|
+
></nile-textarea>`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
renderNileCheckBox(defaultInput: switchInputType) {
|
|
82
|
+
const { value, label } = defaultInput;
|
|
83
|
+
|
|
84
|
+
return html`<nile-checkbox
|
|
85
|
+
.checked=${value}
|
|
86
|
+
.label=${label}
|
|
87
|
+
@valueChange="${this.handleChangeCheckbox}"
|
|
88
|
+
></nile-checkbox>`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
handleChange(event: CustomEvent) {
|
|
92
|
+
this.emit('nile-change', { value: event.detail.value });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
handleChangeCheckbox(event: CustomEvent) {
|
|
96
|
+
this.emit('nile-change', { value: event.detail.checked });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
renderDropdown(defaultInput: switchInputType) {
|
|
100
|
+
const { options, multiple, placeholder } = defaultInput;
|
|
101
|
+
return html`<nile-select
|
|
102
|
+
.placeholder=${placeholder}
|
|
103
|
+
.multiple="${multiple}"
|
|
104
|
+
@nile-change="${this.handleChange}"
|
|
105
|
+
>
|
|
106
|
+
${options &&
|
|
107
|
+
options.map((option: any) => {
|
|
108
|
+
return html`<nile-option .value="${option}">${option} </nile-option>`;
|
|
109
|
+
})}
|
|
110
|
+
</nile-select>`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
renderIcon() {
|
|
114
|
+
const icon = !this.nileSwitchConfig.toggleSwitch
|
|
115
|
+
? 'header-functions'
|
|
116
|
+
: 'stringinput';
|
|
117
|
+
return html`<nile-icon
|
|
118
|
+
size="14"
|
|
119
|
+
class=${classMap({
|
|
120
|
+
'pointer-cursor': true,
|
|
121
|
+
'flex-start': icon === 'stringinput',
|
|
122
|
+
})}
|
|
123
|
+
.name=${icon}
|
|
124
|
+
color="#005EA6"
|
|
125
|
+
@click=${this.toggleField}
|
|
126
|
+
></nile-icon>`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
toggleField() {
|
|
130
|
+
this.nileSwitchConfig = {
|
|
131
|
+
...this.nileSwitchConfig,
|
|
132
|
+
toggleSwitch: !this.nileSwitchConfig.toggleSwitch,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
singleFieldSwitcher(
|
|
137
|
+
defaultInput: switchInputType,
|
|
138
|
+
switchInput: switchInputType,
|
|
139
|
+
toggleField: boolean
|
|
140
|
+
) {
|
|
141
|
+
const defaultInputType = defaultInput.inputType;
|
|
142
|
+
const switchInputType = switchInput.inputType;
|
|
143
|
+
return html`
|
|
144
|
+
${!toggleField
|
|
145
|
+
? choose(
|
|
146
|
+
defaultInputType,
|
|
147
|
+
[
|
|
148
|
+
['text', () => this.renderNileText(defaultInput)],
|
|
149
|
+
['checkbox', () => this.renderNileCheckBox(defaultInput)],
|
|
150
|
+
[
|
|
151
|
+
'dropdown',
|
|
152
|
+
() => this.renderDropdown(this.nileSwitchConfig.defaultInput),
|
|
153
|
+
],
|
|
154
|
+
],
|
|
155
|
+
() => this.renderNileText(defaultInput)
|
|
156
|
+
)
|
|
157
|
+
: choose(
|
|
158
|
+
switchInputType,
|
|
159
|
+
[['text-area', () => this.renderNileTextArea(switchInput)]],
|
|
160
|
+
|
|
161
|
+
() => this.renderNileTextArea(switchInput)
|
|
162
|
+
)}
|
|
163
|
+
${this.renderIcon()}
|
|
164
|
+
`;
|
|
165
|
+
}
|
|
166
|
+
public render(): TemplateResult {
|
|
167
|
+
const {
|
|
168
|
+
toggleSwitch: toggleField,
|
|
169
|
+
defaultInput,
|
|
170
|
+
switchInput,
|
|
171
|
+
} = this.nileSwitchConfig;
|
|
172
|
+
|
|
173
|
+
return html`<div class="input-container">
|
|
174
|
+
${this.singleFieldSwitcher(defaultInput, switchInput, toggleField)}
|
|
175
|
+
</div>`;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default NileSwitcher;
|
|
180
|
+
|
|
181
|
+
declare global {
|
|
182
|
+
interface HTMLElementTagNameMap {
|
|
183
|
+
'nile-switcher': NileSwitcher;
|
|
184
|
+
}
|
|
185
|
+
}
|