@claspo/common 7.5.3 → 7.5.4-gbx1

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.
@@ -321,6 +321,7 @@ export interface TextStylesPropertyPaneManifestParamsI {
321
321
  fontSizePlaceholder?: string;
322
322
  hideTextShadow?: boolean;
323
323
  hideLetterSpacing?: boolean;
324
+ hideTextColor?: boolean;
324
325
  }
325
326
  export interface RadioButtonsPropertyPaneManifestModelI extends BasePropertyPaneManifestModelI {
326
327
  params: RadioButtonsPropertyPaneManifestParamsI;
@@ -1 +1 @@
1
- export default function copyToClipboard(r){var i;return(null===(i=navigator.clipboard)||void 0===i?void 0:i.writeText)?navigator.clipboard.writeText(String(r).trim().replace("<br>"," ")):Promise.reject()}
1
+ export default function copyToClipboard(e){var t;const o=String(e).trim().replace("<br>"," ");return(null===(t=navigator.clipboard)||void 0===t?void 0:t.writeText)?navigator.clipboard.writeText(o).catch(()=>copyWithExecCommand(o)):copyWithExecCommand(o)}function copyWithExecCommand(e){if("function"!=typeof document.execCommand)return Promise.reject();const t=document.createElement("textarea");try{t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t);const o=document.createRange();o.selectNodeContents(t);const n=document.getSelection();return n&&(n.removeAllRanges(),n.addRange(o)),t.setSelectionRange(0,e.length),document.execCommand("copy")?Promise.resolve():Promise.reject()}catch(e){return Promise.reject(e)}finally{t.remove()}}
@@ -1,12 +1,12 @@
1
1
  interface WeightedOption {
2
- id: string | number;
3
2
  weight: number;
3
+ id?: string | number;
4
4
  [key: string]: any;
5
5
  }
6
6
  interface Range {
7
7
  from: number;
8
8
  to: number;
9
- id: string | number;
9
+ index: number;
10
10
  }
11
11
  export default class RandomDistributor {
12
12
  calculateFromWeights(originOptions: WeightedOption[], multiplier?: number): WeightedOption | undefined;
@@ -1 +1 @@
1
- import sum from"./sum";import generateRandomNumber from"../utils/generateRandomNumber";export default class RandomDistributor{calculateFromWeights(t,e=1e3){const i=t.map(t=>Object.assign(Object.assign({},t),{weight:t.weight*e})),r=sum(i.map(t=>parseFloat(String(t.weight)))),n=generateRandomNumber(1,r);let o=this._buildRanges(i);const s=this._getRangeByWeight(o,n);return i.find(t=>t.id===(null==s?void 0:s.id))}_getRangeByWeight(t,e){return t.find(t=>e>=t.from&&e<=t.to)}_buildRanges(t){let e=[];for(let i=0;i<t.length;i++){const r=t[i];if(0===i)e.push({from:1,to:parseFloat(String(r.weight)),id:r.id});else{const t=e[e.length-1].to,i=t+parseFloat(String(r.weight));e.push({from:t+1,to:i,id:r.id})}}return e}}
1
+ import sum from"./sum";import generateRandomNumber from"../utils/generateRandomNumber";export default class RandomDistributor{calculateFromWeights(e,t=1e3){const r=e.map(e=>Object.assign(Object.assign({},e),{weight:e.weight*t})),n=sum(r.map(e=>parseFloat(String(e.weight)))),i=generateRandomNumber(1,n);let o=this._buildRanges(r);const s=this._getRangeByWeight(o,i);return s?r[s.index]:void 0}_getRangeByWeight(e,t){return e.find(e=>t>=e.from&&t<=e.to)}_buildRanges(e){let t=[];for(let r=0;r<e.length;r++){const n=e[r];if(0===r)t.push({from:1,to:parseFloat(String(n.weight)),index:r});else{const e=t[t.length-1].to,i=e+parseFloat(String(n.weight));t.push({from:e+1,to:i,index:r})}}return t}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claspo/common",
3
- "version": "7.5.3",
3
+ "version": "7.5.4-gbx1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "engines": {