GithubHelp home page GithubHelp logo

metal / metal-plugins Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 11.0 10.28 MB

A collection of utilities that are often used in Metal.js projects, such as Ajax, Promise, URI, etc

License: Other

JavaScript 93.31% HTML 6.66% SCSS 0.02%

metal-plugins's Introduction

Metal.js

Build Status Join #metal on our Slack Channel

Build Status

Metal.js is a JavaScript library for building UI components in a solid, flexible way.

Support and Project status

Metal.js is widely used and well maintained internally at Liferay but does not currently have staffing to support the open source release. As such this project is mostly internal and support is minimal. For certain issues, like build integration we are in an especially bad position to offer support.

To get assistance you can use any of the following forums

  1. Look through the documentation.
  2. File an issue on GitHub

We will try our best, but keep in mind that given our support staffing, we may not be able to help.

Setup

  1. Install NodeJS >= v0.12.0, if you don't have it yet.

  2. Install lerna global dependency:

[sudo] npm install -g [email protected]
  1. Run the bootstrap script to install local dependencies and link packages together:
npm run lerna
  1. Run tests:
npm test

Developer Tools for Metal.js

Big Thanks

Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs

License

BSD License © Liferay, Inc.

metal-plugins's People

Contributors

bryceosterhaus avatar diegonvs avatar eduardolundgren avatar fernandosouza avatar gcmznt avatar henvic avatar ipeychev avatar jbalsas avatar mairatma avatar p2kmgcl avatar pragmaticivan avatar vbence86 avatar zenorocha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

metal-plugins's Issues

[metal-storage] Doesn't work with jsdom @ >11.12.0

  1. JSDOM added support for window.localStorage, window.sessionStorage, and StorageEvent in their 11.12.0 version
  2. This kinda "breaks" metal-storage, because the check if localStorage if present passes, but then you can't really use localStorage.

Some additional information about this: jsdom/jsdom#2304.

This is affecting magnet that was forced to lock their jsdom version

We should look into updating our check, so it will report that localStorage is not available even when this version of JDOM is loaded.

@diegonvs, could you take a look at this?

/cc @ipeychev

Update package.lock repository field

As we've moved all these packages, we should update the repository field in their package.json files so they can be properly located from the npm page.

[metal-drag-drop] Placeholder is added to the target list

I am using metal-drag-drop in a a list of divs that I want to reorder, so in this particular case, sources are also targets.

As I am using Drag.Placeholder.CLONE as placeholder, at the moment of start dragging, this placeholder is added to the target list, and it sometimes causes problems because the placeholder targets itself.

Would it be possible to prevent the placeholder to be added to the target list in this particular case that sources are also targets?

Thanks in advance!

[metal-router] using window.onbeforeunload does not work for popstate events

I tried to reproduce with just Senna.js and was unable to reproduce, so I think it is specific to metal-router.

Reproduction Steps

  1. Run demos
  2. Navigate around to a few pages
  3. Paste snippet in js console
    window.onbeforeunload = () => true
  4. Click on the "back" arrow in the browser

Expected Result
Browser prompts a warning that asks before going back

Actual Result
Does not navigate, JS error metal.js:9173 Uncaught TypeError: event.preventDefault is not a function

[metal-drag-drop] issue on removeAllListener

When calling removeAllListener, DragHandler could be null leading to below stacktrace exception:

Uncaught TypeError: Cannot read properties of null (reading 'removeAllListeners')
at DragDrop.cleanUpAfterDragging_
at DragDrop.cleanUpAfterDragging_
at DragDrop.handleDragEndEvent_

[metal-uri] [question] Why replacing + character with a blank space?

We are facing a problem when using the metal-uri component because of this:
https://github.com/metal/metal-plugins/blob/master/packages/metal-uri/src/Uri.js#L467
We saw that you are replacing it because of a library, but is it really necessary?
In short, if a user email contains a +, it breaks all our API requests related to user updating since the uriDecode is replacing the + sign with a blank space.
Here goes a reproducible code of the issue we're facing:
test-uri-issue.zip

Unit tests failing when running with `.only` on metal-router package

For instance:

If you add .only on https://github.com/metal/metal-plugins/blob/master/packages/metal-router/test/Router.js#L691

