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

@ideal-postcodes/jsutil

Package Overview
Dependencies
Maintainers
3
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ideal-postcodes/jsutil - npm Package Compare versions

Comparing version 7.0.2 to 7.1.0

7

dist/address.d.ts

@@ -38,13 +38,10 @@ import { AnyAddress, GbrAddress } from "./types";

}
export interface MutateAddressOptions {
address: AnyAddress;
config: MutateConfig;
}
interface PopulateAddress {
(options: PopulateAddressOptions): void;
}
export declare const searchFields: (outputFields: OutputFields, scope: HTMLElement | Document) => OutputFields;
export declare const searchNames: (names: NamedFields, scope: HTMLElement | Document) => OutputFields;
export declare const searchLabels: (labels: NamedFields, scope: HTMLElement | Document) => OutputFields;
interface MutateAddress {
(options: MutateAddressOptions): AnyAddress;
(address: AnyAddress, config: MutateConfig): AnyAddress;
}

@@ -51,0 +48,0 @@ export declare const mutateAddress: MutateAddress;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeOrganisation = exports.populateAddress = exports.mutateAddress = exports.searchLabels = exports.searchNames = exports.getFields = exports.extract = exports.toAddressLines = exports.toMaxLengthLines = exports.charArrayLength = exports.join = exports.numberOfLines = void 0;
exports.removeOrganisation = exports.populateAddress = exports.mutateAddress = exports.searchLabels = exports.searchNames = exports.searchFields = exports.getFields = exports.extract = exports.toAddressLines = exports.toMaxLengthLines = exports.charArrayLength = exports.join = exports.numberOfLines = void 0;
const input_1 = require("./input");

@@ -117,3 +117,3 @@ const dom_1 = require("./dom");

