Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

baseframe-js

Package Overview
Dependencies
Maintainers
1
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baseframe-js - npm Package Compare versions

Comparing version 4.6.2 to 4.7.0

build/js/util/object-to-qs.d.ts

4

build/js/collapse.js

@@ -128,3 +128,5 @@ import $ from 'cash-dom';

close ? _.closeItems(_.$btnElems, _.$collapsibleItem) : _.openItems();
history && updateHistoryState(_, collapseID.substring(1), close, _.prevID.substring(1));
if (history) {
updateHistoryState(_.params, collapseID.substring(1), close, _.prevID.substring(1));
}
_.prevID = collapseID;

@@ -131,0 +133,0 @@ }

@@ -5,2 +5,3 @@ import installStoreToLibrary from './util/store';

import getUrlParam, { getHashParam } from './util/get-param';
import updateSearchParams from './util/updateSearchParams';
import AccessibleMenu from './accessible-menu';

@@ -20,2 +21,2 @@ import Collapse from './collapse';

export default installStoreToLibrary;
export { libraryExtend, AccessibleMenu, Collapse, EqualizeContent, LazyLoad, Modal, NavDesktop, NavMobile, Parallax, SelectEnhance, Tabs, cookies, formInputs, getHashParam, getUrlParam, smoothScroll, throttledResize };
export { libraryExtend, AccessibleMenu, Collapse, EqualizeContent, LazyLoad, Modal, NavDesktop, NavMobile, Parallax, SelectEnhance, Tabs, cookies, formInputs, getHashParam, getUrlParam, smoothScroll, throttledResize, updateSearchParams };

@@ -7,2 +7,3 @@ //cash dom or jquery are a dependency

import getUrlParam, { getHashParam } from './util/get-param';
import updateSearchParams from './util/updateSearchParams';
import AccessibleMenu from './accessible-menu';

@@ -24,2 +25,2 @@ import Collapse from './collapse';

export default installStoreToLibrary;
export { libraryExtend, AccessibleMenu, Collapse, EqualizeContent, LazyLoad, Modal, NavDesktop, NavMobile, Parallax, SelectEnhance, Tabs, cookies, formInputs, getHashParam, getUrlParam, smoothScroll, throttledResize };
export { libraryExtend, AccessibleMenu, Collapse, EqualizeContent, LazyLoad, Modal, NavDesktop, NavMobile, Parallax, SelectEnhance, Tabs, cookies, formInputs, getHashParam, getUrlParam, smoothScroll, throttledResize, updateSearchParams };

@@ -178,3 +178,3 @@ import $ from 'cash-dom';

});
updateHistoryEntry(_, _.modalID);
updateHistoryEntry(_.params, _.modalID);
}

