@ancon/wildcat-utils 1.50.16 → 1.50.18
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/api/APIFilterBuilder.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var p=(o,r,e)=>r in o?l(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e;var i=(o,r,e)=>(p(o,typeof r!="symbol"?r+"":r,e),e);const t=require("./types.js");class s{constructor(r,e){i(this,"propertyName");i(this,"parentBuilder");this.propertyName=e,this.parentBuilder=r}has(r){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.Has,this.parentBuilder.addFilter(this.propertyName,Array.isArray(r)?r.map(e=>`${t.APIFilterOperator.Has}:${e}`):`${t.APIFilterOperator.Has}:${r}`)}in(r){const e=Array.isArray(r)?r:[r];return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.In,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.In}:${e.join(",")}`)}greaterThan(r){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.GT,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.GT}:${r}`)}greaterThanOrEqual(r){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.GTE,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.GTE}:${r}`)}lessThan(r){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.LT,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.LT}:${r}`)}lessThanOrEqual(r){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.LTE,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.LTE}:${r}`)}null(){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.Null,this.parentBuilder.addFilter(this.propertyName,t.APIFilterOperator.Null)}notNull(){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.NotNull,this.parentBuilder.addFilter(this.propertyName,t.APIFilterOperator.NotNull)}notIn(r){const e=Array.isArray(r)?r:[r];return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.NotIn,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.NotIn}:${e.join(",")}`)}andBitwise(r){return this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.And}:${r}`)}}class d{constructor(){i(this,"operatorBuildPending");i(this,"conditionBuildPending");i(this,"recentPropertyName");i(this,"recentPropertyOperator");i(this,"filters",{})}addProperty(r){if(this.operatorBuildPending===!0)throw new Error("API Filter operator configuration is incomplete");return this.operatorBuildPending=!0,this.recentPropertyName=r,new s(this,r)}addFilter(r,e){if(this.filters[r]){const n=this.filters[r],a=Array.isArray(e)?e:[e];this.filters[r]=Array.isArray(n)?n.concat(a):[n,...a]}else this.filters[r]=e;return this.operatorBuildPending=!1,this.conditionBuildPending=!1,this}build(){return this.filters}or(){if(this.operatorBuildPending===!0)throw new Error("API Filter operator configuration is incomplete");if(this.conditionBuildPending===!0)throw new Error("API Filter condition configuration is incomplete");if(!this.recentPropertyOperator||![t.APIFilterOperator.GT,t.APIFilterOperator.GTE,t.APIFilterOperator.LT,t.APIFilterOperator.LTE,t.APIFilterOperator.In,t.APIFilterOperator.Has].includes(this.recentPropertyOperator))throw new Error("Last operator not compatible for OR condition");const r=this.filters[this.recentPropertyName];if(Array.isArray(r))throw new Error("Last operator not compatible for OR condition");const e=`${r}:${t.APIFilterCondition.Or}`;return this.filters[this.recentPropertyName]=e,this.conditionBuildPending=!0,this}}module.exports=d;
|
|
1
|
+
"use strict";var l=Object.defineProperty;var p=(o,r,e)=>r in o?l(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e;var i=(o,r,e)=>(p(o,typeof r!="symbol"?r+"":r,e),e);const t=require("./types.js");class s{constructor(r,e){i(this,"propertyName");i(this,"parentBuilder");this.propertyName=e,this.parentBuilder=r}has(r){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.Has,this.parentBuilder.addFilter(this.propertyName,Array.isArray(r)?r.map(e=>`${t.APIFilterOperator.Has}:${e}`):`${t.APIFilterOperator.Has}:${r}`)}in(r){const e=Array.isArray(r)?r:[r];return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.In,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.In}:${e.join(",")}`)}greaterThan(r){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.GT,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.GT}:${r}`)}greaterThanOrEqual(r){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.GTE,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.GTE}:${r}`)}lessThan(r){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.LT,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.LT}:${r}`)}lessThanOrEqual(r){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.LTE,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.LTE}:${r}`)}null(){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.Null,this.parentBuilder.addFilter(this.propertyName,t.APIFilterOperator.Null)}notNull(){return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.NotNull,this.parentBuilder.addFilter(this.propertyName,t.APIFilterOperator.NotNull)}notIn(r){const e=Array.isArray(r)?r:[r];return this.parentBuilder.recentPropertyOperator=t.APIFilterOperator.NotIn,this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.NotIn}:${e.join(",")}`)}andBitwise(r){return this.parentBuilder.addFilter(this.propertyName,`${t.APIFilterOperator.And}:${r}`)}}class d{constructor(){i(this,"operatorBuildPending");i(this,"conditionBuildPending");i(this,"recentPropertyName");i(this,"recentPropertyOperator");i(this,"filters",{})}addProperty(r){if(this.operatorBuildPending===!0)throw new Error("API Filter operator configuration is incomplete");return this.operatorBuildPending=!0,this.recentPropertyName=r,new s(this,r)}addFilter(r,e){if(this.filters[r]){const n=this.filters[r],a=Array.isArray(e)?e:[e];this.filters[r]=Array.isArray(n)?n.concat(a):[n,...a]}else this.filters[r]=e;return this.operatorBuildPending=!1,this.conditionBuildPending=!1,this}build(){return this.filters}or(){if(this.operatorBuildPending===!0)throw new Error("API Filter operator configuration is incomplete");if(this.conditionBuildPending===!0)throw new Error("API Filter condition configuration is incomplete");if(!this.recentPropertyOperator||![t.APIFilterOperator.GT,t.APIFilterOperator.GTE,t.APIFilterOperator.LT,t.APIFilterOperator.LTE,t.APIFilterOperator.In,t.APIFilterOperator.NotIn,t.APIFilterOperator.Has].includes(this.recentPropertyOperator))throw new Error("Last operator not compatible for OR condition");const r=this.filters[this.recentPropertyName];if(Array.isArray(r))throw new Error("Last operator not compatible for OR condition");const e=`${r}:${t.APIFilterCondition.Or}`;return this.filters[this.recentPropertyName]=e,this.conditionBuildPending=!0,this}}module.exports=d;
|
package/api/APIFilterBuilder.mjs
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
import { WCAG2Options } from 'tinycolor2';
|
|
2
|
+
declare type ReadabilityOptions = WCAG2Options & {
|
|
3
|
+
/**
|
|
4
|
+
* Override WCAG2 readability standards with a custom minimum contrast ratio.
|
|
5
|
+
* Colors pass readability if contrast >= this threshold.
|
|
6
|
+
*/
|
|
7
|
+
minimumReadableContrast?: number;
|
|
8
|
+
};
|
|
1
9
|
/**
|
|
2
10
|
* Ensure that foreground and background color combinations are readable
|
|
3
11
|
*
|
|
4
12
|
* @param fgColor - The foreground color
|
|
5
13
|
* @param bgColor - The background color
|
|
14
|
+
* @param options - The WCAG2 options extended with a custom minimum contrast ratio
|
|
6
15
|
* @returns Whether the color combinations are readable
|
|
7
16
|
*/
|
|
8
|
-
export default function isColorsReadable(fgColor: string, bgColor: string): boolean;
|
|
17
|
+
export default function isColorsReadable(fgColor: string, bgColor: string, options?: ReadabilityOptions): boolean;
|
|
18
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const s=require("tinycolor2"),d=1,m=21;function u(t,a,e){const{level:i,size:o,minimumReadableContrast:n}=e??{};if(n){const c=s.readability(t,a),l=Math.min(Math.max(n,d),m);return c>=l}const r={level:i,size:o};return s.isReadable(t,a,r)}module.exports=u;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import o from "tinycolor2";
|
|
2
|
+
const m = 1, d = 21;
|
|
3
|
+
function R(t, a, e) {
|
|
4
|
+
const { level: s, size: i, minimumReadableContrast: n } = e ?? {};
|
|
5
|
+
if (n) {
|
|
6
|
+
const c = o.readability(t, a), l = Math.min(
|
|
7
|
+
Math.max(n, m),
|
|
8
|
+
d
|
|
9
|
+
);
|
|
10
|
+
return c >= l;
|
|
11
|
+
}
|
|
12
|
+
const r = { level: s, size: i };
|
|
13
|
+
return o.isReadable(t, a, r);
|
|
4
14
|
}
|
|
5
15
|
export {
|
|
6
|
-
|
|
16
|
+
R as default
|
|
7
17
|
};
|