@aquera/nile-elements 0.0.69 → 0.0.70
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/.nycrc +17 -0
- package/README.md +7 -0
- package/demo/variables.css +1 -1
- package/demo/variables_v2.css +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +45 -15
- package/dist/nile-card/nile-card.cjs.js +1 -1
- package/dist/nile-card/nile-card.cjs.js.map +1 -1
- package/dist/nile-card/nile-card.css.cjs.js +1 -1
- package/dist/nile-card/nile-card.css.cjs.js.map +1 -1
- package/dist/nile-card/nile-card.css.esm.js +23 -4
- package/dist/nile-card/nile-card.esm.js +13 -5
- package/dist/nile-checkbox/nile-checkbox.cjs.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.cjs.js.map +1 -1
- package/dist/nile-checkbox/nile-checkbox.esm.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.cjs.js +4 -4
- package/dist/nile-checkbox/nile-checkbox.test.cjs.js.map +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.esm.js +9 -4
- package/dist/nile-format-date/index.cjs.js +2 -0
- package/dist/nile-format-date/index.cjs.js.map +1 -0
- package/dist/nile-format-date/index.esm.js +1 -0
- package/dist/nile-format-date/nile-format-date.cjs.js +2 -0
- package/dist/nile-format-date/nile-format-date.cjs.js.map +1 -0
- package/dist/nile-format-date/nile-format-date.css.cjs.js +2 -0
- package/dist/nile-format-date/nile-format-date.css.cjs.js.map +1 -0
- package/dist/nile-format-date/nile-format-date.css.esm.js +5 -0
- package/dist/nile-format-date/nile-format-date.esm.js +5 -0
- package/dist/nile-input/nile-input.css.cjs.js +1 -1
- package/dist/nile-input/nile-input.css.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.css.esm.js +0 -5
- package/dist/nile-tab-group/nile-tab-group.cjs.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.cjs.js.map +1 -1
- package/dist/nile-tab-group/nile-tab-group.esm.js +1 -1
- 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-card/nile-card.css.js +23 -4
- package/dist/src/nile-card/nile-card.css.js.map +1 -1
- package/dist/src/nile-card/nile-card.js +12 -4
- package/dist/src/nile-card/nile-card.js.map +1 -1
- package/dist/src/nile-checkbox/nile-checkbox.d.ts +0 -2
- package/dist/src/nile-checkbox/nile-checkbox.js +0 -4
- package/dist/src/nile-checkbox/nile-checkbox.js.map +1 -1
- package/dist/src/nile-checkbox/nile-checkbox.test.js +34 -0
- package/dist/src/nile-checkbox/nile-checkbox.test.js.map +1 -1
- package/dist/src/nile-format-date/index.d.ts +1 -0
- package/dist/src/nile-format-date/index.js +2 -0
- package/dist/src/nile-format-date/index.js.map +1 -0
- package/dist/src/nile-format-date/nile-format-date.css.d.ts +12 -0
- package/dist/src/nile-format-date/nile-format-date.css.js +17 -0
- package/dist/src/nile-format-date/nile-format-date.css.js.map +1 -0
- package/dist/src/nile-format-date/nile-format-date.d.ts +59 -0
- package/dist/src/nile-format-date/nile-format-date.js +129 -0
- package/dist/src/nile-format-date/nile-format-date.js.map +1 -0
- package/dist/src/nile-input/nile-input.css.js +0 -5
- package/dist/src/nile-input/nile-input.css.js.map +1 -1
- package/dist/src/nile-tab-group/nile-tab-group.js +2 -2
- package/dist/src/nile-tab-group/nile-tab-group.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/nile-card/nile-card.css.ts +23 -4
- package/src/nile-card/nile-card.ts +19 -8
- package/src/nile-checkbox/nile-checkbox.test.ts +43 -1
- package/src/nile-checkbox/nile-checkbox.ts +0 -5
- package/src/nile-format-date/index.ts +1 -0
- package/src/nile-format-date/nile-format-date.css.ts +19 -0
- package/src/nile-format-date/nile-format-date.ts +133 -0
- package/src/nile-input/nile-input.css.ts +0 -5
- package/src/nile-tab-group/nile-tab-group.ts +2 -2
- package/web-test-runner.config.mjs +13 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
@@ -61,4 +61,5 @@ export { NileEmptyState } from './nile-empty-state';
|
|
61
61
|
export { NileHero } from './nile-hero';
|
62
62
|
export { NileStepperItem } from './nile-stepper-item';
|
63
63
|
export { NileStepper } from './nile-stepper';
|
64
|
-
export { NileHeroHeader } from './nile-hero-header';
|
64
|
+
export { NileHeroHeader } from './nile-hero-header';
|
65
|
+
export { NileFormatDate } from './nile-format-date';
|
@@ -28,7 +28,7 @@ export const styles = css`
|
|
28
28
|
:host {
|
29
29
|
--border-color: var(--nile-card-color-border);
|
30
30
|
--border-radius: 8px;
|
31
|
-
--border-width:
|
31
|
+
--border-width: 0.5px;
|
32
32
|
--padding: 18px;
|
33
33
|
display: inline-block;
|
34
34
|
}
|
@@ -36,11 +36,24 @@ export const styles = css`
|
|
36
36
|
.card {
|
37
37
|
display: flex;
|
38
38
|
flex-direction: column;
|
39
|
+
justify-items: strecth;
|
39
40
|
background-color: var(--nile-colors-white-base);
|
40
41
|
border: solid var(--border-width) var(--border-color);
|
41
42
|
border-radius: var(--border-radius);
|
42
|
-
|
43
|
-
|
43
|
+
min-width: 273px;
|
44
|
+
max-width: 350px;
|
45
|
+
overflow: hidden;
|
46
|
+
}
|
47
|
+
|
48
|
+
.body__wrapper {
|
49
|
+
display: flex;
|
50
|
+
flex-direction: column;
|
51
|
+
gap: 12px;
|
52
|
+
padding: 12px 16px 0 16px;
|
53
|
+
}
|
54
|
+
|
55
|
+
.card__header {
|
56
|
+
display: block;
|
44
57
|
}
|
45
58
|
|
46
59
|
.card__body {
|
@@ -48,8 +61,14 @@ export const styles = css`
|
|
48
61
|
}
|
49
62
|
|
50
63
|
.card__footer {
|
64
|
+
margin-top: 12px;
|
51
65
|
display: block;
|
52
|
-
|
66
|
+
box-sizing: border-box;
|
67
|
+
align-content: center;
|
68
|
+
align-items: center;
|
69
|
+
padding: 8px 16px;
|
70
|
+
background-color: #f9fafb;
|
71
|
+
height: 40px;
|
53
72
|
}
|
54
73
|
|
55
74
|
.card:not(.card--has-footer) .card__footer {
|
@@ -5,15 +5,20 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import {
|
8
|
+
import {
|
9
|
+
LitElement,
|
10
|
+
html,
|
11
|
+
property,
|
12
|
+
CSSResultArray,
|
13
|
+
TemplateResult,
|
14
|
+
} from 'lit-element';
|
9
15
|
import { customElement } from 'lit/decorators.js';
|
10
|
-
import {styles} from './nile-card.css';
|
16
|
+
import { styles } from './nile-card.css';
|
11
17
|
import { classMap } from 'lit/directives/class-map.js';
|
12
18
|
import { HasSlotController } from '../internal/slot';
|
13
19
|
import NileElements from '../internal/nile-element';
|
14
20
|
import { CSSResultGroup } from 'lit';
|
15
21
|
|
16
|
-
|
17
22
|
/**
|
18
23
|
* Nile icon component.
|
19
24
|
*
|
@@ -22,7 +27,6 @@ import { CSSResultGroup } from 'lit';
|
|
22
27
|
*/
|
23
28
|
@customElement('nile-card')
|
24
29
|
export class NileCard extends NileElements {
|
25
|
-
|
26
30
|
static styles: CSSResultGroup = styles;
|
27
31
|
|
28
32
|
private readonly hasSlotController = new HasSlotController(this, 'footer');
|
@@ -36,15 +40,22 @@ export class NileCard extends NileElements {
|
|
36
40
|
'card--has-footer': this.hasSlotController.test('footer'),
|
37
41
|
})}
|
38
42
|
>
|
39
|
-
<
|
40
|
-
|
43
|
+
<div class="body__wrapper">
|
44
|
+
<slot name="header" part="header" class="card__header"></slot>
|
45
|
+
<slot part="body" class="card__body"></slot>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<slot
|
49
|
+
name="footer"
|
50
|
+
part="footer"
|
51
|
+
?hidden="${!this.hasSlotController.test('footer')}"
|
52
|
+
class="card__footer"
|
53
|
+
></slot>
|
41
54
|
</div>
|
42
|
-
|
43
55
|
`;
|
44
56
|
}
|
45
57
|
}
|
46
58
|
|
47
|
-
|
48
59
|
export default NileCard;
|
49
60
|
|
50
61
|
declare global {
|
@@ -72,7 +72,7 @@ describe('NileCheckbox', () => {
|
|
72
72
|
expect(el.getAttribute('name')).to.equal('test-name');
|
73
73
|
expect(el.getAttribute('title')).to.equal('test-title');
|
74
74
|
expect(el.getAttribute('disabled')).to.equal('');
|
75
|
-
expect(el.getAttribute('required')).
|
75
|
+
expect(el.getAttribute('required')).to.equal('');
|
76
76
|
expect(el.getAttribute('label')).to.equal('test-label');
|
77
77
|
expect(el.getAttribute('sub-label')).to.equal('test-sublabel');
|
78
78
|
expect(el.getAttribute('help-text')).to.equal('test-help');
|
@@ -143,4 +143,46 @@ describe('NileCheckbox', () => {
|
|
143
143
|
const blurEvent = await oneEvent(el, 'blur');
|
144
144
|
expect(blurEvent).to.exist;
|
145
145
|
});
|
146
|
+
|
147
|
+
it('reflects checked attribute to property', async () => {
|
148
|
+
const el = await fixture<NileCheckbox>(html`<nile-checkbox checked></nile-checkbox>`);
|
149
|
+
expect(el.checked).to.be.true;
|
150
|
+
});
|
151
|
+
|
152
|
+
it('reflects indeterminate attribute to property', async () => {
|
153
|
+
const el = await fixture<NileCheckbox>(html`<nile-checkbox indeterminate></nile-checkbox>`);
|
154
|
+
expect(el.indeterminate).to.be.true;
|
155
|
+
});
|
156
|
+
|
157
|
+
it('associates form using form attribute', async () => {
|
158
|
+
const el = await fixture(html`
|
159
|
+
<div>
|
160
|
+
<form id="test-form"></form>
|
161
|
+
<nile-checkbox form="test-form"></nile-checkbox>
|
162
|
+
</div>
|
163
|
+
`);
|
164
|
+
const checkbox = el.querySelector('nile-checkbox') as NileCheckbox;
|
165
|
+
expect(checkbox).to.not.be.null;
|
166
|
+
expect(checkbox.getAttribute('form')).to.equal('test-form');
|
167
|
+
});
|
168
|
+
|
169
|
+
it('displays and hides help text correctly', async () => {
|
170
|
+
const el = await fixture<NileCheckbox>(html`<nile-checkbox help-text="test-help"></nile-checkbox>`);
|
171
|
+
|
172
|
+
// Initially, help text should not be shown
|
173
|
+
expect(el.showHelpText).to.be.false;
|
174
|
+
|
175
|
+
// Show the help text
|
176
|
+
el.showHelpText = true;
|
177
|
+
await el.updateComplete;
|
178
|
+
let helpTextIcon = el.shadowRoot!.querySelector('.checkbox__helptext-icon');
|
179
|
+
expect(helpTextIcon).to.exist;
|
180
|
+
|
181
|
+
// Hide the help text
|
182
|
+
el.showHelpText = false;
|
183
|
+
await el.updateComplete;
|
184
|
+
helpTextIcon = el.shadowRoot!.querySelector('.checkbox__helptext-icon');
|
185
|
+
expect(helpTextIcon).to.be.exist;
|
186
|
+
});
|
146
187
|
});
|
188
|
+
|
@@ -35,7 +35,6 @@ import type { CSSResultGroup } from 'lit';
|
|
35
35
|
* @event nile-change - Emitted when the checked state changes.
|
36
36
|
* @event nile-focus - Emitted when the checkbox gains focus.
|
37
37
|
* @event nile-input - Emitted when the checkbox receives input.
|
38
|
-
* @event nile-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.
|
39
38
|
*
|
40
39
|
* @csspart base - The component's base wrapper.
|
41
40
|
* @csspart control - The square container that wraps the checkbox's checked state.
|
@@ -113,10 +112,6 @@ export class NileCheckbox extends NileElement {
|
|
113
112
|
/** Makes the checkbox a required field. */
|
114
113
|
@property({ type: Boolean, reflect: true }) required = false;
|
115
114
|
|
116
|
-
private toggleHelpText() {
|
117
|
-
this.showHelpText = !this.showHelpText;
|
118
|
-
}
|
119
|
-
|
120
115
|
private handleClick() {
|
121
116
|
this.checked = !this.checked;
|
122
117
|
this.indeterminate = false;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { NileFormatDate } from './nile-format-date';
|
@@ -0,0 +1,19 @@
|
|
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
|
+
* FormatDate CSS
|
12
|
+
*/
|
13
|
+
export const styles = css`
|
14
|
+
:host {
|
15
|
+
|
16
|
+
}
|
17
|
+
`;
|
18
|
+
|
19
|
+
export default [styles];
|
@@ -0,0 +1,133 @@
|
|
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 {LitElement, html, property, CSSResultArray, TemplateResult} from 'lit-element';
|
9
|
+
import { customElement } from 'lit/decorators.js';
|
10
|
+
import {styles} from './nile-format-date.css';
|
11
|
+
import NileElement from '../internal/nile-element';
|
12
|
+
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Nile format-date component.
|
16
|
+
*
|
17
|
+
* @tag nile-format-date
|
18
|
+
*
|
19
|
+
*/
|
20
|
+
@customElement('nile-format-date')
|
21
|
+
export class NileFormatDate extends NileElement {
|
22
|
+
/**
|
23
|
+
* The styles for nile-format-date
|
24
|
+
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
25
|
+
*/
|
26
|
+
public static get styles(): CSSResultArray {
|
27
|
+
return [styles];
|
28
|
+
}
|
29
|
+
|
30
|
+
/**
|
31
|
+
* The date/time to format. If not set, the current date and time will be used. When passing a string, it's strongly
|
32
|
+
* recommended to use the ISO 8601 format to ensure timezones are handled correctly. To convert a date to this format
|
33
|
+
* in JavaScript, use [`date.toISOString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString).
|
34
|
+
*/
|
35
|
+
@property() date: Date | string = new Date();
|
36
|
+
|
37
|
+
/** The format for displaying the weekday. */
|
38
|
+
@property() weekday: 'narrow' | 'short' | 'long';
|
39
|
+
|
40
|
+
/** The format for displaying the era. */
|
41
|
+
@property() era: 'narrow' | 'short' | 'long';
|
42
|
+
|
43
|
+
/** The format for displaying the year. */
|
44
|
+
@property() year: 'numeric' | '2-digit';
|
45
|
+
|
46
|
+
/** The format for displaying the month. */
|
47
|
+
@property() month: 'numeric' | '2-digit' | 'narrow' | 'short' | 'long';
|
48
|
+
|
49
|
+
/** The format for displaying the day. */
|
50
|
+
@property() day: 'numeric' | '2-digit';
|
51
|
+
|
52
|
+
/** The format for displaying the hour. */
|
53
|
+
@property() hour: 'numeric' | '2-digit';
|
54
|
+
|
55
|
+
/** The format for displaying the minute. */
|
56
|
+
@property() minute: 'numeric' | '2-digit';
|
57
|
+
|
58
|
+
/** The format for displaying the second. */
|
59
|
+
@property() second: 'numeric' | '2-digit';
|
60
|
+
|
61
|
+
/** The format for displaying the time. */
|
62
|
+
@property({ attribute: 'time-zone-name' }) timeZoneName: 'short' | 'long';
|
63
|
+
|
64
|
+
/** The time zone to express the time in. */
|
65
|
+
@property({ attribute: 'time-zone' }) timeZone: string;
|
66
|
+
|
67
|
+
/** The format for displaying the hour. */
|
68
|
+
@property({ attribute: 'hour-format' }) hourFormat: 'auto' | '12' | '24' =
|
69
|
+
'auto';
|
70
|
+
|
71
|
+
/** The separator for the date format. */
|
72
|
+
@property({ attribute: 'date-separator' }) dateSeparator: '-' | '/' = '-';
|
73
|
+
|
74
|
+
formatDate(dateToFormat: Date | string, options?: Intl.DateTimeFormatOptions): string {
|
75
|
+
dateToFormat = new Date(dateToFormat);
|
76
|
+
const formatter = new Intl.DateTimeFormat('en-GB', options);
|
77
|
+
const parts = formatter.formatToParts(dateToFormat);
|
78
|
+
const formattedDate = parts.map(({ type, value }) => {
|
79
|
+
if (type === 'day' || type === 'month' || type === 'year') {
|
80
|
+
return value;
|
81
|
+
}
|
82
|
+
if (type === 'literal' && value === '/') {
|
83
|
+
return this.dateSeparator;
|
84
|
+
}
|
85
|
+
return value;
|
86
|
+
}).join('');
|
87
|
+
return formattedDate;
|
88
|
+
}
|
89
|
+
|
90
|
+
// formatDate(dateToFormat: Date | string, options?: Intl.DateTimeFormatOptions): string {
|
91
|
+
// dateToFormat = new Date(dateToFormat);
|
92
|
+
// return new Intl.DateTimeFormat('en-GB', options).format(dateToFormat);
|
93
|
+
// }
|
94
|
+
|
95
|
+
|
96
|
+
render() {
|
97
|
+
const date = new Date(this.date);
|
98
|
+
const hour12 =
|
99
|
+
this.hourFormat === 'auto' ? undefined : this.hourFormat === '12';
|
100
|
+
|
101
|
+
// Check for an invalid date
|
102
|
+
if (isNaN(date.getMilliseconds())) {
|
103
|
+
return undefined;
|
104
|
+
}
|
105
|
+
|
106
|
+
return html`
|
107
|
+
<time datetime=${date.toISOString()}>
|
108
|
+
${this.formatDate(date, {
|
109
|
+
weekday: this.weekday,
|
110
|
+
era: this.era,
|
111
|
+
year: this.year,
|
112
|
+
month: this.month,
|
113
|
+
day: this.day,
|
114
|
+
hour: this.hour,
|
115
|
+
minute: this.minute,
|
116
|
+
second: this.second,
|
117
|
+
timeZoneName: this.timeZoneName,
|
118
|
+
timeZone: this.timeZone,
|
119
|
+
hour12: hour12,
|
120
|
+
})}
|
121
|
+
</time>
|
122
|
+
`;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
/* #endregion */
|
126
|
+
|
127
|
+
export default NileFormatDate;
|
128
|
+
|
129
|
+
declare global {
|
130
|
+
interface HTMLElementTagNameMap {
|
131
|
+
'nile-format-date': NileFormatDate;
|
132
|
+
}
|
133
|
+
}
|
@@ -259,11 +259,6 @@ export const styles = css`
|
|
259
259
|
|
260
260
|
.input:hover:not(.input--disabled) .input__control {
|
261
261
|
color: #000;
|
262
|
-
font-size: 14px;
|
263
|
-
line-height: 14px;
|
264
|
-
font-style: normal;
|
265
|
-
font-weight: 400;
|
266
|
-
letter-spacing: 0.2px;
|
267
262
|
}
|
268
263
|
|
269
264
|
.input__control:focus {
|
@@ -313,8 +313,8 @@ export class NileTabGroup extends NileElement {
|
|
313
313
|
const precedingTabs = allTabs.slice(0, allTabs.indexOf(currentTab));
|
314
314
|
const offset = precedingTabs.reduce(
|
315
315
|
(previous, current) => ({
|
316
|
-
left: previous.left + current.clientWidth +
|
317
|
-
top: previous.top + current.clientHeight +
|
316
|
+
left: previous.left + current.clientWidth + 10,
|
317
|
+
top: previous.top + current.clientHeight + 10
|
318
318
|
}),
|
319
319
|
{ left: 0, top: 0 }
|
320
320
|
);
|
@@ -38,4 +38,17 @@ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
38
38
|
timeout: 5000 // Increase the default timeout to 5 seconds
|
39
39
|
}
|
40
40
|
},
|
41
|
+
|
42
|
+
/** Coverage configuration */
|
43
|
+
coverageConfig: {
|
44
|
+
include: ['dist/src/**/*.js'],
|
45
|
+
exclude: ['dist/src/**/*.test.js'],
|
46
|
+
reporter: ['html', 'text-summary'],
|
47
|
+
thresholds: {
|
48
|
+
statements: 100,
|
49
|
+
branches: 100,
|
50
|
+
functions: 100,
|
51
|
+
lines: 100,
|
52
|
+
},
|
53
|
+
},
|
41
54
|
});
|