New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@baseline-ui/utils

Package Overview
Dependencies
Maintainers
2
Versions
204
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@baseline-ui/utils - npm Package Compare versions

Comparing version 0.16.0 to 0.17.0

16

dist/index.d.ts

@@ -162,2 +162,16 @@ import React from 'react';

export { calculateFontSizeToFitWidth, classNames, cleanKeyFromGlobImport, filterTruthyValues, getHTMLElement, getSvgPathFromStroke, getTextDimensions, invariant, isUrl, lightenColor };
/**
* Returns the keyboard shortcut label with the correct symbols for the current
* OS.
*
* ```tsx
* getOsSpecificKeyboardShortcutLabel("Ctrl+Alt+Shift+Enter", true); // "⌘⌥⇧↩"
* getOsSpecificKeyboardShortcutLabel("Ctrl+Alt+Shift+Enter"); // "Cmd+Option+Shift+Enter"
* ```
*
* @param keyboardShortcut - The Windows keyboard shortcut to format.
* @param useSymbol - Whether to use symbols for the modifier keys.
*/
declare function getOsSpecificKeyboardShortcutLabel(keyboardShortcut: string, useSymbol?: boolean): string;
export { calculateFontSizeToFitWidth, classNames, cleanKeyFromGlobImport, filterTruthyValues, getHTMLElement, getOsSpecificKeyboardShortcutLabel, getSvgPathFromStroke, getTextDimensions, invariant, isUrl, lightenColor };

16

dist/index.js
'use strict';
var color = require('@react-stately/color');
var utils = require('@react-aria/utils');