const getFields = (o) => ({
...o.outputFields,
...(0, exports.searchFields)(o.outputFields || {}, o.config.scope),
...(0, exports.searchNames)(o.names || {}, o.config.scope),

@@ -123,2 +123,16 @@ ...(0, exports.searchLabels)(o.labels || {}, o.config.scope),

exports.getFields = getFields;
const searchFields = (outputFields, scope) => {
const fields = {};
let key;
for (key in outputFields) {
const value = outputFields[key];
if (value === undefined)
continue;
const field = (0, dom_1.toElem)(value, scope);
if ((0, input_1.isInputElem)(field))
fields[key] = field;
}
return fields;
};
exports.searchFields = searchFields;
const searchNames = (names, scope) => {

@@ -174,9 +188,8 @@ const result = {};

const skipFields = ["country", "country_iso_2", "country_iso"];
const mutateAddress = (o) => {
const address = { ...o.address };
const mutateAddress = (address, config) => {
if ((0, types_1.isGbrAddress)(address)) {
if (o.config.removeOrganisation)
if (config.removeOrganisation)
(0, exports.removeOrganisation)(address);
}
const [line_1, line_2, line_3] = (0, exports.toAddressLines)(o.config.lines || 3, address, o.config);
const [line_1, line_2, line_3] = (0, exports.toAddressLines)(config.lines || 3, address, config);
address.line_1 = line_1;

@@ -191,7 +204,7 @@ address.line_2 = line_2;

const { config } = options;
const address = (0, exports.mutateAddress)(options);
const { scope, populateCounty } = config;
const fields = (0, exports.getFields)(options);
if (config.lines !== undefined)
if (config.lines === undefined)
config.lines = (0, exports.numberOfLines)(fields);
const address = (0, exports.mutateAddress)({ ...options.address }, config);
const { scope, populateCounty } = config;
const skip = [...skipFields];

@@ -198,0 +211,0 @@ if ((0, types_1.isGbrAddress)(address)) {

export declare const isSelect: (e: HTMLElement | null) => e is HTMLSelectElement;
export declare const isInput: (e: HTMLElement | null) => e is HTMLInputElement;
export declare const isTextarea: (e: HTMLElement | null) => e is HTMLTextAreaElement;
export declare const isInputElem: (e: HTMLElement | null) => e is HTMLInputElement | HTMLTextAreaElement;
export declare const update: (input: HTMLElement | null | undefined, value: string, skipTrigger?: boolean) => void;

@@ -5,0 +6,0 @@ export declare const hasValue: (select: HTMLElement, value: string | null) => boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.change = exports.setValue = exports.hasValue = exports.update = exports.isTextarea = exports.isInput = exports.isSelect = void 0;
exports.change = exports.setValue = exports.hasValue = exports.update = exports.isInputElem = exports.isTextarea = exports.isInput = exports.isSelect = void 0;
const event_1 = require("./event");

@@ -8,3 +8,3 @@ const isSelect = (e) => {

return false;
return e instanceof HTMLSelectElement || e.constructor.name === "HTMLSelectElement";
return (e instanceof HTMLSelectElement || e.constructor.name === "HTMLSelectElement");
};

@@ -15,3 +15,3 @@ exports.isSelect = isSelect;

return false;
return e instanceof HTMLInputElement || e.constructor.name === "HTMLInputElement";
return (e instanceof HTMLInputElement || e.constructor.name === "HTMLInputElement");
};

@@ -22,5 +22,8 @@ exports.isInput = isInput;

return false;
return e instanceof HTMLTextAreaElement || e.constructor.name === "HTMLTextAreaElement";
return (e instanceof HTMLTextAreaElement ||
e.constructor.name === "HTMLTextAreaElement");
};
exports.isTextarea = isTextarea;
const isInputElem = (e) => (0, exports.isInput)(e) || (0, exports.isTextarea)(e) || (0, exports.isSelect)(e);
exports.isInputElem = isInputElem;
const update = (input, value, skipTrigger = false) => {

@@ -27,0 +30,0 @@ if (!input)

@@ -73,3 +73,3 @@ import { components } from "@ideal-postcodes/openapi";

export type NamedFields = Partial<Record<keyof GbrAddress, string>>;
export type SelectorNode = string | HTMLInputElement | HTMLTextAreaElement;
export type SelectorNode = string | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
export declare const isGbrAddress: (address: AnyAddress) => address is GbrAddress;

@@ -38,13 +38,10 @@ import { AnyAddress, GbrAddress } from "./types";

}
export interface MutateAddressOptions {
address: AnyAddress;
config: MutateConfig;
}
interface PopulateAddress {
(options: PopulateAddressOptions): void;
}
export declare const searchFields: (outputFields: OutputFields, scope: HTMLElement | Document) => OutputFields;
export declare const searchNames: (names: NamedFields, scope: HTMLElement | Document) => OutputFields;
export declare const searchLabels: (labels: NamedFields, scope: HTMLElement | Document) => OutputFields;
interface MutateAddress {
(options: MutateAddressOptions): AnyAddress;
(address: AnyAddress, config: MutateConfig): AnyAddress;
}

@@ -51,0 +48,0 @@ export declare const mutateAddress: MutateAddress;

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

import { update, change, isSelect, isInput, hasValue } from "./input";
import { isInputElem, update, change, isSelect, isInput, hasValue, } from "./input";
import { toElem, contains } from "./dom";

@@ -108,6 +108,19 @@ import { updateCountry } from "./country";

export const getFields = (o) => ({
...o.outputFields,
...searchFields(o.outputFields || {}, o.config.scope),
...searchNames(o.names || {}, o.config.scope),
...searchLabels(o.labels || {}, o.config.scope),
});
export const searchFields = (outputFields, scope) => {
const fields = {};
let key;
for (key in outputFields) {
const value = outputFields[key];
if (value === undefined)
continue;
const field = toElem(value, scope);
if (isInputElem(field))
fields[key] = field;
}
return fields;
};
export const searchNames = (names, scope) => {

@@ -161,9 +174,8 @@ const result = {};

const skipFields = ["country", "country_iso_2", "country_iso"];
export const mutateAddress = (o) => {
const address = { ...o.address };
export const mutateAddress = (address, config) => {
if (isGbrAddress(address)) {
if (o.config.removeOrganisation)
if (config.removeOrganisation)
removeOrganisation(address);
}
const [line_1, line_2, line_3] = toAddressLines(o.config.lines || 3, address, o.config);
const [line_1, line_2, line_3] = toAddressLines(config.lines || 3, address, config);
address.line_1 = line_1;

@@ -177,7 +189,7 @@ address.line_2 = line_2;

const { config } = options;
const address = mutateAddress(options);
const { scope, populateCounty } = config;
const fields = getFields(options);
if (config.lines !== undefined)
if (config.lines === undefined)
config.lines = numberOfLines(fields);
const address = mutateAddress({ ...options.address }, config);
const { scope, populateCounty } = config;
const skip = [...skipFields];

@@ -184,0 +196,0 @@ if (isGbrAddress(address)) {

export declare const isSelect: (e: HTMLElement | null) => e is HTMLSelectElement;
export declare const isInput: (e: HTMLElement | null) => e is HTMLInputElement;
export declare const isTextarea: (e: HTMLElement | null) => e is HTMLTextAreaElement;
export declare const isInputElem: (e: HTMLElement | null) => e is HTMLInputElement | HTMLTextAreaElement;
export declare const update: (input: HTMLElement | null | undefined, value: string, skipTrigger?: boolean) => void;

@@ -5,0 +6,0 @@ export declare const hasValue: (select: HTMLElement, value: string | null) => boolean;

@@ -5,3 +5,3 @@ import { trigger } from "./event";

return false;
return e instanceof HTMLSelectElement || e.constructor.name === "HTMLSelectElement";
return (e instanceof HTMLSelectElement || e.constructor.name === "HTMLSelectElement");
};

@@ -11,3 +11,3 @@ export const isInput = (e) => {

return false;
return e instanceof HTMLInputElement || e.constructor.name === "HTMLInputElement";
return (e instanceof HTMLInputElement || e.constructor.name === "HTMLInputElement");
};

@@ -17,4 +17,6 @@ export const isTextarea = (e) => {

return false;
return e instanceof HTMLTextAreaElement || e.constructor.name === "HTMLTextAreaElement";
return (e instanceof HTMLTextAreaElement ||
e.constructor.name === "HTMLTextAreaElement");
};
export const isInputElem = (e) => isInput(e) || isTextarea(e) || isSelect(e);
export const update = (input, value, skipTrigger = false) => {

@@ -21,0 +23,0 @@ if (!input)

@@ -73,3 +73,3 @@ import { components } from "@ideal-postcodes/openapi";

export type NamedFields = Partial<Record<keyof GbrAddress, string>>;
export type SelectorNode = string | HTMLInputElement | HTMLTextAreaElement;
export type SelectorNode = string | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
export declare const isGbrAddress: (address: AnyAddress) => address is GbrAddress;
{
"name": "@ideal-postcodes/jsutil",
"version": "7.0.2",
"version": "7.1.0",
"description": "Browser Address Autocomplete for api.ideal-postcodes.co.uk",

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

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