@@ -193,3 +193,3 @@ disableModal() {

.off(`${_.modalEvent}Dismiss`);
updateHistoryEntry(_, _.modalID, true);
updateHistoryEntry(_.params, _.modalID, true);
transitionElem(() => {

@@ -196,0 +196,0 @@ $modal.attr({

@@ -207,3 +207,3 @@ import $ from 'cash-dom';

else {
updateHistoryState(_, tabId, removeIdFormHash, _.prevTabId);
updateHistoryState(_.params, tabId, removeIdFormHash, _.prevTabId);
}

@@ -210,0 +210,0 @@ _.prevTabId = tabId;

@@ -1,6 +0,3 @@

export declare const qsToObject: (qs?: string) => object;
export declare const objectToQs: (paramsObj: object) => string;
export declare const changeHashParam: (key: string, val: string, remove?: boolean, prevKeyOrVal?: string) => string;
declare const getUrlParam: (name: string, searchStr?: string) => string | null;
export declare const getHashParam: (name: string) => string | null;
export default getUrlParam;

@@ -1,84 +0,1 @@

import $ from 'cash-dom';
const qsArrayFormat = /(^\[)((?:(?!\]$)(.|\n|))*)(\]$)/; //begins with '[' and ends with ']';
export const qsToObject = (qs = location.search.substring(1)) => {
if (qs) {
const jsonStr = '{' +
decodeURI(qs)
.split('&').map((el) => {
const kv = el.split('=');
return `"${kv[0]}":"${(kv[1] ? kv[1] : '')}"`;
}).join(',')
+ '}';
const jsonObj = JSON.parse(jsonStr, (key, value) => {
if (value === 'true')
return true;
if (value === 'false')
return false;
// set as number, +'' evalutes to 0... we don't want that
if (value !== "" && typeof +value === 'number' && !isNaN(+value))
return +value;
// returns an array
if (qsArrayFormat.test(value) && typeof value === 'string') {
return value.replace(qsArrayFormat, '$2').split('%2C');
}
return value;
});
return jsonObj;
}
else {
return {};
}
};
export const objectToQs = (paramsObj) => {
const strArr = [];
const obj = {};
for (let key in paramsObj) {
if (obj.hasOwnProperty.call(paramsObj, key)) {
let propVal = paramsObj[key];
if (propVal) {
if (propVal instanceof Array) {
propVal = '[' + propVal + ']';
}
strArr.push(`${key}=${encodeURIComponent(propVal + '')}`);
}
else {
strArr.push(key);
}
}
}
return strArr.join('&');
};
export const changeHashParam = (key, val, remove = false, prevKeyOrVal) => {
const hashObj = qsToObject(location.hash.substring(1));
// if (!key && val !== prevVal) {
if (prevKeyOrVal && val !== prevKeyOrVal) {
// if we have a previous value and
// it doesn't match the current delete it.
// Also, the key may be a value, hence the name
delete hashObj[prevKeyOrVal];
}
if (remove) {
if (key && ({}).hasOwnProperty.call(hashObj, key)) {
delete hashObj[key];
}
// if (!key && val) {
if (val && ({}).hasOwnProperty.call(hashObj, key)) {
// if we only have a value
// then remove that as a key
delete hashObj[val];
}
}
else {
if (key) {
$.extend(hashObj, { [key]: val });
}
else {
// if we don't have a key
// assign the value to the key,
// and then it's value is blank
$.extend(hashObj, { [val]: '' });
}
}
return objectToQs(hashObj);
};
const _getParam = (name, searchStr = window.location.search, start = '?&', end = '([^&#]*)|&|#|$') => {

@@ -85,0 +2,0 @@ name = name.replace(/[\[\]]/g, '\\$&');

@@ -0,2 +1,9 @@

export declare function store<T>(dataName: string, data?: T): void | T;
export declare function removeStore<T>(dataName: string): void;
declare function installStoreAsDataToLibrary(expose?: boolean): void;
declare module 'cash-dom' {
interface Cash {
removeData: typeof removeStore;
}
}
export default installStoreAsDataToLibrary;

@@ -1,2 +0,3 @@

declare const updateHistoryState: (_: any, val: string, remove?: boolean, prevKeyOrVal?: string) => void;
import type { LocationHashTrackingHistory } from '../../types/shared';
declare const updateHistoryState: (params: LocationHashTrackingHistory, val: string, remove?: boolean, prevVal?: string) => void;
export default updateHistoryState;

@@ -1,6 +0,8 @@

import { changeHashParam } from '../get-param';
const updateHistoryState = (_, val, remove = false, prevKeyOrVal) => {
const { useLocationHash, historyType, useHashFilter } = _.params;
if (useLocationHash && useHashFilter) {
const qsParams = changeHashParam(useHashFilter, val, remove, prevKeyOrVal);
import updateSearchParams from '../updateSearchParams';
const updateHistoryState = (params, val, remove = false, prevVal) => {
const { useLocationHash, historyType, useHashFilter } = params;
const paramKey = useHashFilter || val;
const value = remove ? null : (useHashFilter ? val : null);
if (useLocationHash) {
const qsParams = updateSearchParams('hash', paramKey, value, remove, prevVal);
const updatedQs = qsParams ? '#' + qsParams : ' '; //space allows a change if there are no params

@@ -7,0 +9,0 @@ if (!historyType || historyType === 'replace') {

@@ -1,2 +0,1 @@

import type { Selector } from 'cash-dom';
declare type StoreElem = ArrayLike<HTMLElement> | HTMLElement;

@@ -10,3 +9,2 @@ export interface IStore {

export declare function removeStore<T>(dataName: string): void;
export declare function staticRemoveStore<T>(elem: Selector, dataName: string): void;
declare module 'cash-dom' {

@@ -19,3 +17,2 @@ interface Cash {

store: IStore;
removeStore: typeof staticRemoveStore;
}

@@ -22,0 +19,0 @@ }

{
"name": "baseframe-js",
"version": "4.6.2",
"version": "4.7.0",
"description": "A suite of useful Javascript plugins and functions to help with Front-end Development on websites",

@@ -5,0 +5,0 @@ "repository": {

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