It throws an error:

LOG: 'Senna was not initialized from data attributes. In order to enable its usage from data attributes try setting in the base element, e.g. `<body data-senna>`.'
Chrome 63.0.3239 (Mac OS X 10.13.2) ERROR
  Some of your tests did a full page reload!
Chrome 63.0.3239 (Mac OS X 10.13.2): Executed 0 of 59 ERROR (0.002 secs / 0 secs)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `karma start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script.

When running all the tests without .only it works.

[metal-debounce] Stop including @babel/polyfill

Importing a polyfill directly doesn't seem like a good solution, especially when we can implement this function without the spread operator. (And in anycase the transpiler should take care of this not us)

The current version looks like this:

function debounce(fn, delay) {
	return function debounced() {
		let args = arguments;
		cancelDebounce(debounced);
		debounced.id = setTimeout(function() {
				fn(...(null, args));
				}, delay);
	};
}

And it can be re-written like this:

function debounce(fn, delay) {
	return function debounced() {
		let args = Array.prototype.slice.call(arguments, 0);
		cancelDebounce(debounced);
		debounced.id = setTimeout(function() {
			fn.apply(null, args);
		}, delay);
	};
}

NOTE: I'm aware that using apply is not considered a good practise when using ES6+ by some, but neither is using arguments so at this point does it really matter?

That being said, once the format task kicks in (pretter-eslint) the snippet above gets transformed (before it gets transpiled) to:

function debounce(fn, delay) {
	return function debounced() {
		let args = Array.prototype.slice.call(arguments, 0);
		cancelDebounce(debounced);
		debounced.id = setTimeout(function() {
			fn(...args);       // 👈no more apply, spread is here again
		}, delay);
	};
}

Which gets transpiled to:

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }  // 👈Array.from is expected to be available, which is not the case in IE so how do we solve this?

function debounce(fn, delay) {
  return function debounced() {
    var args = Array.prototype.slice.call(arguments, 0);
    cancelDebounce(debounced);
    debounced.id = setTimeout(function () {
      fn.apply(undefined, _toConsumableArray(args));
    }, delay); 
  };
}

This is probably because our .eslintrc extends eslint-config-liferay which extends eslint-config-google which has

'prefer-rest-params': 2, 
'prefer-spread': 2

Which does actually change apply for spread.

If any one has an idea on how to solve this without changing our config or massive changes, I'd appreciate your feedback.

Thanks

Nested Routes

Copied from deprecate/metal-router#14 by @AngeloYoun

It is a common use case where a site structure needs to have nested routing.

Currently, only the top level URL routes can be routed via metal-router. It would be useful to be able to do something along the lines of:

<Router component={SomeComponent} path={some/path/:param1} />

...

class SomeComponent extends JSXComponent {
    render() {
        return {
            <div class="wrapper">
                <HeaderComponent />

                <Router component={FooComponent} path={some/path/:param1/view1} />

                <Router component={BarComponent} path={some/path/:param1/view2} />
            </div>
        }
    }
}

[metal-position] Add ability to specify the size of the space between the element and alignElement

From deprecate/metal-position#4 by @kienD

It would be useful to be able to specify the size of the space you would like between the element and alignElement for the Align.getAlignRegion method.

I think this could be done by adding a parameter that accepts a number value to the Align.getAlignRegion method for the spacing size and then add or subtract the value of the spacing parameter to the values in each of the switch statements.

The parameter will probably need to be added to other methods that use Align.getAlignRegion like Align.align as well.

Add "types" to path matchers

Copied from deprecate/metal-router#24 by @mthadley

Hey everyone, I wanted to throw out a quick idea that may reduce some of the boilerplate when defining our routes.

It's pretty common to define a route like this, possibly many times, that is meant to match some kind of number:

<Route
  component={userPage}
  path="user/:id(\d+)/"
/>

After a while, it get's tedious to add these regexes to our routes, and also reduces readability. Maybe instead we could still allow for a regex, but also provide some default "types":

<Route
  component={userPage}
  path="user/:id<number>/"
/>

The syntax is subject to change, but I think it would at least be useful for parsing numbers. Possible other things like booleans as well.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.