@aquera/nile-elements 2.0.19 → 2.0.21
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/README.md +8 -0
- package/demo/index.js +0 -1
- package/dist/floating-ui.dom-9df9f37b.cjs.js +2 -0
- package/dist/floating-ui.dom-9df9f37b.cjs.js.map +1 -0
- package/dist/floating-ui.dom-c4ea6a32.esm.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1326 -523
- package/dist/nile-auto-complete/index.cjs.js +1 -1
- package/dist/nile-auto-complete/index.esm.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.esm.js +1 -1
- package/dist/nile-auto-complete/portal-manager.cjs.js +1 -1
- package/dist/nile-auto-complete/portal-manager.esm.js +1 -1
- package/dist/nile-badge/index.cjs.js +1 -1
- package/dist/nile-badge/index.esm.js +1 -1
- package/dist/nile-badge/nile-badge.cjs.js +1 -1
- package/dist/nile-badge/nile-badge.cjs.js.map +1 -1
- package/dist/nile-badge/nile-badge.css.cjs.js +1 -1
- package/dist/nile-badge/nile-badge.css.cjs.js.map +1 -1
- package/dist/nile-badge/nile-badge.css.esm.js +24 -3
- package/dist/nile-badge/nile-badge.esm.js +5 -3
- package/dist/nile-button/nile-button.cjs.js +1 -1
- package/dist/nile-button/nile-button.cjs.js.map +1 -1
- 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 +46 -9
- package/dist/nile-button/nile-button.esm.js +6 -6
- package/dist/nile-calendar/index.cjs.js +1 -1
- package/dist/nile-calendar/index.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.cjs.js +2 -1
- package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.css.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.css.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.css.esm.js +357 -2
- package/dist/nile-calendar/nile-calendar.esm.js +365 -41
- package/dist/nile-calendar/timezones.cjs.js +1 -1
- package/dist/nile-calendar/timezones.cjs.js.map +1 -1
- package/dist/nile-calendar/timezones.esm.js +1 -1
- package/dist/nile-color-picker/index.cjs.js +1 -1
- package/dist/nile-color-picker/index.esm.js +1 -1
- package/dist/nile-color-picker/nile-color-picker.cjs.js +1 -1
- package/dist/nile-color-picker/nile-color-picker.esm.js +1 -1
- package/dist/nile-combobox/index.cjs.js +1 -1
- package/dist/nile-combobox/index.esm.js +1 -1
- package/dist/nile-combobox/nile-combobox.cjs.js +1 -1
- package/dist/nile-combobox/nile-combobox.esm.js +1 -1
- package/dist/nile-combobox/portal-manager.cjs.js +1 -1
- package/dist/nile-combobox/portal-manager.esm.js +1 -1
- package/dist/nile-date-time-picker/index.cjs.js +2 -0
- package/dist/nile-date-time-picker/index.cjs.js.map +1 -0
- package/dist/nile-date-time-picker/index.esm.js +1 -0
- package/dist/nile-date-time-picker/nile-date-time-picker.cjs.js +2 -0
- package/dist/nile-date-time-picker/nile-date-time-picker.cjs.js.map +1 -0
- package/dist/nile-date-time-picker/nile-date-time-picker.css.cjs.js +2 -0
- package/dist/nile-date-time-picker/nile-date-time-picker.css.cjs.js.map +1 -0
- package/dist/nile-date-time-picker/nile-date-time-picker.css.esm.js +13 -0
- package/dist/nile-date-time-picker/nile-date-time-picker.esm.js +53 -0
- package/dist/nile-dropdown/index.cjs.js +1 -1
- package/dist/nile-dropdown/index.esm.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.cjs.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.esm.js +1 -1
- package/dist/nile-dropdown/portal-manager.cjs.js +1 -1
- package/dist/nile-dropdown/portal-manager.esm.js +1 -1
- package/dist/nile-markdown-editor/index.cjs.js +1 -1
- package/dist/nile-markdown-editor/index.esm.js +1 -1
- package/dist/nile-markdown-editor/nile-markdown-editor.cjs.js +1 -1
- package/dist/nile-markdown-editor/nile-markdown-editor.esm.js +1 -1
- package/dist/nile-popover/index.cjs.js +1 -1
- package/dist/nile-popover/index.esm.js +1 -1
- package/dist/nile-popover/nile-popover.cjs.js +1 -1
- package/dist/nile-popover/nile-popover.esm.js +1 -1
- package/dist/nile-popover/portal-manager.cjs.js +1 -1
- package/dist/nile-popover/portal-manager.esm.js +1 -1
- package/dist/nile-popup/index.cjs.js +1 -1
- package/dist/nile-popup/index.esm.js +1 -1
- package/dist/nile-popup/nile-popup.cjs.js +1 -1
- package/dist/nile-popup/nile-popup.esm.js +1 -1
- package/dist/nile-select/index.cjs.js +1 -1
- package/dist/nile-select/index.esm.js +1 -1
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.esm.js +1 -1
- package/dist/nile-select/portal-manager.cjs.js +1 -1
- package/dist/nile-select/portal-manager.esm.js +1 -1
- package/dist/nile-side-bar-action/index.cjs.js +1 -1
- package/dist/nile-side-bar-action/index.esm.js +1 -1
- package/dist/nile-side-bar-action/nile-side-bar-action.cjs.js +1 -1
- package/dist/nile-side-bar-action/nile-side-bar-action.esm.js +1 -1
- package/dist/nile-side-bar-action/portal-manager.cjs.js +1 -1
- package/dist/nile-side-bar-action/portal-manager.esm.js +1 -1
- package/dist/nile-tooltip/index.cjs.js +1 -1
- package/dist/nile-tooltip/index.esm.js +1 -1
- package/dist/nile-tooltip/nile-tooltip.cjs.js +1 -1
- package/dist/nile-tooltip/nile-tooltip.esm.js +1 -1
- package/dist/nile-virtual-select/index.cjs.js +1 -1
- package/dist/nile-virtual-select/index.esm.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +1 -1
- package/dist/nile-virtual-select/portal-manager.cjs.js +1 -1
- package/dist/nile-virtual-select/portal-manager.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.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-badge/nile-badge.css.js +24 -3
- package/dist/src/nile-badge/nile-badge.css.js.map +1 -1
- package/dist/src/nile-badge/nile-badge.d.ts +7 -4
- package/dist/src/nile-badge/nile-badge.js +22 -5
- package/dist/src/nile-badge/nile-badge.js.map +1 -1
- package/dist/src/nile-badge/nile-badge.test.js +88 -0
- package/dist/src/nile-badge/nile-badge.test.js.map +1 -1
- package/dist/src/nile-button/nile-button.css.js +46 -9
- package/dist/src/nile-button/nile-button.css.js.map +1 -1
- package/dist/src/nile-button/nile-button.d.ts +2 -2
- package/dist/src/nile-button/nile-button.js +13 -5
- package/dist/src/nile-button/nile-button.js.map +1 -1
- package/dist/src/nile-button/nile-button.test.js +140 -2
- package/dist/src/nile-button/nile-button.test.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.css.js +355 -0
- package/dist/src/nile-calendar/nile-calendar.css.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.d.ts +175 -0
- package/dist/src/nile-calendar/nile-calendar.js +1726 -26
- package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.test.d.ts +1 -0
- package/dist/src/nile-calendar/nile-calendar.test.js +3580 -0
- package/dist/src/nile-calendar/nile-calendar.test.js.map +1 -1
- package/dist/src/nile-calendar/timezones.d.ts +21 -0
- package/dist/src/nile-calendar/timezones.js +49 -0
- package/dist/src/nile-calendar/timezones.js.map +1 -1
- package/dist/src/nile-date-time-picker/index.d.ts +1 -0
- package/dist/src/nile-date-time-picker/index.js +2 -0
- package/dist/src/nile-date-time-picker/index.js.map +1 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.css.d.ts +11 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.css.js +49 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.css.js.map +1 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.d.ts +173 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.js +1270 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.js.map +1 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-1.test.d.ts +47 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-1.test.js +578 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-1.test.js.map +1 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-2.test.d.ts +3 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-2.test.js +109 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-2.test.js.map +1 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-3.test.d.ts +3 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-3.test.js +356 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-3.test.js.map +1 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-4.test.d.ts +4 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-4.test.js +339 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-4.test.js.map +1 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.regressions.test.d.ts +3 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.regressions.test.js +1472 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.regressions.test.js.map +1 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.test-helpers.d.ts +103 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.test-helpers.js +331 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.test-helpers.js.map +1 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.test.d.ts +3 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.test.js +2783 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.test.js.map +1 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.year-handling.test.d.ts +3 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.year-handling.test.js +1440 -0
- package/dist/src/nile-date-time-picker/nile-date-time-picker.year-handling.test.js.map +1 -0
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/animation-registry.cjs.js +1 -1
- package/dist/utilities/animation-registry.cjs.js.map +1 -1
- package/dist/utilities/animation-registry.esm.js +1 -1
- package/package.json +4 -2
- package/rollup.config.js +1 -0
- package/scripts/component-metrics.mjs +145 -0
- package/scripts/coverage-report.mjs +96 -0
- package/scripts/merge-coverage.cjs +33 -0
- package/src/index.ts +1 -0
- package/src/nile-badge/nile-badge.css.ts +24 -3
- package/src/nile-badge/nile-badge.test.ts +102 -0
- package/src/nile-badge/nile-badge.ts +28 -5
- package/src/nile-button/nile-button.css.ts +46 -9
- package/src/nile-button/nile-button.test.ts +162 -2
- package/src/nile-button/nile-button.ts +13 -4
- package/src/nile-calendar/nile-calendar.css.ts +355 -0
- package/src/nile-calendar/nile-calendar.test.ts +3793 -0
- package/src/nile-calendar/nile-calendar.ts +1760 -28
- package/src/nile-calendar/timezones.ts +57 -0
- package/src/nile-date-time-picker/index.ts +1 -0
- package/src/nile-date-time-picker/nile-date-time-picker.css.ts +54 -0
- package/src/nile-date-time-picker/nile-date-time-picker.phases-1.test.ts +607 -0
- package/src/nile-date-time-picker/nile-date-time-picker.phases-2.test.ts +112 -0
- package/src/nile-date-time-picker/nile-date-time-picker.phases-3.test.ts +389 -0
- package/src/nile-date-time-picker/nile-date-time-picker.phases-4.test.ts +329 -0
- package/src/nile-date-time-picker/nile-date-time-picker.regressions.test.ts +1618 -0
- package/src/nile-date-time-picker/nile-date-time-picker.test-helpers.ts +381 -0
- package/src/nile-date-time-picker/nile-date-time-picker.test.ts +3116 -0
- package/src/nile-date-time-picker/nile-date-time-picker.ts +1153 -0
- package/src/nile-date-time-picker/nile-date-time-picker.year-handling.test.ts +1499 -0
- package/test-timings.json +41 -0
- package/vscode-html-custom-data.json +180 -7
- package/web-test-runner.config.mjs +72 -2
- package/dist/floating-ui.dom-007bbe96.cjs.js +0 -2
- package/dist/floating-ui.dom-007bbe96.cjs.js.map +0 -1
- package/dist/floating-ui.dom-cc9126da.esm.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register([],function(_export,_context){"use strict";var n,t;function o(
|
|
1
|
+
System.register([],function(_export,_context){"use strict";var n,t;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function o(n){return n!==null&&n!==void 0?n:{keyframes:[],options:{duration:0}};}function r(n,t){return"rtl"===t.toLowerCase()?{keyframes:n.rtlKeyframes||n.keyframes,options:n.options}:n;}function e(t,r){n.set(t,o(r));}function s(n,r,e){t.set(n,_objectSpread(_objectSpread({},t.get(n)),{},_defineProperty({},r,o(e))));}function a(o,e,s){var a=t.get(o);if(a!==null&&a!==void 0&&a[e])return r(a[e],s.dir);var i=n.get(e);return i?r(i,s.dir):{keyframes:[],options:{duration:0}};}_export({a:s,g:a,s:e});return{setters:[],execute:function execute(){n=new Map(),t=new WeakMap();}};});
|
|
2
2
|
//# sourceMappingURL=animation-registry.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation-registry.cjs.js","sources":["../../../src/utilities/animation-registry.ts"],"sourcesContent":["export interface ElementAnimation {\n keyframes: Keyframe[];\n rtlKeyframes?: Keyframe[];\n options?: KeyframeAnimationOptions;\n}\n\nexport interface ElementAnimationMap {\n [animationName: string]: ElementAnimation;\n}\n\nexport interface GetAnimationOptions {\n /**\n * The component's directionality. When set to \"rtl\", `rtlKeyframes` will be preferred over `keyframes` where\n * available using getAnimation().\n */\n dir: string;\n}\n\nconst defaultAnimationRegistry = new Map<string, ElementAnimation>();\nconst customAnimationRegistry = new WeakMap<Element, ElementAnimationMap>();\n\nfunction ensureAnimation(animation: ElementAnimation | null) {\n return animation ?? { keyframes: [], options: { duration: 0 } };\n}\n\n//\n// Given an ElementAnimation, this function returns a new ElementAnimation where the keyframes property reflects either\n// keyframes or rtlKeyframes depending on the specified directionality.\n//\nfunction getLogicalAnimation(animation: ElementAnimation, dir: string) {\n if (dir.toLowerCase() === 'rtl') {\n return {\n keyframes: animation.rtlKeyframes || animation.keyframes,\n options: animation.options\n };\n }\n\n return animation;\n}\n\n/**\n * Sets a default animation. Components should use the `name.animation` for primary animations and `name.part.animation`\n * for secondary animations, e.g. `dialog.show` and `dialog.overlay.show`. For modifiers, use `drawer.showTop`.\n */\nexport function setDefaultAnimation(animationName: string, animation: ElementAnimation | null) {\n defaultAnimationRegistry.set(animationName, ensureAnimation(animation));\n}\n\n/** Sets a custom animation for the specified element. */\nexport function setAnimation(el: Element, animationName: string, animation: ElementAnimation | null) {\n customAnimationRegistry.set(el, { ...customAnimationRegistry.get(el), [animationName]: ensureAnimation(animation) });\n}\n\n/** Gets an element's animation. Falls back to the default if no animation is found. */\nexport function getAnimation(el: Element, animationName: string, options: GetAnimationOptions) {\n const customAnimation = customAnimationRegistry.get(el);\n\n // Check for a custom animation\n if (customAnimation?.[animationName]) {\n return getLogicalAnimation(customAnimation[animationName], options.dir);\n }\n\n // Check for a default animation\n const defaultAnimation = defaultAnimationRegistry.get(animationName);\n if (defaultAnimation) {\n return getLogicalAnimation(defaultAnimation, options.dir);\n }\n\n // Fall back to an empty animation\n return {\n keyframes: [],\n options: { duration: 0 }\n };\n}\n"],"names":["
|
|
1
|
+
{"version":3,"file":"animation-registry.cjs.js","sources":["../../../src/utilities/animation-registry.ts"],"sourcesContent":["export interface ElementAnimation {\n keyframes: Keyframe[];\n rtlKeyframes?: Keyframe[];\n options?: KeyframeAnimationOptions;\n}\n\nexport interface ElementAnimationMap {\n [animationName: string]: ElementAnimation;\n}\n\nexport interface GetAnimationOptions {\n /**\n * The component's directionality. When set to \"rtl\", `rtlKeyframes` will be preferred over `keyframes` where\n * available using getAnimation().\n */\n dir: string;\n}\n\nconst defaultAnimationRegistry = new Map<string, ElementAnimation>();\nconst customAnimationRegistry = new WeakMap<Element, ElementAnimationMap>();\n\nfunction ensureAnimation(animation: ElementAnimation | null) {\n return animation ?? { keyframes: [], options: { duration: 0 } };\n}\n\n//\n// Given an ElementAnimation, this function returns a new ElementAnimation where the keyframes property reflects either\n// keyframes or rtlKeyframes depending on the specified directionality.\n//\nfunction getLogicalAnimation(animation: ElementAnimation, dir: string) {\n if (dir.toLowerCase() === 'rtl') {\n return {\n keyframes: animation.rtlKeyframes || animation.keyframes,\n options: animation.options\n };\n }\n\n return animation;\n}\n\n/**\n * Sets a default animation. Components should use the `name.animation` for primary animations and `name.part.animation`\n * for secondary animations, e.g. `dialog.show` and `dialog.overlay.show`. For modifiers, use `drawer.showTop`.\n */\nexport function setDefaultAnimation(animationName: string, animation: ElementAnimation | null) {\n defaultAnimationRegistry.set(animationName, ensureAnimation(animation));\n}\n\n/** Sets a custom animation for the specified element. */\nexport function setAnimation(el: Element, animationName: string, animation: ElementAnimation | null) {\n customAnimationRegistry.set(el, { ...customAnimationRegistry.get(el), [animationName]: ensureAnimation(animation) });\n}\n\n/** Gets an element's animation. Falls back to the default if no animation is found. */\nexport function getAnimation(el: Element, animationName: string, options: GetAnimationOptions) {\n const customAnimation = customAnimationRegistry.get(el);\n\n // Check for a custom animation\n if (customAnimation?.[animationName]) {\n return getLogicalAnimation(customAnimation[animationName], options.dir);\n }\n\n // Check for a default animation\n const defaultAnimation = defaultAnimationRegistry.get(animationName);\n if (defaultAnimation) {\n return getLogicalAnimation(defaultAnimation, options.dir);\n }\n\n // Fall back to an empty animation\n return {\n keyframes: [],\n options: { duration: 0 }\n };\n}\n"],"names":["ensureAnimation","animation","keyframes","options","duration","getLogicalAnimation","dir","toLowerCase","rtlKeyframes","setDefaultAnimation","animationName","defaultAnimationRegistry","set","setAnimation","el","customAnimationRegistry","get","getAnimation","customAnimation","defaultAnimation","Map","WeakMap"],"mappings":"+8CAqBA,QAASA,CAAAA,CAAgBC,CAAAA,CAAAA,CAAAA,CACvB,MAAOA,CAAAA,CAAAA,SAAAA,CAAAA,UAAAA,CAAAA,CAAa,CAAEC,SAAW,CAAA,EAAA,CAAIC,OAAS,CAAA,CAAEC,QAAU,CAAA,CAAA,CAAA,CAC5D,EAMA,QAASC,CAAAA,CAAAA,CAAoBJ,CAA6BK,CAAAA,CAAAA,CAAAA,CACxD,MAA0B,KAAA,GAAtBA,EAAIC,WACC,CAAA,CAAA,CAAA,CACLL,UAAWD,CAAUO,CAAAA,YAAAA,EAAgBP,EAAUC,SAC/CC,CAAAA,OAAAA,CAASF,CAAUE,CAAAA,OAAAA,CAAAA,CAIhBF,CACT,EAMgB,QAAAQ,CAAAA,CAAoBC,CAAAA,CAAAA,CAAuBT,CACzDU,CAAAA,CAAAA,CAAAA,CAAyBC,GAAIF,CAAAA,CAAAA,CAAeV,EAAgBC,CAC9D,CAAA,CAAA,UAGgBY,CAAAA,CAAAA,CAAaC,CAAaJ,CAAAA,CAAAA,CAAuBT,GAC/Dc,CAAwBH,CAAAA,GAAAA,CAAIE,iCAASC,CAAAA,CAAwBC,IAAIF,CAAKJ,CAAAA,KAAAA,eAAAA,IAACA,CAAgBV,CAAAA,CAAAA,CAAgBC,CACzG,CAAA,EAAA,CAAA,UAGgBgB,CAAAA,CAAaH,CAAAA,CAAAA,CAAaJ,CAAuBP,CAAAA,CAAAA,CAAAA,CAC/D,GAAMe,CAAAA,CAAAA,CAAkBH,EAAwBC,GAAIF,CAAAA,CAAAA,CAAAA,CAGpD,GAAII,CAAAA,SAAAA,CAAAA,WAAAA,CAAAA,CAAkBR,CACpB,CAAA,CAAA,MAAOL,CAAAA,EAAoBa,CAAgBR,CAAAA,CAAAA,CAAAA,CAAgBP,EAAQG,GAIrE,CAAA,CAAA,GAAMa,CAAAA,EAAmBR,CAAyBK,CAAAA,GAAAA,CAAIN,CACtD,CAAA,CAAA,MAAIS,CAAAA,CACKd,CAAAA,CAAAA,CAAoBc,EAAkBhB,CAAQG,CAAAA,GAAAA,CAAAA,CAIhD,CACLJ,SAAAA,CAAW,EACXC,CAAAA,OAAAA,CAAS,CAAEC,QAAU,CAAA,CAAA,CAAA,CAEzB,sEAvDMO,CAAAA,CAA2B,GAAIS,CAAAA,GAC/BL,CAAAA,CAAAA,CAAAA,CAAAA,CAA0B,GAAIM,CAAAA,OAEpC,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const n=new Map,t=new WeakMap;function o(n,t){return"rtl"===t.toLowerCase()?{keyframes:n.rtlKeyframes||n.keyframes,options:n.options}:n}function
|
|
1
|
+
const n=new Map,t=new WeakMap;function o(n){return n??{keyframes:[],options:{duration:0}}}function r(n,t){return"rtl"===t.toLowerCase()?{keyframes:n.rtlKeyframes||n.keyframes,options:n.options}:n}function e(t,r){n.set(t,o(r))}function s(n,r,e){t.set(n,{...t.get(n),[r]:o(e)})}function a(o,e,s){const a=t.get(o);if(a?.[e])return r(a[e],s.dir);const i=n.get(e);return i?r(i,s.dir):{keyframes:[],options:{duration:0}}}export{s as a,a as g,e as s};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent nile-elements following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "nile-elements",
|
|
6
|
-
"version": "2.0.
|
|
6
|
+
"version": "2.0.21",
|
|
7
7
|
"main": "dist/src/index.js",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"module": "dist/src/index.js",
|
|
@@ -134,6 +134,7 @@
|
|
|
134
134
|
"./nile-color-swatch": "./dist/src/nile-color-swatch/index.js",
|
|
135
135
|
"./nile-tree": "./dist/src/nile-tree/index.js",
|
|
136
136
|
"./nile-tree-item": "./dist/src/nile-tree-item/index.js",
|
|
137
|
+
"./nile-date-time-picker": "./dist/src/nile-date-time-picker/index.js",
|
|
137
138
|
"./nile-wysiwyg-editor": "./dist/src/nile-wysiwyg-editor/index.js",
|
|
138
139
|
"./nile-wysiwyg-toolbar": "./dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js",
|
|
139
140
|
"./nile-app-shell": "./dist/src/nile-app-shell/index.js",
|
|
@@ -143,7 +144,7 @@
|
|
|
143
144
|
"./nile-app-shell-panel": "./dist/src/nile-app-shell-panel/index.js"
|
|
144
145
|
},
|
|
145
146
|
"scripts": {
|
|
146
|
-
"analyze": "cem analyze --litelement",
|
|
147
|
+
"analyze": "cem analyze --litelement --exclude \"**/*.test-helpers.ts\"",
|
|
147
148
|
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
148
149
|
"build": "tsc && node scripts/replace-version.cjs && yarn analyze -- --exclude dist && yarn build:vscode-schema",
|
|
149
150
|
"package": "rollup -c",
|
|
@@ -197,6 +198,7 @@
|
|
|
197
198
|
"tippy.js": "^6.3.7"
|
|
198
199
|
},
|
|
199
200
|
"devDependencies": {
|
|
201
|
+
"@aquera/nile-glyph": "^1.0.9",
|
|
200
202
|
"@custom-elements-manifest/analyzer": "^0.4.17",
|
|
201
203
|
"@open-wc/eslint-config": "^8.0.2",
|
|
202
204
|
"@open-wc/testing": "^3.1.6",
|
package/rollup.config.js
CHANGED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Builds components.json (consumed by ui-playground's per-component doc badges): the size of each
|
|
3
|
+
// component's own code and an axe-core audit of its default render. coverage.json carries coverage.
|
|
4
|
+
// Usage (from a package dir): node scripts/component-metrics.mjs [out.json]
|
|
5
|
+
import { readFileSync, readdirSync, writeFileSync, existsSync } from 'node:fs';
|
|
6
|
+
import { execSync } from 'node:child_process';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { gzipSync } from 'node:zlib';
|
|
9
|
+
import { join, relative, resolve } from 'node:path';
|
|
10
|
+
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
const esbuild = require('esbuild');
|
|
13
|
+
const puppeteer = require('puppeteer');
|
|
14
|
+
const axeSource = readFileSync(require.resolve('axe-core/axe.min.js'), 'utf8');
|
|
15
|
+
const axeVersion = require('axe-core/package.json').version;
|
|
16
|
+
|
|
17
|
+
const [outPath = 'coverage/components.json'] = process.argv.slice(2);
|
|
18
|
+
const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
|
|
19
|
+
const SRC = resolve('src');
|
|
20
|
+
const define = { 'process.env.NODE_ENV': '"production"' };
|
|
21
|
+
|
|
22
|
+
// A component is a src/nile-*/ folder that registers at least one element.
|
|
23
|
+
const components = readdirSync(SRC, { withFileTypes: true })
|
|
24
|
+
.filter(d => d.isDirectory() && d.name.startsWith('nile-'))
|
|
25
|
+
.map(d => {
|
|
26
|
+
const dir = join(SRC, d.name);
|
|
27
|
+
const sources = readdirSync(dir).filter(f => f.endsWith('.ts') && !f.endsWith('.test.ts') && !f.endsWith('.d.ts'));
|
|
28
|
+
const tags = sources.flatMap(f => [...readFileSync(join(dir, f), 'utf8').matchAll(/@customElement\(\s*['"]([a-z0-9-]+)['"]/g)].map(m => m[1]));
|
|
29
|
+
const entry = existsSync(join(dir, 'index.ts')) ? join(dir, 'index.ts') : join(dir, `${d.name}.ts`);
|
|
30
|
+
return { name: d.name, tags, entry };
|
|
31
|
+
})
|
|
32
|
+
.filter(c => c.tags.length && existsSync(c.entry))
|
|
33
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
34
|
+
|
|
35
|
+
// ---------------- SIZE ----------------
|
|
36
|
+
// "own" leaves out npm packages (Lit, floating-ui...) and other components, so the numbers compare
|
|
37
|
+
// component to component. "total" is everything a page pays to import just this component.
|
|
38
|
+
const ownCodeOnly = name => ({
|
|
39
|
+
name: 'own-code-only',
|
|
40
|
+
setup(build) {
|
|
41
|
+
build.onResolve({ filter: /.*/ }, args => {
|
|
42
|
+
if (args.kind === 'entry-point') return null;
|
|
43
|
+
if (!args.path.startsWith('.') && !args.path.startsWith('/')) return { path: args.path, external: true };
|
|
44
|
+
const top = relative(SRC, resolve(args.resolveDir, args.path)).split(/[\\/]/)[0];
|
|
45
|
+
return top.startsWith('nile-') && top !== name ? { path: args.path, external: true } : null;
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const measure = async (entry, plugins = []) => {
|
|
51
|
+
const result = await esbuild.build({
|
|
52
|
+
entryPoints: [entry], bundle: true, minify: true, format: 'esm', write: false, logLevel: 'silent',
|
|
53
|
+
target: 'es2020', define, plugins,
|
|
54
|
+
});
|
|
55
|
+
const code = result.outputFiles[0].contents;
|
|
56
|
+
return { minified: code.length, gzip: gzipSync(code, { level: 9 }).length };
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const sizes = new Map();
|
|
60
|
+
for (const c of components) {
|
|
61
|
+
try {
|
|
62
|
+
sizes.set(c.name, { own: await measure(c.entry, [ownCodeOnly(c.name)]), total: await measure(c.entry) });
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.warn(`size unavailable for ${c.name}: ${e.message.split('\n')[0]}`);
|
|
65
|
+
sizes.set(c.name, null);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ---------------- ACCESSIBILITY ----------------
|
|
70
|
+
// Each element is rendered the way a page minimally uses it -- with a label and text, and child-only
|
|
71
|
+
// elements inside their parent -- and audited against WCAG 2.1 A/AA. Without that, every element fails
|
|
72
|
+
// for content only the consumer can supply (an unlabelled button), which says nothing about the component.
|
|
73
|
+
// Only violations on the audited element itself count, so a parent's own issues are not charged to it.
|
|
74
|
+
const PARENTS = {
|
|
75
|
+
'nile-option': 'nile-select',
|
|
76
|
+
'nile-option-group': 'nile-select',
|
|
77
|
+
'nile-menu-item': 'nile-menu',
|
|
78
|
+
'nile-nav-tab': 'nile-nav-tab-group',
|
|
79
|
+
'nile-command-menu-item': 'nile-command-menu',
|
|
80
|
+
'nile-command-menu-group': 'nile-command-menu',
|
|
81
|
+
'nile-context-menu-item': 'nile-context-menu',
|
|
82
|
+
'nile-context-menu-group': 'nile-context-menu',
|
|
83
|
+
'nile-inline-sidebar-item': 'nile-inline-sidebar',
|
|
84
|
+
'nile-side-bar-group-item': 'nile-side-bar-group',
|
|
85
|
+
'nile-side-bar-action-menu-item': 'nile-side-bar-action-menu',
|
|
86
|
+
'nile-radio': 'nile-radio-group',
|
|
87
|
+
'nile-tab': 'nile-tab-group',
|
|
88
|
+
'nile-tree-item': 'nile-tree',
|
|
89
|
+
};
|
|
90
|
+
// Containers whose role requires children (a menu with no items) get one, for the same reason.
|
|
91
|
+
const CHILDREN = {
|
|
92
|
+
'nile-menu': '<nile-menu-item>Example</nile-menu-item>',
|
|
93
|
+
'nile-tree': '<nile-tree-item>Example</nile-tree-item>',
|
|
94
|
+
};
|
|
95
|
+
const AXE_TAGS = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'];
|
|
96
|
+
const audits = new Map();
|
|
97
|
+
const bundle = await esbuild.build({
|
|
98
|
+
entryPoints: [join(SRC, 'index.ts')], bundle: true, format: 'esm', write: false, logLevel: 'silent', target: 'es2020', define,
|
|
99
|
+
});
|
|
100
|
+
const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] });
|
|
101
|
+
try {
|
|
102
|
+
const page = await browser.newPage();
|
|
103
|
+
await page.setContent('<!doctype html><html lang="en"><head><title>Audit</title></head><body><main></main></body></html>');
|
|
104
|
+
await page.addScriptTag({ type: 'module', content: bundle.outputFiles[0].text });
|
|
105
|
+
await page.addScriptTag({ content: axeSource });
|
|
106
|
+
for (const c of components) {
|
|
107
|
+
const tag = c.tags.includes(c.name) ? c.name : c.tags[0];
|
|
108
|
+
try {
|
|
109
|
+
const violations = await page.evaluate(async (tag, parent, children, tags) => {
|
|
110
|
+
const main = document.querySelector('main');
|
|
111
|
+
const el = `<${tag} label="Example">${children ?? 'Example'}</${tag}>`;
|
|
112
|
+
main.innerHTML = parent ? `<${parent} label="Example">${el}</${parent}>` : el;
|
|
113
|
+
// A tag that never registers or renders must not stall the whole audit.
|
|
114
|
+
const within = (promise, what) => Promise.race([promise, new Promise((_, reject) => setTimeout(() => reject(new Error(`${what} timed out`)), 10000))]);
|
|
115
|
+
await within(customElements.whenDefined(tag), 'registration');
|
|
116
|
+
const target = main.querySelector(tag);
|
|
117
|
+
if (parent) await within(customElements.whenDefined(parent), 'registration');
|
|
118
|
+
await within(Promise.all([main.firstElementChild.updateComplete, target.updateComplete]), 'render');
|
|
119
|
+
const { violations } = await window.axe.run(target, { runOnly: { type: 'tag', values: tags } });
|
|
120
|
+
main.innerHTML = '';
|
|
121
|
+
return violations.map(v => ({ id: v.id, impact: v.impact, help: v.help, nodes: v.nodes.length }));
|
|
122
|
+
}, tag, PARENTS[tag] ?? null, CHILDREN[tag] ?? null, AXE_TAGS);
|
|
123
|
+
audits.set(c.name, { tag, violations });
|
|
124
|
+
} catch (e) {
|
|
125
|
+
console.warn(`axe unavailable for ${c.name}: ${e.message.split('\n')[0]}`);
|
|
126
|
+
audits.set(c.name, null);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} finally {
|
|
130
|
+
await browser.close();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const git = cmd => { try { return execSync(cmd, { encoding: 'utf8' }).trim(); } catch { return ''; } };
|
|
134
|
+
const report = {
|
|
135
|
+
package: pkg.name,
|
|
136
|
+
version: pkg.version,
|
|
137
|
+
branch: process.env.BITBUCKET_BRANCH || git('git rev-parse --abbrev-ref HEAD'),
|
|
138
|
+
commit: (process.env.BITBUCKET_COMMIT || git('git rev-parse HEAD')).slice(0, 7),
|
|
139
|
+
generatedAt: new Date().toISOString(),
|
|
140
|
+
axe: { version: axeVersion, tags: AXE_TAGS, render: 'label="Example" and text content; child elements inside their parent' },
|
|
141
|
+
components: components.map(c => ({ name: c.name, tags: c.tags, size: sizes.get(c.name), axe: audits.get(c.name) })),
|
|
142
|
+
};
|
|
143
|
+
writeFileSync(outPath, JSON.stringify(report, null, 2) + '\n');
|
|
144
|
+
const audited = report.components.filter(c => c.axe);
|
|
145
|
+
console.log(`components.json: ${components.length} components, ${[...sizes.values()].filter(Boolean).length} sized, ${audited.length} audited (${audited.filter(c => !c.axe.violations.length).length} with no violations) -> ${outPath}`);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Builds coverage.json (consumed by the ui-playground Metrics > Testing tab) from the
|
|
3
|
+
// wtr lcov report, the Istanbul coverage-final.json (statements) and the test runner output.
|
|
4
|
+
// Usage (from a package dir): node scripts/coverage-report.mjs <lcov.info> <test-output.txt> <out.json>
|
|
5
|
+
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
6
|
+
import { execSync } from 'node:child_process';
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
|
|
9
|
+
const [lcovPath = 'coverage/lcov.info', outputPath, outPath = 'coverage/coverage.json'] = process.argv.slice(2);
|
|
10
|
+
// Run from the package directory (cwd), so this script can be shared by other packages.
|
|
11
|
+
const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
|
|
12
|
+
|
|
13
|
+
const ratio = (covered, total) => ({ covered, total, pct: total ? Math.round((covered / total) * 10000) / 100 : 100 });
|
|
14
|
+
// sMissing counts files without statement data, so a group's statements become null instead of a false 100%.
|
|
15
|
+
const blank = () => ({ files: 0, sMissing: 0, SH: 0, SF: 0, LH: 0, LF: 0, BRH: 0, BRF: 0, FNH: 0, FNF: 0 });
|
|
16
|
+
const relPath = p => p.replace(/\\/g, '/').replace(/^.*?(?:^|\/)src\//, '');
|
|
17
|
+
|
|
18
|
+
// Statements: lcov has no statement metric, so read them from Istanbul's coverage-final.json.
|
|
19
|
+
const statements = new Map();
|
|
20
|
+
const finalPath = join(dirname(lcovPath), 'coverage-final.json');
|
|
21
|
+
try {
|
|
22
|
+
const final = JSON.parse(readFileSync(finalPath, 'utf8'));
|
|
23
|
+
for (const [file, data] of Object.entries(final)) {
|
|
24
|
+
const counts = Object.values(data.s ?? {});
|
|
25
|
+
statements.set(relPath(file), { SH: counts.filter(c => c > 0).length, SF: counts.length });
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
28
|
+
statements.clear();
|
|
29
|
+
console.warn(`statements unavailable: cannot read ${finalPath} (${e.code ?? e.message})`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const files = new Map();
|
|
33
|
+
let current = null;
|
|
34
|
+
for (const line of readFileSync(lcovPath, 'utf8').split('\n')) {
|
|
35
|
+
const [key, value] = [line.slice(0, line.indexOf(':')), line.slice(line.indexOf(':') + 1)];
|
|
36
|
+
if (key === 'SF') {
|
|
37
|
+
const rel = relPath(value);
|
|
38
|
+
const st = statements.get(rel);
|
|
39
|
+
current = { ...blank(), ...(st ?? { sMissing: 1 }), files: 1 };
|
|
40
|
+
files.set(rel, current);
|
|
41
|
+
} else if (current && key in current && key !== 'files') {
|
|
42
|
+
current[key] += Number(value) || 0;
|
|
43
|
+
} else if (line === 'end_of_record') {
|
|
44
|
+
current = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const metrics = g => ({
|
|
49
|
+
statements: g.sMissing ? null : ratio(g.SH, g.SF),
|
|
50
|
+
lines: ratio(g.LH, g.LF),
|
|
51
|
+
branches: ratio(g.BRH, g.BRF),
|
|
52
|
+
functions: ratio(g.FNH, g.FNF),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const groups = new Map();
|
|
56
|
+
const sum = blank();
|
|
57
|
+
const fileRows = [...files].map(([name, g]) => {
|
|
58
|
+
// Only real component folders (src/nile-*/) get a component row; shared code (internal, utilities, slot,
|
|
59
|
+
// version, index) is still in totals and files.
|
|
60
|
+
const group = name.split('/')[0];
|
|
61
|
+
const isComponent = name.includes('/') && group.startsWith('nile-');
|
|
62
|
+
if (isComponent && !groups.has(group)) groups.set(group, blank());
|
|
63
|
+
for (const k of Object.keys(sum)) {
|
|
64
|
+
if (isComponent) groups.get(group)[k] += g[k];
|
|
65
|
+
sum[k] += g[k];
|
|
66
|
+
}
|
|
67
|
+
return { name, ...metrics(g) };
|
|
68
|
+
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
69
|
+
|
|
70
|
+
const components = [...groups].map(([name, g]) => ({ name, files: g.files, ...metrics(g) }))
|
|
71
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
72
|
+
|
|
73
|
+
// null when the counts cannot be parsed, so a broken run is not reported as "0 tests".
|
|
74
|
+
let tests = null;
|
|
75
|
+
if (outputPath && existsSync(outputPath)) {
|
|
76
|
+
const text = readFileSync(outputPath, 'utf8').replace(/\x1B\[[0-9;]*[mK]/g, '');
|
|
77
|
+
const summary = text.split('\n').filter(l => /\d+\s+passed.*\d+\s+failed/.test(l)).pop();
|
|
78
|
+
const passed = summary?.match(/(\d+)\s+passed/)?.[1];
|
|
79
|
+
const failed = summary?.match(/(\d+)\s+failed/)?.[1];
|
|
80
|
+
if (passed !== undefined && failed !== undefined) tests = { passed: Number(passed), failed: Number(failed), total: Number(passed) + Number(failed) };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const git = cmd => { try { return execSync(cmd, { encoding: 'utf8' }).trim(); } catch { return ''; } };
|
|
84
|
+
const report = {
|
|
85
|
+
package: pkg.name,
|
|
86
|
+
version: pkg.version,
|
|
87
|
+
branch: process.env.BITBUCKET_BRANCH || git('git rev-parse --abbrev-ref HEAD'),
|
|
88
|
+
commit: (process.env.BITBUCKET_COMMIT || git('git rev-parse HEAD')).slice(0, 7),
|
|
89
|
+
generatedAt: new Date().toISOString(),
|
|
90
|
+
tests,
|
|
91
|
+
totals: { files: sum.files, ...metrics(sum) },
|
|
92
|
+
components,
|
|
93
|
+
files: fileRows,
|
|
94
|
+
};
|
|
95
|
+
writeFileSync(outPath, JSON.stringify(report, null, 2) + '\n');
|
|
96
|
+
console.log(`coverage.json: ${fileRows.length} files, ${components.length} components, ${report.totals.lines.pct}% lines, ${report.totals.statements ? `${report.totals.statements.pct}%` : 'n/a'} statements, ${tests?.total ?? 'n/a'} tests -> ${outPath}`);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Merges the per-shard wtr coverage (coverage/shard-*/coverage-final.json, written when the
|
|
3
|
+
// suite runs with WTR_SHARD) into one report in coverage/: lcov.info, cobertura-coverage.xml,
|
|
4
|
+
// coverage-final.json and a text summary, the same files an unsharded run produces (minus html,
|
|
5
|
+
// which needs the compiled sources).
|
|
6
|
+
// Needs istanbul-lib-coverage, istanbul-lib-report and istanbul-reports resolvable (NODE_PATH).
|
|
7
|
+
// Usage (from the package dir): node scripts/merge-coverage.cjs [coverageDir]
|
|
8
|
+
const { readdirSync, readFileSync, existsSync } = require('node:fs');
|
|
9
|
+
const { join } = require('node:path');
|
|
10
|
+
const libCoverage = require('istanbul-lib-coverage');
|
|
11
|
+
const libReport = require('istanbul-lib-report');
|
|
12
|
+
const reports = require('istanbul-reports');
|
|
13
|
+
|
|
14
|
+
const dir = process.argv[2] || 'coverage';
|
|
15
|
+
const map = libCoverage.createCoverageMap({});
|
|
16
|
+
const shards = readdirSync(dir).filter(d => d.startsWith('shard-')).sort();
|
|
17
|
+
|
|
18
|
+
for (const shard of shards) {
|
|
19
|
+
const file = join(dir, shard, 'coverage-final.json');
|
|
20
|
+
if (existsSync(file)) map.merge(JSON.parse(readFileSync(file, 'utf8')));
|
|
21
|
+
else console.warn(`${shard}: no coverage-final.json`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!map.files().length) {
|
|
25
|
+
console.error(`no shard coverage found in ${dir}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const context = libReport.createContext({ dir, coverageMap: map });
|
|
30
|
+
for (const name of ['lcovonly', 'cobertura', 'json', 'text-summary']) {
|
|
31
|
+
reports.create(name).execute(context);
|
|
32
|
+
}
|
|
33
|
+
console.log(`merged ${shards.length} shards, ${map.files().length} files -> ${dir}`);
|
package/src/index.ts
CHANGED
|
@@ -154,6 +154,7 @@ export { NileInlineSidebarItemHeader } from './nile-inline-sidebar-item-header';
|
|
|
154
154
|
export { NileInlineSidebarItemBody } from './nile-inline-sidebar-item-body';
|
|
155
155
|
export { NileMarkdown } from './nile-markdown';
|
|
156
156
|
export { NileMarkdownEditor } from './nile-markdown-editor';
|
|
157
|
+
export { NileDateTimePicker } from './nile-date-time-picker';
|
|
157
158
|
|
|
158
159
|
// nile-wysiwyg-editor — ProseMirror-powered rich text editor
|
|
159
160
|
export {
|
|
@@ -27,7 +27,24 @@ export const styles = css`
|
|
|
27
27
|
height: var(--nile-height-22px, var(--ng-height-24px));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
.
|
|
30
|
+
.badge__prefix,
|
|
31
|
+
.badge__suffix {
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
flex: 0 0 auto;
|
|
34
|
+
align-items: center;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.badge--has-prefix .badge__prefix {
|
|
38
|
+
margin-inline-end: var(--nile-spacing-xs, var(--ng-spacing-xs));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.badge--has-suffix .badge__suffix {
|
|
42
|
+
margin-inline-start: var(--nile-spacing-xs, var(--ng-spacing-xs));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.badge__prefix,
|
|
46
|
+
.badge__content,
|
|
47
|
+
.badge__suffix {
|
|
31
48
|
font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
|
|
32
49
|
font-size: var(--nile-type-scale-2, var(--ng-font-size-text-sm));
|
|
33
50
|
font-style: normal;
|
|
@@ -209,7 +226,9 @@ export const styles = css`
|
|
|
209
226
|
height: var(--nile-height-22px, var(--ng-height-22px));
|
|
210
227
|
}
|
|
211
228
|
|
|
212
|
-
.badge--sm .
|
|
229
|
+
.badge--sm .badge__prefix,
|
|
230
|
+
.badge--sm .badge__content,
|
|
231
|
+
.badge--sm .badge__suffix {
|
|
213
232
|
font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));
|
|
214
233
|
line-height: var(--nile-type-scale-5, var(--ng-line-height-text-xs));
|
|
215
234
|
}
|
|
@@ -219,7 +238,9 @@ export const styles = css`
|
|
|
219
238
|
height: var(--nile-height-28px, var(--ng-height-28px));
|
|
220
239
|
}
|
|
221
240
|
|
|
222
|
-
.badge--lg .
|
|
241
|
+
.badge--lg .badge__prefix,
|
|
242
|
+
.badge--lg .badge__content,
|
|
243
|
+
.badge--lg .badge__suffix {
|
|
223
244
|
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
|
|
224
245
|
line-height: var(--nile-type-scale-5, var(--ng-line-height-text-sm));
|
|
225
246
|
}
|
|
@@ -744,4 +744,106 @@ describe('NileBadge', () => {
|
|
|
744
744
|
});
|
|
745
745
|
});
|
|
746
746
|
});
|
|
747
|
+
|
|
748
|
+
describe('prefix and suffix slots', () => {
|
|
749
|
+
const base = (el: NileBadge) => el.shadowRoot!.querySelector('[part="base"]')!;
|
|
750
|
+
const slotOf = (el: NileBadge, name: string) =>
|
|
751
|
+
el.shadowRoot!.querySelector<HTMLSlotElement>(`slot[name="${name}"]`)!;
|
|
752
|
+
|
|
753
|
+
it('110. should render prefix and suffix slots with parts', async () => {
|
|
754
|
+
const el = await fixture<NileBadge>(html`<nile-badge>Label</nile-badge>`);
|
|
755
|
+
expect(slotOf(el, 'prefix').getAttribute('part')).to.equal('prefix');
|
|
756
|
+
expect(slotOf(el, 'suffix').getAttribute('part')).to.equal('suffix');
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
it('111. should render prefix before content and suffix after it', async () => {
|
|
760
|
+
const el = await fixture<NileBadge>(html`<nile-badge>Label</nile-badge>`);
|
|
761
|
+
const parts = [...base(el).children].map(n => n.getAttribute('part'));
|
|
762
|
+
expect(parts).to.deep.equal(['prefix', 'content', 'suffix']);
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
it('112. should assign prefix content to the prefix slot', async () => {
|
|
766
|
+
const el = await fixture<NileBadge>(html`<nile-badge><span slot="prefix" id="p">●</span>Label</nile-badge>`);
|
|
767
|
+
const assigned = slotOf(el, 'prefix').assignedElements();
|
|
768
|
+
expect(assigned).to.have.length(1);
|
|
769
|
+
expect(assigned[0].id).to.equal('p');
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
it('113. should assign suffix content to the suffix slot', async () => {
|
|
773
|
+
const el = await fixture<NileBadge>(html`<nile-badge>Label<span slot="suffix" id="s">3</span></nile-badge>`);
|
|
774
|
+
const assigned = slotOf(el, 'suffix').assignedElements();
|
|
775
|
+
expect(assigned).to.have.length(1);
|
|
776
|
+
expect(assigned[0].id).to.equal('s');
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
it('114. should accept any element in the slots', async () => {
|
|
780
|
+
const el = await fixture<NileBadge>(html`
|
|
781
|
+
<nile-badge>
|
|
782
|
+
<img slot="prefix" alt="" />
|
|
783
|
+
Label
|
|
784
|
+
<button slot="suffix">x</button>
|
|
785
|
+
</nile-badge>
|
|
786
|
+
`);
|
|
787
|
+
expect(slotOf(el, 'prefix').assignedElements()[0].tagName).to.equal('IMG');
|
|
788
|
+
expect(slotOf(el, 'suffix').assignedElements()[0].tagName).to.equal('BUTTON');
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
it('115. should not add has-prefix or has-suffix classes when slots are empty', async () => {
|
|
792
|
+
const el = await fixture<NileBadge>(html`<nile-badge>Label</nile-badge>`);
|
|
793
|
+
expect(base(el).classList.contains('badge--has-prefix')).to.be.false;
|
|
794
|
+
expect(base(el).classList.contains('badge--has-suffix')).to.be.false;
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
it('116. should add has-prefix and has-suffix classes when slots are filled', async () => {
|
|
798
|
+
const el = await fixture<NileBadge>(html`
|
|
799
|
+
<nile-badge><span slot="prefix">a</span>Label<span slot="suffix">b</span></nile-badge>
|
|
800
|
+
`);
|
|
801
|
+
expect(base(el).classList.contains('badge--has-prefix')).to.be.true;
|
|
802
|
+
expect(base(el).classList.contains('badge--has-suffix')).to.be.true;
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
it('117. should update classes when slot content is added later', async () => {
|
|
806
|
+
const el = await fixture<NileBadge>(html`<nile-badge>Label</nile-badge>`);
|
|
807
|
+
const icon = document.createElement('span');
|
|
808
|
+
icon.slot = 'prefix';
|
|
809
|
+
el.prepend(icon);
|
|
810
|
+
await elementUpdated(el);
|
|
811
|
+
await el.updateComplete;
|
|
812
|
+
expect(base(el).classList.contains('badge--has-prefix')).to.be.true;
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
it('118. should take no space when prefix and suffix are empty', async () => {
|
|
816
|
+
const el = await fixture<NileBadge>(html`<nile-badge>Label</nile-badge>`);
|
|
817
|
+
expect(slotOf(el, 'prefix').getBoundingClientRect().width).to.equal(0);
|
|
818
|
+
expect(slotOf(el, 'suffix').getBoundingClientRect().width).to.equal(0);
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
it('119. should space filled slots from the content with the spacing token', () => {
|
|
822
|
+
const css = styles.cssText;
|
|
823
|
+
const rule = (selector: string) => css.slice(css.indexOf(`${selector} {`)).split('}')[0];
|
|
824
|
+
const token = 'var(--nile-spacing-xs, var(--ng-spacing-xs))';
|
|
825
|
+
expect(rule('.badge--has-prefix .badge__prefix')).to.contain(`margin-inline-end: ${token}`);
|
|
826
|
+
expect(rule('.badge--has-suffix .badge__suffix')).to.contain(`margin-inline-start: ${token}`);
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
it('120. should keep slot content out of the aria-label', async () => {
|
|
830
|
+
const el = await fixture<NileBadge>(html`
|
|
831
|
+
<nile-badge><span slot="prefix">icon</span>Active<span slot="suffix">12</span></nile-badge>
|
|
832
|
+
`);
|
|
833
|
+
expect(el.getAttribute('aria-label')).to.equal('Active');
|
|
834
|
+
});
|
|
835
|
+
it('121. should ignore comment nodes in the aria-label', async () => {
|
|
836
|
+
const el = document.createElement('nile-badge') as NileBadge;
|
|
837
|
+
el.append(document.createComment('?lit$123$'), 'Active', document.createComment('ng-container'));
|
|
838
|
+
document.body.append(el);
|
|
839
|
+
await el.updateComplete;
|
|
840
|
+
expect(el.getAttribute('aria-label')).to.equal('Active');
|
|
841
|
+
el.remove();
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
it('122. should keep the existing label for badges without slots', async () => {
|
|
845
|
+
const el = await fixture<NileBadge>(html`<nile-badge>New <b>beta</b></nile-badge>`);
|
|
846
|
+
expect(el.getAttribute('aria-label')).to.equal('New beta');
|
|
847
|
+
});
|
|
848
|
+
});
|
|
747
849
|
});
|
|
@@ -15,6 +15,7 @@ import { styles } from './nile-badge.css';
|
|
|
15
15
|
import '../nile-icon-button/nile-icon-button';
|
|
16
16
|
import { classMap } from 'lit/directives/class-map.js';
|
|
17
17
|
import { customElement, property } from 'lit/decorators.js';
|
|
18
|
+
import { HasSlotController } from '../internal/slot';
|
|
18
19
|
import NileElement, { setupA11yMetadata } from '../internal/nile-element';
|
|
19
20
|
import type { CSSResultGroup } from 'lit';
|
|
20
21
|
import { A11yProperty } from '../internal/accessibility/a11y.property.enum';
|
|
@@ -35,27 +36,42 @@ import { A11yCustomValue } from '../internal/accessibility/a11y.custom-value.enu
|
|
|
35
36
|
* @dependency nile-icon-button
|
|
36
37
|
*
|
|
37
38
|
* @slot - The badge's content.
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
39
|
+
* @slot prefix - Content placed before the badge's content, such as an icon, dot or avatar.
|
|
40
|
+
* @slot suffix - Content placed after the badge's content, such as an icon, count or button.
|
|
40
41
|
*
|
|
41
42
|
* @csspart base - The component's base wrapper.
|
|
43
|
+
* @csspart prefix - The container that wraps the prefix slot.
|
|
42
44
|
* @csspart content - The badge's content.
|
|
43
|
-
* @csspart
|
|
44
|
-
* @csspart remove-button__base - The remove button's exported `base` part.
|
|
45
|
+
* @csspart suffix - The container that wraps the suffix slot.
|
|
45
46
|
*/
|
|
46
47
|
|
|
47
48
|
@customElement('nile-badge')
|
|
48
49
|
export class NileBadge extends NileElement {
|
|
49
50
|
static styles: CSSResultGroup = styles;
|
|
50
51
|
|
|
52
|
+
private readonly hasSlotController = new HasSlotController(this, 'prefix', 'suffix');
|
|
53
|
+
|
|
51
54
|
connectedCallback(): void {
|
|
52
55
|
super.connectedCallback();
|
|
53
56
|
setupA11yMetadata(this, {
|
|
54
57
|
[Role.Role]: A11yRole.Text,
|
|
55
|
-
[A11yProperty.AriaLabel]: this.
|
|
58
|
+
[A11yProperty.AriaLabel]: this.getLabelText() || A11yCustomValue.Badge,
|
|
56
59
|
});
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
/** Text of the default slot only, so prefix and suffix content stays out of the label. */
|
|
63
|
+
private getLabelText(): string {
|
|
64
|
+
return [...this.childNodes]
|
|
65
|
+
.filter(
|
|
66
|
+
node =>
|
|
67
|
+
node.nodeType === Node.TEXT_NODE ||
|
|
68
|
+
(node.nodeType === Node.ELEMENT_NODE && !(node as Element).hasAttribute('slot'))
|
|
69
|
+
)
|
|
70
|
+
.map(node => node.textContent ?? '')
|
|
71
|
+
.join('')
|
|
72
|
+
.trim();
|
|
73
|
+
}
|
|
74
|
+
|
|
59
75
|
/** The badge's theme variant. */
|
|
60
76
|
@property({ reflect: true }) variant:
|
|
61
77
|
| 'primary'
|
|
@@ -88,6 +104,9 @@ export class NileBadge extends NileElement {
|
|
|
88
104
|
@property({ reflect: true }) size: 'sm' | 'md' | 'lg' = 'md';
|
|
89
105
|
|
|
90
106
|
render() {
|
|
107
|
+
const hasPrefix = this.hasSlotController.test('prefix');
|
|
108
|
+
const hasSuffix = this.hasSlotController.test('suffix');
|
|
109
|
+
|
|
91
110
|
return html`
|
|
92
111
|
<span
|
|
93
112
|
part="base"
|
|
@@ -117,9 +136,13 @@ export class NileBadge extends NileElement {
|
|
|
117
136
|
'badge--sm': this.size === 'sm',
|
|
118
137
|
'badge--md': this.size === 'md',
|
|
119
138
|
'badge--lg': this.size === 'lg',
|
|
139
|
+
'badge--has-prefix': hasPrefix,
|
|
140
|
+
'badge--has-suffix': hasSuffix,
|
|
120
141
|
})}
|
|
121
142
|
>
|
|
143
|
+
<slot name="prefix" part="prefix" class="badge__prefix"></slot>
|
|
122
144
|
<slot part="content" class="badge__content"></slot>
|
|
145
|
+
<slot name="suffix" part="suffix" class="badge__suffix"></slot>
|
|
123
146
|
</span>
|
|
124
147
|
`;
|
|
125
148
|
}
|