@aquera/nile-elements 0.0.80 → 0.0.81

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 (78) hide show
  1. package/README.md +3 -0
  2. package/dist/fixture-6f853cbd.esm.js +569 -0
  3. package/dist/fixture-b1476eef.cjs.js +395 -0
  4. package/dist/fixture-b1476eef.cjs.js.map +1 -0
  5. package/dist/index.cjs.js +1 -1
  6. package/dist/index.esm.js +1 -1
  7. package/dist/index.iife.js +171 -65
  8. package/dist/internal/drag.cjs.js +2 -0
  9. package/dist/internal/drag.cjs.js.map +1 -0
  10. package/dist/internal/drag.esm.js +1 -0
  11. package/dist/internal/math.cjs.js +2 -0
  12. package/dist/internal/math.cjs.js.map +1 -0
  13. package/dist/internal/math.esm.js +1 -0
  14. package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -394
  15. package/dist/nile-checkbox/nile-checkbox.test.cjs.js.map +1 -1
  16. package/dist/nile-checkbox/nile-checkbox.test.esm.js +3 -571
  17. package/dist/nile-empty-state/nile-empty-state.test.cjs.js +2 -0
  18. package/dist/nile-empty-state/nile-empty-state.test.cjs.js.map +1 -0
  19. package/dist/nile-empty-state/nile-empty-state.test.esm.js +9 -0
  20. package/dist/nile-hero/nile-hero.test.cjs.js +2 -0
  21. package/dist/nile-hero/nile-hero.test.cjs.js.map +1 -0
  22. package/dist/nile-hero/nile-hero.test.esm.js +14 -0
  23. package/dist/nile-split-panel/index.cjs.js +2 -0
  24. package/dist/nile-split-panel/index.cjs.js.map +1 -0
  25. package/dist/nile-split-panel/index.esm.js +1 -0
  26. package/dist/nile-split-panel/nile-split-panel.cjs.js +2 -0
  27. package/dist/nile-split-panel/nile-split-panel.cjs.js.map +1 -0
  28. package/dist/nile-split-panel/nile-split-panel.css.cjs.js +2 -0
  29. package/dist/nile-split-panel/nile-split-panel.css.cjs.js.map +1 -0
  30. package/dist/nile-split-panel/nile-split-panel.css.esm.js +87 -0
  31. package/dist/nile-split-panel/nile-split-panel.esm.js +21 -0
  32. package/dist/nile-stepper/nile-stepper.cjs.js +1 -1
  33. package/dist/nile-stepper/nile-stepper.cjs.js.map +1 -1
  34. package/dist/nile-stepper/nile-stepper.esm.js +1 -1
  35. package/dist/nile-stepper/nile-stepper.test.cjs.js +2 -0
  36. package/dist/nile-stepper/nile-stepper.test.cjs.js.map +1 -0
  37. package/dist/nile-stepper/nile-stepper.test.esm.js +1 -0
  38. package/dist/src/index.d.ts +1 -0
  39. package/dist/src/index.js +1 -0
  40. package/dist/src/index.js.map +1 -1
  41. package/dist/src/internal/drag.d.ts +15 -0
  42. package/dist/src/internal/drag.js +28 -0
  43. package/dist/src/internal/drag.js.map +1 -0
  44. package/dist/src/internal/math.d.ts +2 -0
  45. package/dist/src/internal/math.js +12 -0
  46. package/dist/src/internal/math.js.map +1 -0
  47. package/dist/src/nile-empty-state/nile-empty-state.test.d.ts +1 -0
  48. package/dist/src/nile-empty-state/nile-empty-state.test.js +63 -0
  49. package/dist/src/nile-empty-state/nile-empty-state.test.js.map +1 -0
  50. package/dist/src/nile-hero/nile-hero.test.d.ts +1 -0
  51. package/dist/src/nile-hero/nile-hero.test.js +42 -0
  52. package/dist/src/nile-hero/nile-hero.test.js.map +1 -0
  53. package/dist/src/nile-split-panel/index.d.ts +1 -0
  54. package/dist/src/nile-split-panel/index.js +2 -0
  55. package/dist/src/nile-split-panel/index.js.map +1 -0
  56. package/dist/src/nile-split-panel/nile-split-panel.css.d.ts +12 -0
  57. package/dist/src/nile-split-panel/nile-split-panel.css.js +99 -0
  58. package/dist/src/nile-split-panel/nile-split-panel.css.js.map +1 -0
  59. package/dist/src/nile-split-panel/nile-split-panel.d.ts +78 -0
  60. package/dist/src/nile-split-panel/nile-split-panel.js +251 -0
  61. package/dist/src/nile-split-panel/nile-split-panel.js.map +1 -0
  62. package/dist/src/nile-stepper/nile-stepper.js +1 -1
  63. package/dist/src/nile-stepper/nile-stepper.js.map +1 -1
  64. package/dist/src/nile-stepper/nile-stepper.test.d.ts +0 -0
  65. package/dist/src/nile-stepper/nile-stepper.test.js +165 -0
  66. package/dist/src/nile-stepper/nile-stepper.test.js.map +1 -0
  67. package/dist/tsconfig.tsbuildinfo +1 -1
  68. package/package.json +1 -1
  69. package/src/index.ts +2 -1
  70. package/src/internal/drag.ts +45 -0
  71. package/src/internal/math.ts +14 -0
  72. package/src/nile-empty-state/nile-empty-state.test.ts +69 -0
  73. package/src/nile-hero/nile-hero.test.ts +45 -0
  74. package/src/nile-split-panel/index.ts +1 -0
  75. package/src/nile-split-panel/nile-split-panel.css.ts +101 -0
  76. package/src/nile-split-panel/nile-split-panel.ts +285 -0
  77. package/src/nile-stepper/nile-stepper.test.ts +174 -0
  78. package/src/nile-stepper/nile-stepper.ts +2 -2