@@ -14,13 +15,14 @@ /**

*/
function a(t,n){if(!t)throw new Error(n||"Invariant failed")}function l(...t){let n=t.filter(Boolean),e=[];for(let r of n)if(Array.isArray(r))e.push(l(...r));else if(typeof r=="object"){let o=Object.keys(r);for(let i of o)r[i]&&e.push(i);}else typeof r=="string"&&e.push(r);return e.join(" ")}function b(t,n){if(!t)return null;if(typeof t=="string")return n.querySelector(t);if(t instanceof HTMLElement)return t;if("current"in t)return t.current}function f({text:t,fontSize:n,fontFamily:e="Arial",fontWeight:r="normal",fontStyle:o="normal"}){let c=document.createElement("canvas").getContext("2d");if(!c)return {width:0,height:0};c.font=`${o} ${r} ${n}px ${e}`;let s=c.measureText(t);return {width:s.width,height:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent}}function y({text:t,maxWidth:n,initialFontSize:e=50,fontFamily:r="Arial",fontWeight:o="normal",fontStyle:i="normal"}){let{width:c}=f({text:t,fontSize:e,fontFamily:r,fontWeight:o,fontStyle:i}),s=e,u=c;for(;u>n;)s-=.5,u=f({text:t,fontSize:s,fontFamily:r,fontWeight:o,fontStyle:i}).width;return Math.max(s,1)}function m(t,n,e,r){return [(t+e)/2,(n+r)/2]}function w(t){if(!t.length)return "";let n=["M",...t[0],"Q"];for(let e=0;e<t.length;e++){let[r,o]=t[e],[i,c]=t[(e+1)%t.length],s=m(r,o,i,c);n=[...n,r,o,...s];}return n.push("Z"),n.join(" ")}function g(t){return t.split("/").pop()?.split(".").shift()}function S(t){let n={};for(let e of Object.keys(t)){let r=g(e)??"";n[r]=t[e];}return n}function P(t){return Object.fromEntries(Object.entries(t).filter(([,n])=>!!n))}function $(t,n){a(n>=0&&n<=100,"Percent must be between 0 and 100");let e=color.parseColor(t),r=e.getChannelValue("red"),o=e.getChannelValue("green"),i=e.getChannelValue("blue"),c=Math.round(r+(255-r)*n/100),s=Math.round(o+(255-o)*n/100),u=Math.round(i+(255-i)*n/100);return `#${c.toString(16)}${s.toString(16)}${u.toString(16)}`}function d(t,n){if(t=t.trim(),t.includes(" "))return !1;try{return new URL(t),!0}catch{return n?d(`https://${t}`):!1}}
function f(t,n){if(!t)throw new Error(n||"Invariant failed")}function l(...t){let n=t.filter(Boolean),r=[];for(let e of n)if(Array.isArray(e))r.push(l(...e));else if(typeof e=="object"){let o=Object.keys(e);for(let i of o)e[i]&&r.push(i);}else typeof e=="string"&&r.push(e);return r.join(" ")}function y(t,n){if(!t)return null;if(typeof t=="string")return n.querySelector(t);if(t instanceof HTMLElement)return t;if("current"in t)return t.current}function u({text:t,fontSize:n,fontFamily:r="Arial",fontWeight:e="normal",fontStyle:o="normal"}){let c=document.createElement("canvas").getContext("2d");if(!c)return {width:0,height:0};c.font=`${o} ${e} ${n}px ${r}`;let s=c.measureText(t);return {width:s.width,height:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent}}function E({text:t,maxWidth:n,initialFontSize:r=50,fontFamily:e="Arial",fontWeight:o="normal",fontStyle:i="normal"}){let{width:c}=u({text:t,fontSize:r,fontFamily:e,fontWeight:o,fontStyle:i}),s=r,a=c;for(;a>n;)s-=.5,a=u({text:t,fontSize:s,fontFamily:e,fontWeight:o,fontStyle:i}).width;return Math.max(s,1)}function p(t,n,r,e){return [(t+r)/2,(n+e)/2]}function w(t){if(!t.length)return "";let n=["M",...t[0],"Q"];for(let r=0;r<t.length;r++){let[e,o]=t[r],[i,c]=t[(r+1)%t.length],s=p(e,o,i,c);n=[...n,e,o,...s];}return n.push("Z"),n.join(" ")}function g(t){return t.split("/").pop()?.split(".").shift()}function S(t){let n={};for(let r of Object.keys(t)){let e=g(r)??"";n[e]=t[r];}return n}function R(t){return Object.fromEntries(Object.entries(t).filter(([,n])=>!!n))}function L(t,n){f(n>=0&&n<=100,"Percent must be between 0 and 100");let r=color.parseColor(t),e=r.getChannelValue("red"),o=r.getChannelValue("green"),i=r.getChannelValue("blue"),c=Math.round(e+(255-e)*n/100),s=Math.round(o+(255-o)*n/100),a=Math.round(i+(255-i)*n/100);return `#${c.toString(16)}${s.toString(16)}${a.toString(16)}`}function d(t,n){if(t=t.trim(),t.includes(" "))return !1;try{return new URL(t),!0}catch{return n?d(`https://${t}`):!1}}function B(t,n=!1){return utils.isMac()?t.replace("Ctrl+",n?"\u2318":"Cmd+").replace("Alt+",n?"\u2325":"Option+").replace("Shift+",n?"\u21E7":"Shift+").replace("Enter+",n?"\u21A9":"Enter+").replace("Space+",n?"\u2423":"Space+").replace("Enter",n?"\u21A9":"Enter"):t}
exports.calculateFontSizeToFitWidth = y;
exports.calculateFontSizeToFitWidth = E;
exports.classNames = l;
exports.cleanKeyFromGlobImport = S;
exports.filterTruthyValues = P;
exports.getHTMLElement = b;
exports.filterTruthyValues = R;
exports.getHTMLElement = y;
exports.getOsSpecificKeyboardShortcutLabel = B;
exports.getSvgPathFromStroke = w;
exports.getTextDimensions = f;
exports.invariant = a;
exports.getTextDimensions = u;
exports.invariant = f;
exports.isUrl = d;
exports.lightenColor = $;
exports.lightenColor = L;
{
"name": "@baseline-ui/utils",
"version": "0.16.0",
"version": "0.17.0",
"description": "A collection of utility functions for Baseline UI",

@@ -15,2 +15,3 @@ "main": "dist/index.js",

"dependencies": {
"@react-aria/utils": "3.23.2",
"@react-stately/color": "3.5.3"

@@ -17,0 +18,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc