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

frc-ui

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frc-ui - npm Package Compare versions

Comparing version 0.0.0-beta.16 to 0.0.0-beta.17

8

es/tree/Item.js

@@ -22,4 +22,5 @@ import React from 'react';

}
const paddingLeft = (index * 20) + 10;
let style = {
paddingLeft: (index * 20) + 10,
paddingLeft: paddingLeft,
height: rowHeight,

@@ -32,4 +33,5 @@ lineHeight: `${rowHeight}px`

const hidden = !expandEnable && !expandPlace;
const textLeftWidth = (!hidden ? 12 + 4 : 0) + (selectEnable ? 12 + 4 : 0);
const textStyle = {
width: `calc(100% - ${(!hidden ? 12 + 4 : 0) + (selectEnable ? 12 + 4 : 0)}px)`
width: `calc(100% - ${textLeftWidth}px)`
};

@@ -42,3 +44,3 @@ let content = text;

document.body.appendChild(span);
content = render(option, { parentWidth, width: span.offsetWidth });
content = render(option, { parentWidth: parentWidth - textLeftWidth - paddingLeft - 10, width: span.offsetWidth });
document.body.removeChild(span);

@@ -45,0 +47,0 @@ }

@@ -20,6 +20,5 @@ import React from 'react';

componentWillReceiveProps(nextProps: Props): void;
handleResize: () => void;
resize: () => void;
getProps: (prop: string) => any;
saveRef: (name: string) => (ele: HTMLDivElement) => void;
getContainerHeight: () => void;
update: (options?: OptionProps[]) => {

@@ -37,5 +36,6 @@ tops: never[];

onChange: (option: OptionProps) => (type: string, flag: boolean) => void;
getChildKeys: (value: string | number, options?: OptionProps[], keys?: (string | number)[], flag?: boolean) => (string | number)[];
expandKeys: (value: string | number, options?: OptionProps[], keys?: (string | number)[], found?: boolean) => (string | number)[];
getSelectedPath: (selectedKeys: (string | number)[], options?: OptionProps[], keys?: (string | number)[]) => (string | number)[];
getOptions: (expandedKeys?: (string | number)[], options?: OptionProps[], opt?: OptionProps[], index?: number, parentExpanded?: boolean) => OptionProps[];
getOptions: (expandedKeys?: (string | number)[], options?: OptionProps[], opt?: OptionProps[], index?: number, parentExpanded?: boolean, parent?: string | number) => OptionProps[];
getStyle: (type: Render_Type) => React.CSSProperties;

@@ -42,0 +42,0 @@ renderItem: (type: Render_Type) => JSX.Element[];

@@ -22,3 +22,3 @@ var __rest = (this && this.__rest) || function (s, e) {

this.showCount = 0;
this.handleResize = () => {
this.resize = () => {
const { rowHeight, fixedTopBottom } = this.props;

@@ -54,4 +54,2 @@ const { tops, options, bottoms } = this.state;

};
this.getContainerHeight = () => {
};
this.update = (options = []) => {

@@ -123,8 +121,9 @@ const { rowHeight } = this.props;

else {
const childKeys = this.expandKeys(value);
keys = keys.filter((v) => (childKeys.indexOf(v) < 0));
const cKeys = this.expandKeys(value);
keys = keys.filter((v) => (cKeys.indexOf(v) < 0));
}
let options = this.getOptions(keys);
if (option.index === 0 && (height && options.length * rowHeight > height)) {
keys = [option.value];
if (height && options.length * rowHeight > height) {
const childKeys = this.getChildKeys(option.index === 0 ? option.value : option.parent);
keys = keys.filter(k => childKeys.indexOf(k) > -1);
}

@@ -142,13 +141,23 @@ options = this.getOptions(keys);

};
this.getChildKeys = (value, options = this.props.options, keys = [], flag = false) => {
for (let i = 0; i < options.length; i++) {
const option = options[i];
if (option.value === value || flag) {
keys.push(option.value);
const children = option.children || [];
if (children.length > 0) {
keys = this.getChildKeys(value, children, keys, true);
}
}
}
return keys;
};
this.expandKeys = (value, options = this.props.options, keys = [], found = false) => {
options.forEach(o => {
const children = o.children || [];
if (o.value === value) {
found = true;
}
if (found) {
keys.push(o.value);
}
if (children.length > 0) {
keys = this.expandKeys(value, children, keys, found);
if (o.value === value || found) {
keys.push(o.value);
}
keys = this.expandKeys(value, children, keys, o.value === value || found);
}

@@ -170,3 +179,3 @@ });

};
this.getOptions = (expandedKeys = this.state.expandedKeys || [], options = this.props.options, opt = [], index = 0, parentExpanded = true) => {
this.getOptions = (expandedKeys = this.state.expandedKeys || [], options = this.props.options, opt = [], index = 0, parentExpanded = true, parent = '') => {
options = options || [];

@@ -177,4 +186,6 @@ const expandPlace = options.some(o => (o.children && o.children.length > 0));

const expandEnable = children && children.length > 0;
const one = Object.assign(Object.assign({ expandEnable }, other), { index, expandPlace });
const one = Object.assign(Object.assign({ expandEnable }, other), { index, expandPlace, parent });
const expanded = expandEnable && expandedKeys.indexOf(o.value) > -1;
if (index === 0)
parent = o.value;
if (parentExpanded) {

@@ -184,3 +195,3 @@ opt.push(one);

if (expandEnable) {
this.getOptions(expandedKeys, children || [], opt, index + 1, expanded);
this.getOptions(expandedKeys, children || [], opt, index + 1, expanded, parent);
}

@@ -225,4 +236,4 @@ });

if (this.wrap) {
this.handleResize();
this.wrap.addEventListener('resize', this.handleResize);
this.resize();
this.wrap.addEventListener('resize', this.resize);
}

@@ -229,0 +240,0 @@ }

@@ -10,3 +10,3 @@ export interface OptionProps {

expandPlace?: boolean;
parent?: string | number;
parent: string | number;
expandedIcon?: Function;

@@ -13,0 +13,0 @@ children?: Array<OptionProps>;

@@ -53,4 +53,5 @@ "use strict";

var paddingLeft = index * 20 + 10;
var style = {
paddingLeft: index * 20 + 10,
paddingLeft: paddingLeft,
height: rowHeight,

@@ -65,4 +66,5 @@ lineHeight: "".concat(rowHeight, "px")

var hidden = !expandEnable && !expandPlace;
var textLeftWidth = (!hidden ? 12 + 4 : 0) + (selectEnable ? 12 + 4 : 0);
var textStyle = {
width: "calc(100% - ".concat((!hidden ? 12 + 4 : 0) + (selectEnable ? 12 + 4 : 0), "px)")
width: "calc(100% - ".concat(textLeftWidth, "px)")
};

@@ -77,3 +79,3 @@ var content = text;

content = render(option, {
parentWidth: parentWidth,
parentWidth: parentWidth - textLeftWidth - paddingLeft - 10,
width: span.offsetWidth

@@ -80,0 +82,0 @@ });

@@ -80,3 +80,3 @@ "use strict";

_this.handleResize = function () {
_this.resize = function () {
var _this$props = _this.props,

@@ -131,4 +131,2 @@ rowHeight = _this$props.rowHeight,

_this.getContainerHeight = function () {};
_this.update = function () {

@@ -227,6 +225,6 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];

} else {
var childKeys = _this.expandKeys(value);
var cKeys = _this.expandKeys(value);
keys = keys.filter(function (v) {
return childKeys.indexOf(v) < 0;
return cKeys.indexOf(v) < 0;
});

@@ -237,4 +235,8 @@ }

if (option.index === 0 && height && options.length * rowHeight > height) {
keys = [option.value];
if (height && options.length * rowHeight > height) {
var childKeys = _this.getChildKeys(option.index === 0 ? option.value : option.parent);
keys = keys.filter(function (k) {
return childKeys.indexOf(k) > -1;
});
}

@@ -259,2 +261,23 @@

_this.getChildKeys = function (value) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.props.options;
var keys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var flag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
for (var i = 0; i < options.length; i++) {
var option = options[i];
if (option.value === value || flag) {
keys.push(option.value);
var children = option.children || [];
if (children.length > 0) {
keys = _this.getChildKeys(value, children, keys, true);
}
}
}
return keys;
};
_this.expandKeys = function (value) {

@@ -267,13 +290,9 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.props.options;

if (o.value === value) {
found = true;
}
if (children.length > 0) {
if (o.value === value || found) {
keys.push(o.value);
}
if (found) {
keys.push(o.value);
keys = _this.expandKeys(value, children, keys, o.value === value || found);
}
if (children.length > 0) {
keys = _this.expandKeys(value, children, keys, found);
}
});

@@ -308,2 +327,3 @@ return keys;

var parentExpanded = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
var parent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '';
options = options || [];

@@ -322,5 +342,7 @@ var expandPlace = options.some(function (o) {

index: index,
expandPlace: expandPlace
expandPlace: expandPlace,
parent: parent
});
var expanded = expandEnable && expandedKeys.indexOf(o.value) > -1;
if (index === 0) parent = o.value;

@@ -332,3 +354,3 @@ if (parentExpanded) {

if (expandEnable) {
_this.getOptions(expandedKeys, children || [], opt, index + 1, expanded);
_this.getOptions(expandedKeys, children || [], opt, index + 1, expanded, parent);
}

@@ -405,4 +427,4 @@ });

if (this.wrap) {
this.handleResize();
this.wrap.addEventListener('resize', this.handleResize);
this.resize();
this.wrap.addEventListener('resize', this.resize);
}

@@ -409,0 +431,0 @@ }

{
"name": "frc-ui",
"version": "0.0.0-beta.16",
"version": "0.0.0-beta.17",
"description": "React Web UI",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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