@@ -0,0 +1,28 @@
1
+ /** Begins listening for dragging. */
2
+ export function drag(container, options) {
3
+ function move(pointerEvent) {
4
+ const dims = container.getBoundingClientRect();
5
+ const defaultView = container.ownerDocument.defaultView;
6
+ const offsetX = dims.left + defaultView.pageXOffset;
7
+ const offsetY = dims.top + defaultView.pageYOffset;
8
+ const x = pointerEvent.pageX - offsetX;
9
+ const y = pointerEvent.pageY - offsetY;
10
+ if (options?.onMove) {
11
+ options.onMove(x, y);
12
+ }
13
+ }
14
+ function stop() {
15
+ document.removeEventListener('pointermove', move);
16
+ document.removeEventListener('pointerup', stop);
17
+ if (options?.onStop) {
18
+ options.onStop();
19
+ }
20
+ }
21
+ document.addEventListener('pointermove', move, { passive: true });
22
+ document.addEventListener('pointerup', stop);
23
+ // If an initial event is set, trigger the first drag immediately
24
+ if (options?.initialEvent instanceof PointerEvent) {
25
+ move(options.initialEvent);
26
+ }
27
+ }
28
+ //# sourceMappingURL=drag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag.js","sourceRoot":"","sources":["../../../src/internal/drag.ts"],"names":[],"mappings":"AAaA,qCAAqC;AACrC,MAAM,UAAU,IAAI,CAAC,SAAsB,EAAE,OAA8B;IACzE,SAAS,IAAI,CAAC,YAA0B;QACtC,MAAM,IAAI,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,SAAS,CAAC,aAAa,CAAC,WAAY,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,WAAW,CAAC;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,GAAG,WAAW,CAAC,WAAW,CAAC;QACnD,MAAM,CAAC,GAAG,YAAY,CAAC,KAAK,GAAG,OAAO,CAAC;QACvC,MAAM,CAAC,GAAG,YAAY,CAAC,KAAK,GAAG,OAAO,CAAC;QAEvC,IAAI,OAAO,EAAE,MAAM,EAAE;YACnB,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACtB;IACH,CAAC;IAED,SAAS,IAAI;QACX,QAAQ,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QAClD,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAEhD,IAAI,OAAO,EAAE,MAAM,EAAE;YACnB,OAAO,CAAC,MAAM,EAAE,CAAC;SAClB;IACH,CAAC;IAED,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAE7C,iEAAiE;IACjE,IAAI,OAAO,EAAE,YAAY,YAAY,YAAY,EAAE;QACjD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;KAC5B;AACH,CAAC","sourcesContent":["interface DragOptions {\n /** Callback that runs as dragging occurs. */\n onMove: (x: number, y: number) => void;\n /** Callback that runs when dragging stops. */\n onStop: () => void;\n /**\n * When an initial event is passed, the first drag will be triggered immediately using the coordinates therein. This\n * is useful when the drag is initiated by a mousedown/touchstart event but you want the initial \"click\" to activate\n * a drag (e.g. positioning a handle initially at the click target).\n */\n initialEvent: PointerEvent;\n}\n\n/** Begins listening for dragging. */\nexport function drag(container: HTMLElement, options?: Partial<DragOptions>) {\n function move(pointerEvent: PointerEvent) {\n const dims = container.getBoundingClientRect();\n const defaultView = container.ownerDocument.defaultView!;\n const offsetX = dims.left + defaultView.pageXOffset;\n const offsetY = dims.top + defaultView.pageYOffset;\n const x = pointerEvent.pageX - offsetX;\n const y = pointerEvent.pageY - offsetY;\n\n if (options?.onMove) {\n options.onMove(x, y);\n }\n }\n\n function stop() {\n document.removeEventListener('pointermove', move);\n document.removeEventListener('pointerup', stop);\n\n if (options?.onStop) {\n options.onStop();\n }\n }\n\n document.addEventListener('pointermove', move, { passive: true });\n document.addEventListener('pointerup', stop);\n\n // If an initial event is set, trigger the first drag immediately\n if (options?.initialEvent instanceof PointerEvent) {\n move(options.initialEvent);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ /** Ensures a number stays within a minimum and maximum value */
2
+ export declare function clamp(value: number, min: number, max: number): number;
@@ -0,0 +1,12 @@
1
+ /** Ensures a number stays within a minimum and maximum value */
2
+ export function clamp(value, min, max) {
3
+ const noNegativeZero = (n) => (Object.is(n, -0) ? 0 : n);
4
+ if (value < min) {
5
+ return noNegativeZero(min);
6
+ }
7
+ if (value > max) {
8
+ return noNegativeZero(max);
9
+ }
10
+ return noNegativeZero(value);
11
+ }
12
+ //# sourceMappingURL=math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.js","sourceRoot":"","sources":["../../../src/internal/math.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IAC3D,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjE,IAAI,KAAK,GAAG,GAAG,EAAE;QACf,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;KAC5B;IAED,IAAI,KAAK,GAAG,GAAG,EAAE;QACf,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;KAC5B;IAED,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["/** Ensures a number stays within a minimum and maximum value */\nexport function clamp(value: number, min: number, max: number) {\n const noNegativeZero = (n: number) => (Object.is(n, -0) ? 0 : n);\n\n if (value < min) {\n return noNegativeZero(min);\n }\n\n if (value > max) {\n return noNegativeZero(max);\n }\n\n return noNegativeZero(value);\n}\n"]}
@@ -0,0 +1 @@
1
+ import './nile-empty-state';
@@ -0,0 +1,63 @@
1
+ import { fixture, html, expect } from "@open-wc/testing";
2
+ import './nile-empty-state';
3
+ describe('NileEmptyState', () => {
4
+ it('renders correctly with default properties', async () => {
5
+ const el = await fixture(html `<nile-empty-state></nile-empty-state>`);
6
+ expect(el.size).to.equal('md');
7
+ expect(el.variant).to.equal('tonal');
8
+ expect(el.icon).to.equal('error');
9
+ expect(el.grayscale).to.be.false;
10
+ expect(el.text).to.equal('Empty State');
11
+ expect(el.subText).to.equal('No Data');
12
+ });
13
+ it('should reflect properties to attributes', async () => {
14
+ const iconName = "action";
15
+ const el = await fixture(html `
16
+ <nile-empty-state size="sm" variant="flat" icon=${iconName} grayscale text="Test state text" sub-text="Test sub text"></nile-empty-state>
17
+ `);
18
+ expect(el.getAttribute('size')).to.equal('sm');
19
+ expect(el.getAttribute('variant')).to.equal('flat');
20
+ expect(el.getAttribute('icon')).to.equal(iconName);
21
+ expect(el.hasAttribute('grayscale')).to.be.true;
22
+ expect(el.getAttribute('text')).to.equal('Test state text');
23
+ expect(el.getAttribute('sub-text')).to.equal('Test sub text');
24
+ });
25
+ it('should render different sizes correctly', async () => {
26
+ const sizes = ['sm', 'md', 'lg'];
27
+ for (const size of sizes) {
28
+ const el = await fixture(html `<nile-empty-state size="${size}"></nile-empty-state>`);
29
+ const container = el.shadowRoot.querySelector('.empty-state');
30
+ expect(container.classList.contains(`empty-state--${size}`)).to.be.true;
31
+ }
32
+ });
33
+ it('should render different variants correctly', async () => {
34
+ const variants = ['flat', 'content', 'tonal'];
35
+ for (const variant of variants) {
36
+ const el = await fixture(html `<nile-empty-state variant="${variant}"></nile-empty-state>`);
37
+ const container = el.shadowRoot.querySelector(`.empty-state__body--${variant}`);
38
+ expect(container).to.exist;
39
+ }
40
+ });
41
+ it('should render text properties correctly', async () => {
42
+ const sampleText = 'Custom Text';
43
+ const sampleSubText = "Custom SubText";
44
+ const el = await fixture(html `
45
+ <nile-empty-state text=${sampleText} sub-text=${sampleSubText}></nile-empty-state>
46
+ `);
47
+ const textEl = el.shadowRoot.querySelector('.empty-state__text');
48
+ const subTextEl = el.shadowRoot.querySelector('.empty-state__subtext');
49
+ expect(textEl.textContent).to.equal(sampleText);
50
+ expect(subTextEl.textContent).to.equal(sampleSubText);
51
+ });
52
+ it('should render slot content', async () => {
53
+ const el = await fixture(html `
54
+ <nile-empty-state>
55
+ <div class="slot-content">Slot Content</div>
56
+ </nile-empty-state>
57
+ `);
58
+ const slotContent = el.querySelector('.slot-content');
59
+ expect(slotContent).to.exist;
60
+ expect(slotContent.textContent).to.equal('Slot Content');
61
+ });
62
+ });
63
+ //# sourceMappingURL=nile-empty-state.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-empty-state.test.js","sourceRoot":"","sources":["../../../src/nile-empty-state/nile-empty-state.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAC,IAAI,EAAC,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,oBAAoB,CAAC;AAG5B,QAAQ,CAAC,gBAAgB,EAAC,GAAE,EAAE;IAC1B,EAAE,CAAC,2CAA2C,EAAC,KAAK,IAAG,EAAE;QACrD,MAAM,EAAE,GAAC,MAAM,OAAO,CAAiB,IAAI,CAAA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B,MAAM,aAAa,GAAC,gBAAgB,CAAA;QACpC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAiB,IAAI,CAAA;mCAClB,UAAU,aAAa,aAAa;SAC9D,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,oBAAoB,CAAE,CAAC;QACnE,MAAM,SAAS,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,uBAAuB,CAAE,CAAC;QACzE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAChD,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,EAAE,GAAG,MAAM,OAAO,CAAiB,IAAI,CAAA;;;;SAI5C,CAAC,CAAC;QACH,MAAM,WAAW,GAAG,EAAE,CAAC,aAAa,CAAC,eAAe,CAAE,CAAC;QACvD,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC7B,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACT,CAAC,CAAC,CAAA","sourcesContent":["import { fixture,html,expect } from \"@open-wc/testing\";\nimport './nile-empty-state';\nimport { NileEmptyState } from \"./nile-empty-state\";\n\ndescribe('NileEmptyState',()=>{\n it('renders correctly with default properties',async ()=>{\n const el=await fixture<NileEmptyState>(html`<nile-empty-state></nile-empty-state>`)\n expect(el.size).to.equal('md');\n expect(el.variant).to.equal('tonal');\n expect(el.icon).to.equal('error');\n expect(el.grayscale).to.be.false;\n expect(el.text).to.equal('Empty State');\n expect(el.subText).to.equal('No Data');\n })\n\n it('should reflect properties to attributes', async () => {\n const iconName=\"action\"\n const el = await fixture<NileEmptyState>(html`\n <nile-empty-state size=\"sm\" variant=\"flat\" icon=${iconName} grayscale text=\"Test state text\" sub-text=\"Test sub text\"></nile-empty-state>\n `);\n expect(el.getAttribute('size')).to.equal('sm');\n expect(el.getAttribute('variant')).to.equal('flat');\n expect(el.getAttribute('icon')).to.equal(iconName);\n expect(el.hasAttribute('grayscale')).to.be.true;\n expect(el.getAttribute('text')).to.equal('Test state text');\n expect(el.getAttribute('sub-text')).to.equal('Test sub text');\n });\n\n it('should render different sizes correctly', async () => {\n const sizes:Array<'sm' | 'md' | 'lg' >= ['sm', 'md', 'lg'];\n for (const size of sizes) {\n const el = await fixture<NileEmptyState>(html`<nile-empty-state size=\"${size}\"></nile-empty-state>`);\n const container = el.shadowRoot!.querySelector('.empty-state')!;\n expect(container.classList.contains(`empty-state--${size}`)).to.be.true;\n }\n });\n\n it('should render different variants correctly', async () => {\n const variants :Array<'flat' | 'content' | 'tonal' >= ['flat', 'content', 'tonal'];\n for (const variant of variants) {\n const el = await fixture<NileEmptyState>(html`<nile-empty-state variant=\"${variant}\"></nile-empty-state>`);\n const container = el.shadowRoot!.querySelector(`.empty-state__body--${variant}`)!;\n expect(container).to.exist;\n }\n });\n\n it('should render text properties correctly', async () => {\n const sampleText='Custom Text'\n const sampleSubText=\"Custom SubText\"\n const el = await fixture<NileEmptyState>(html`\n <nile-empty-state text=${sampleText} sub-text=${sampleSubText}></nile-empty-state>\n `);\n const textEl = el.shadowRoot!.querySelector('.empty-state__text')!;\n const subTextEl = el.shadowRoot!.querySelector('.empty-state__subtext')!;\n expect(textEl.textContent).to.equal(sampleText);\n expect(subTextEl.textContent).to.equal(sampleSubText);\n });\n\n it('should render slot content', async () => {\n const el = await fixture<NileEmptyState>(html`\n <nile-empty-state>\n <div class=\"slot-content\">Slot Content</div>\n </nile-empty-state>\n `);\n const slotContent = el.querySelector('.slot-content')!;\n expect(slotContent).to.exist;\n expect(slotContent.textContent).to.equal('Slot Content');\n });\n})"]}
@@ -0,0 +1 @@
1
+ import './nile-hero';
@@ -0,0 +1,42 @@
1
+ import { fixture, html, expect } from '@open-wc/testing';
2
+ import './nile-hero';
3
+ describe('NileHero', () => {
4
+ it('renders correctly with default properties', async () => {
5
+ const el = await fixture(html `
6
+ <nile-hero icon="error" hero-text="Test Hero">
7
+ <nile-page-header
8
+ heading="I am heading"
9
+ sub-heading="I am subheading"
10
+ ></nile-page-header>
11
+ </nile-hero>`);
12
+ expect(el.getAttribute('icon')).to.equal('error');
13
+ expect(el.hasAttribute('collapse')).to.be.false;
14
+ expect(el.getAttribute('img-src')).to.equal('');
15
+ expect(el.getAttribute('hero-text')).to.equal('Test Hero');
16
+ expect(el).shadowDom.to.equalSnapshot();
17
+ });
18
+ it('checks for collapsed state', async () => {
19
+ const el = await fixture(html `<nile-hero></nile-hero>`);
20
+ el.collapse = true;
21
+ await el.updateComplete;
22
+ expect(el.collapse).to.be.true;
23
+ el.collapse = true;
24
+ await el.updateComplete;
25
+ const heroContainer = el.shadowRoot?.querySelector('.hero__container');
26
+ expect(heroContainer?.classList.contains('hero__container--collapsed')).to.be.true;
27
+ });
28
+ it('should render slot content', async () => {
29
+ const el = await fixture(html `
30
+ <nile-hero>
31
+ <nile-page-header
32
+ heading="I am heading"
33
+ sub-heading="I am subheading"
34
+ ></nile-page-header>
35
+ </nile-hero>
36
+ `);
37
+ await el.updateComplete;
38
+ const NilePageHeader = el.querySelector('nile-page-header');
39
+ expect(NilePageHeader).to.exist;
40
+ });
41
+ });
42
+ //# sourceMappingURL=nile-hero.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-hero.test.js","sourceRoot":"","sources":["../../../src/nile-hero/nile-hero.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AACnE,OAAO,aAAa,CAAC;AAGrB,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,E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CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,EAAE,GAAG,MAAM,OAAO,CAAW,IAAI,CAAA;;;;;;;KAOtC,CAAC,CAAC;QACH,MAAM,EAAE,CAAC,cAAc,CAAC;QACxB,MAAM,cAAc,GAAG,EAAE,CAAC,aAAa,CAAC,kBAAkB,CAAE,CAAC;QAC7D,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAA","sourcesContent":["import { fixture, html, expect, oneEvent } from '@open-wc/testing';\nimport './nile-hero';\nimport { NileHero } from './nile-hero';\n\ndescribe('NileHero', () => {\n it('renders correctly with default properties', async () => {\n const el = await fixture<NileHero>(html`\n\t\t<nile-hero icon=\"error\" hero-text=\"Test Hero\">\n <nile-page-header\n heading=\"I am heading\"\n sub-heading=\"I am subheading\"\n ></nile-page-header>\n </nile-hero>`);\n expect(el.getAttribute('icon')).to.equal('error');\n expect(el.hasAttribute('collapse')).to.be.false;\n expect(el.getAttribute('img-src')).to.equal('');\n expect(el.getAttribute('hero-text')).to.equal('Test Hero');\n expect(el).shadowDom.to.equalSnapshot();\n });\n\n it('checks for collapsed state', async () => {\n const el = await fixture<NileHero>(html`<nile-hero></nile-hero>`);\n el.collapse = true;\n await el.updateComplete;\n expect(el.collapse).to.be.true;\n el.collapse=true;\n await el.updateComplete;\n const heroContainer=el.shadowRoot?.querySelector('.hero__container');\n expect(heroContainer?.classList.contains('hero__container--collapsed')).to.be.true;\n });\n\n it('should render slot content', async () => {\n const el = await fixture<NileHero>(html`\n <nile-hero>\n <nile-page-header\n heading=\"I am heading\"\n sub-heading=\"I am subheading\"\n ></nile-page-header>\n </nile-hero>\n `);\n await el.updateComplete;\n const NilePageHeader = el.querySelector('nile-page-header')!;\n expect(NilePageHeader).to.exist;\n });\n})\n"]}
@@ -0,0 +1 @@
1
+ export { NileSplitPanel } from './nile-split-panel';
@@ -0,0 +1,2 @@
1
+ export { NileSplitPanel } from './nile-split-panel';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nile-split-panel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { NileSplitPanel } from './nile-split-panel';"]}
@@ -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
+ * SplitPanel 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,99 @@
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
+ * SplitPanel CSS
10
+ */
11
+ export const styles = css `
12
+ :host *,
13
+ :host *::before,
14
+ :host *::after {
15
+ box-sizing: inherit;
16
+ }
17
+
18
+ [hidden] {
19
+ display: none !important;
20
+ }
21
+
22
+ :host {
23
+ box-sizing: border-box;
24
+ --divider-width: 4px;
25
+ --divider-hit-area: 12px;
26
+ --min: 0%;
27
+ --max: 100%;
28
+
29
+ display: grid;
30
+ }
31
+
32
+ .start,
33
+ .end {
34
+ overflow: hidden;
35
+ }
36
+
37
+ .divider {
38
+ flex: 0 0 var(--divider-width);
39
+ display: flex;
40
+ position: relative;
41
+ align-items: center;
42
+ justify-content: center;
43
+ background-color: var(--nile-colors-neutral-100);
44
+ color: var(--nile-colors-dark-900);
45
+ z-index: 1;
46
+ }
47
+
48
+ .divider:focus {
49
+ outline: none;
50
+ }
51
+
52
+ :host(:not([disabled])) .divider:focus-visible {
53
+ background-color: var(--nile-colors-blue-500);
54
+ color: var(--nile-colors-white-base);
55
+ }
56
+
57
+ :host([disabled]) .divider {
58
+ cursor: not-allowed;
59
+ }
60
+
61
+ /* Horizontal */
62
+ :host(:not([vertical], [disabled])) .divider {
63
+ cursor: col-resize;
64
+ }
65
+
66
+ :host(:not([vertical])) .divider::after {
67
+ display: flex;
68
+ content: '';
69
+ position: absolute;
70
+ height: 100%;
71
+ left: calc(var(--divider-hit-area) / -2 + var(--divider-width) / 2);
72
+ width: var(--divider-hit-area);
73
+ }
74
+
75
+ /* Vertical */
76
+ :host([vertical]) {
77
+ flex-direction: column;
78
+ }
79
+
80
+ :host([vertical]:not([disabled])) .divider {
81
+ cursor: row-resize;
82
+ }
83
+
84
+ :host([vertical]) .divider::after {
85
+ content: '';
86
+ position: absolute;
87
+ width: 100%;
88
+ top: calc(var(--divider-hit-area) / -2 + var(--divider-width) / 2);
89
+ height: var(--divider-hit-area);
90
+ }
91
+
92
+ @media (forced-colors: active) {
93
+ .divider {
94
+ outline: solid 1px transparent;
95
+ }
96
+ }
97
+ `;
98
+ export default [styles];
99
+ //# sourceMappingURL=nile-split-panel.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-split-panel.css.js","sourceRoot":"","sources":["../../../src/nile-split-panel/nile-split-panel.css.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAEF,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFxB,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 * SplitPanel CSS\n */\nexport const styles = css`\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit;\n }\n\n [hidden] {\n display: none !important;\n }\n\n :host {\n box-sizing: border-box;\n --divider-width: 4px;\n --divider-hit-area: 12px;\n --min: 0%;\n --max: 100%;\n\n display: grid;\n }\n\n .start,\n .end {\n overflow: hidden;\n }\n\n .divider {\n flex: 0 0 var(--divider-width);\n display: flex;\n position: relative;\n align-items: center;\n justify-content: center;\n background-color: var(--nile-colors-neutral-100);\n color: var(--nile-colors-dark-900);\n z-index: 1;\n }\n\n .divider:focus {\n outline: none;\n }\n\n :host(:not([disabled])) .divider:focus-visible {\n background-color: var(--nile-colors-blue-500);\n color: var(--nile-colors-white-base);\n }\n\n :host([disabled]) .divider {\n cursor: not-allowed;\n }\n\n /* Horizontal */\n :host(:not([vertical], [disabled])) .divider {\n cursor: col-resize;\n }\n\n :host(:not([vertical])) .divider::after {\n display: flex;\n content: '';\n position: absolute;\n height: 100%;\n left: calc(var(--divider-hit-area) / -2 + var(--divider-width) / 2);\n width: var(--divider-hit-area);\n }\n\n /* Vertical */\n :host([vertical]) {\n flex-direction: column;\n }\n\n :host([vertical]:not([disabled])) .divider {\n cursor: row-resize;\n }\n\n :host([vertical]) .divider::after {\n content: '';\n position: absolute;\n width: 100%;\n top: calc(var(--divider-hit-area) / -2 + var(--divider-width) / 2);\n height: var(--divider-hit-area);\n }\n\n @media (forced-colors: active) {\n .divider {\n outline: solid 1px transparent;\n }\n }\n`;\n\nexport default [styles];\n"]}
@@ -0,0 +1,78 @@
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 type { CSSResultGroup } from 'lit';
10
+ /**
11
+ * @summary Split panels display two adjacent panels, allowing the user to reposition them.
12
+ *
13
+ * @event nile-reposition - Emitted when the divider's position changes.
14
+ *
15
+ * @slot start - Content to place in the start panel.
16
+ * @slot end - Content to place in the end panel.
17
+ * @slot divider - The divider. Useful for slotting in a custom icon that renders as a handle.
18
+ *
19
+ * @csspart start - The start panel.
20
+ * @csspart end - The end panel.
21
+ * @csspart panel - Targets both the start and end panels.
22
+ * @csspart divider - The divider that separates the start and end panels.
23
+ *
24
+ * @cssproperty [--divider-width=4px] - The width of the visible divider.
25
+ * @cssproperty [--divider-hit-area=12px] - The invisible region around the divider where dragging can occur. This is
26
+ * usually wider than the divider to facilitate easier dragging.
27
+ * @cssproperty [--min=0] - The minimum allowed size of the primary panel.
28
+ * @cssproperty [--max=100%] - The maximum allowed size of the primary panel.
29
+ */
30
+ export declare class NileSplitPanel extends NileElement {
31
+ static styles: CSSResultGroup;
32
+ private cachedPositionInPixels;
33
+ private resizeObserver;
34
+ private size;
35
+ divider: HTMLElement;
36
+ /**
37
+ * The current position of the divider from the primary panel's edge as a percentage 0-100. Defaults to 50% of the
38
+ * container's initial size.
39
+ */
40
+ position: number;
41
+ /** The current position of the divider from the primary panel's edge in pixels. */
42
+ positionInPixels: number;
43
+ /** Draws the split panel in a vertical orientation with the start and end panels stacked. */
44
+ vertical: boolean;
45
+ /** Disables resizing. Note that the position may still change as a result of resizing the host element. */
46
+ disabled: boolean;
47
+ /**
48
+ * If no primary panel is designated, both panels will resize proportionally when the host element is resized. If a
49
+ * primary panel is designated, it will maintain its size and the other panel will grow or shrink as needed when the
50
+ * host element is resized.
51
+ */
52
+ primary?: 'start' | 'end';
53
+ /**
54
+ * One or more space-separated values at which the divider should snap. Values can be in pixels or percentages, e.g.
55
+ * `"100px 50%"`.
56
+ */
57
+ snap?: string;
58
+ /** How close the divider must be to a snap point until snapping occurs. */
59
+ snapThreshold: number;
60
+ connectedCallback(): void;
61
+ disconnectedCallback(): void;
62
+ private detectSize;
63
+ private percentageToPixels;
64
+ private pixelsToPercentage;
65
+ private handleDrag;
66
+ private handleKeyDown;
67
+ private handleResize;
68
+ handlePositionChange(): void;
69
+ handlePositionInPixelsChange(): void;
70
+ handleVerticalChange(): void;
71
+ render(): TemplateResult<1>;
72
+ }
73
+ export default NileSplitPanel;
74
+ declare global {
75
+ interface HTMLElementTagNameMap {
76
+ 'nile-split-panel': NileSplitPanel;
77
+ }
78
+ }
@@ -0,0 +1,251 @@
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 { styles } from './nile-split-panel.css';
9
+ import NileElement from '../internal/nile-element';
10
+ import { clamp } from '../internal/math';
11
+ import { customElement, property, query } from 'lit/decorators.js';
12
+ import { drag } from '../internal/drag';
13
+ import { html } from 'lit';
14
+ import { ifDefined } from 'lit/directives/if-defined.js';
15
+ import { watch } from '../internal/watch';
16
+ /**
17
+ * @summary Split panels display two adjacent panels, allowing the user to reposition them.
18
+ *
19
+ * @event nile-reposition - Emitted when the divider's position changes.
20
+ *
21
+ * @slot start - Content to place in the start panel.
22
+ * @slot end - Content to place in the end panel.
23
+ * @slot divider - The divider. Useful for slotting in a custom icon that renders as a handle.
24
+ *
25
+ * @csspart start - The start panel.
26
+ * @csspart end - The end panel.
27
+ * @csspart panel - Targets both the start and end panels.
28
+ * @csspart divider - The divider that separates the start and end panels.
29
+ *
30
+ * @cssproperty [--divider-width=4px] - The width of the visible divider.
31
+ * @cssproperty [--divider-hit-area=12px] - The invisible region around the divider where dragging can occur. This is
32
+ * usually wider than the divider to facilitate easier dragging.
33
+ * @cssproperty [--min=0] - The minimum allowed size of the primary panel.
34
+ * @cssproperty [--max=100%] - The maximum allowed size of the primary panel.
35
+ */
36
+ let NileSplitPanel = class NileSplitPanel extends NileElement {
37
+ constructor() {
38
+ super(...arguments);
39
+ /**
40
+ * The current position of the divider from the primary panel's edge as a percentage 0-100. Defaults to 50% of the
41
+ * container's initial size.
42
+ */
43
+ this.position = 50;
44
+ /** Draws the split panel in a vertical orientation with the start and end panels stacked. */
45
+ this.vertical = false;
46
+ /** Disables resizing. Note that the position may still change as a result of resizing the host element. */
47
+ this.disabled = false;
48
+ /** How close the divider must be to a snap point until snapping occurs. */
49
+ this.snapThreshold = 12;
50
+ }
51
+ connectedCallback() {
52
+ super.connectedCallback();
53
+ this.resizeObserver = new ResizeObserver(entries => this.handleResize(entries));
54
+ this.updateComplete.then(() => this.resizeObserver.observe(this));
55
+ this.detectSize();
56
+ this.cachedPositionInPixels = this.percentageToPixels(this.position);
57
+ }
58
+ disconnectedCallback() {
59
+ super.disconnectedCallback();
60
+ this.resizeObserver.unobserve(this);
61
+ }
62
+ detectSize() {
63
+ const { width, height } = this.getBoundingClientRect();
64
+ this.size = this.vertical ? height : width;
65
+ }
66
+ percentageToPixels(value) {
67
+ return this.size * (value / 100);
68
+ }
69
+ pixelsToPercentage(value) {
70
+ return (value / this.size) * 100;
71
+ }
72
+ handleDrag(event) {
73
+ const isRtl = false;
74
+ if (this.disabled) {
75
+ return;
76
+ }
77
+ // Prevent text selection when dragging
78
+ if (event.cancelable) {
79
+ event.preventDefault();
80
+ }
81
+ drag(this, {
82
+ onMove: (x, y) => {
83
+ let newPositionInPixels = this.vertical ? y : x;
84
+ // Flip for end panels
85
+ if (this.primary === 'end') {
86
+ newPositionInPixels = this.size - newPositionInPixels;
87
+ }
88
+ // Check snap points
89
+ if (this.snap) {
90
+ const snaps = this.snap.split(' ');
91
+ snaps.forEach(value => {
92
+ let snapPoint;
93
+ if (value.endsWith('%')) {
94
+ snapPoint = this.size * (parseFloat(value) / 100);
95
+ }
96
+ else {
97
+ snapPoint = parseFloat(value);
98
+ }
99
+ if (isRtl && !this.vertical) {
100
+ snapPoint = this.size - snapPoint;
101
+ }
102
+ if (newPositionInPixels >= snapPoint - this.snapThreshold &&
103
+ newPositionInPixels <= snapPoint + this.snapThreshold) {
104
+ newPositionInPixels = snapPoint;
105
+ }
106
+ });
107
+ }
108
+ this.position = clamp(this.pixelsToPercentage(newPositionInPixels), 0, 100);
109
+ },
110
+ initialEvent: event
111
+ });
112
+ }
113
+ handleKeyDown(event) {
114
+ if (this.disabled) {
115
+ return;
116
+ }
117
+ if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) {
118
+ let newPosition = this.position;
119
+ const incr = (event.shiftKey ? 10 : 1) * (this.primary === 'end' ? -1 : 1);
120
+ event.preventDefault();
121
+ if ((event.key === 'ArrowLeft' && !this.vertical) || (event.key === 'ArrowUp' && this.vertical)) {
122
+ newPosition -= incr;
123
+ }
124
+ if ((event.key === 'ArrowRight' && !this.vertical) || (event.key === 'ArrowDown' && this.vertical)) {
125
+ newPosition += incr;
126
+ }
127
+ if (event.key === 'Home') {
128
+ newPosition = this.primary === 'end' ? 100 : 0;
129
+ }
130
+ if (event.key === 'End') {
131
+ newPosition = this.primary === 'end' ? 0 : 100;
132
+ }
133
+ this.position = clamp(newPosition, 0, 100);
134
+ }
135
+ }
136
+ handleResize(entries) {
137
+ const { width, height } = entries[0].contentRect;
138
+ this.size = this.vertical ? height : width;
139
+ // Resize when a primary panel is set
140
+ if (this.primary) {
141
+ this.position = this.pixelsToPercentage(this.cachedPositionInPixels);
142
+ }
143
+ }
144
+ handlePositionChange() {
145
+ this.cachedPositionInPixels = this.percentageToPixels(this.position);
146
+ this.positionInPixels = this.percentageToPixels(this.position);
147
+ this.emit('nile-reposition');
148
+ }
149
+ handlePositionInPixelsChange() {
150
+ this.position = this.pixelsToPercentage(this.positionInPixels);
151
+ }
152
+ handleVerticalChange() {
153
+ this.detectSize();
154
+ }
155
+ render() {
156
+ const gridTemplate = this.vertical ? 'gridTemplateRows' : 'gridTemplateColumns';
157
+ const gridTemplateAlt = this.vertical ? 'gridTemplateColumns' : 'gridTemplateRows';
158
+ const isRtl = false;
159
+ const primary = `
160
+ clamp(
161
+ 0%,
162
+ clamp(
163
+ var(--min),
164
+ ${this.position}% - var(--divider-width) / 2,
165
+ var(--max)
166
+ ),
167
+ calc(100% - var(--divider-width))
168
+ )
169
+ `;
170
+ const secondary = 'auto';
171
+ if (this.primary === 'end') {
172
+ if (isRtl && !this.vertical) {
173
+ this.style[gridTemplate] = `${primary} var(--divider-width) ${secondary}`;
174
+ }
175
+ else {
176
+ this.style[gridTemplate] = `${secondary} var(--divider-width) ${primary}`;
177
+ }
178
+ }
179
+ else {
180
+ if (isRtl && !this.vertical) {
181
+ this.style[gridTemplate] = `${secondary} var(--divider-width) ${primary}`;
182
+ }
183
+ else {
184
+ this.style[gridTemplate] = `${primary} var(--divider-width) ${secondary}`;
185
+ }
186
+ }
187
+ // Unset the alt grid template property
188
+ this.style[gridTemplateAlt] = '';
189
+ return html `
190
+ <slot name="start" part="panel start" class="start"></slot>
191
+
192
+ <div
193
+ part="divider"
194
+ class="divider"
195
+ tabindex=${ifDefined(this.disabled ? undefined : '0')}
196
+ role="separator"
197
+ aria-valuenow=${this.position}
198
+ aria-valuemin="0"
199
+ aria-valuemax="100"
200
+ aria-label="resize"
201
+ @keydown=${this.handleKeyDown}
202
+ @mousedown=${this.handleDrag}
203
+ @touchstart=${this.handleDrag}
204
+ >
205
+ <slot name="divider"></slot>
206
+ </div>
207
+
208
+ <slot name="end" part="panel end" class="end"></slot>
209
+ `;
210
+ }
211
+ };
212
+ NileSplitPanel.styles = styles;
213
+ __decorate([
214
+ query('.divider')
215
+ ], NileSplitPanel.prototype, "divider", void 0);
216
+ __decorate([
217
+ property({ type: Number, reflect: true })
218
+ ], NileSplitPanel.prototype, "position", void 0);
219
+ __decorate([
220
+ property({ attribute: 'position-in-pixels', type: Number })
221
+ ], NileSplitPanel.prototype, "positionInPixels", void 0);
222
+ __decorate([
223
+ property({ type: Boolean, reflect: true })
224
+ ], NileSplitPanel.prototype, "vertical", void 0);
225
+ __decorate([
226
+ property({ type: Boolean, reflect: true })
227
+ ], NileSplitPanel.prototype, "disabled", void 0);
228
+ __decorate([
229
+ property()
230
+ ], NileSplitPanel.prototype, "primary", void 0);
231
+ __decorate([
232
+ property()
233
+ ], NileSplitPanel.prototype, "snap", void 0);
234
+ __decorate([
235
+ property({ type: Number, attribute: 'snap-threshold' })
236
+ ], NileSplitPanel.prototype, "snapThreshold", void 0);
237
+ __decorate([
238
+ watch('position')
239
+ ], NileSplitPanel.prototype, "handlePositionChange", null);
240
+ __decorate([
241
+ watch('positionInPixels')
242
+ ], NileSplitPanel.prototype, "handlePositionInPixelsChange", null);
243
+ __decorate([
244
+ watch('vertical')
245
+ ], NileSplitPanel.prototype, "handleVerticalChange", null);
246
+ NileSplitPanel = __decorate([
247
+ customElement('nile-split-panel')
248
+ ], NileSplitPanel);
249
+ export { NileSplitPanel };
250
+ export default NileSplitPanel;
251
+ //# sourceMappingURL=nile-split-panel.js.map