Giter Site home page Giter Site logo

domonda / domonda-js Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 9.15 MB

JavaScript libraries developed and used by domonda written in TypeScript.

Home Page: https://domonda.com

License: Other

JavaScript 1.15% TypeScript 98.78% Shell 0.06%
typescript javascript domonda library form state observables javascript-library javascript-libraries

domonda-js's Introduction


domonda.js

JavaScript libraries developed and used by domonda written in TypeScript.


domonda-js's People

Contributors

domondabot avatar enisdenjo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

cianixru

domonda-js's Issues

domonda-ui: improve Menu component

Story

As a user

I want to have a dropdown Menu

So that I can have nested/collapsed menu items

Acceptance criteria

  • User is able to open the Menu by clicking on it
  • User is able to close the Menu by clicking anywhere outside the Menu
  • User sees all collapsed items when the Menu open

react-form: setting value to `undefined`

Expected Behaviour

Setting a field value to undefined either sets the value to undefined or removes the path to the value from the values.

Actual Behaviour

Setting a field value to undefined does nothing.

Previous Reasoning

When an existing array in the form values is used through a FormField to render nested array elements which also use any derivation of the FormField component, removing items from the array itself becomes impossible. The child FormField would set the field to undefined before/instead of unmounting. Efficiently preventing any removals of the items in the array.

Say we have a form which looks like this:

const values = { people: ['John', 'Jane'] };
const tree = (
  <Form defaultValues={values}>
    <FormField path="people">
      {(array, setArray) => (
        <>
          {array.map((_0, index) => (
            <FormField path={`people[${index}]`}>
              {(item) => (
                <input manipulate={item} />
              )}
            </FormField>
          ))}
          <RemoveLast onClick={() =>  setArray(array.pop())} />
        </>
      )}
    </FormField>
  </Form>
);

After you click the <RemoveLast /> the array would become: ['John', undefined], instead of: ['John'].

Described in the following test:

it('should not render or set undefined values on array fields', (done) => {
interface DV {
people: string[];
}
const dv: DV = {
people: ['John', 'Foo', 'Bar'],
};
let form: DomondaForm<DV>;
const { rerender } = render(
<Form getForm={(f) => (form = f)} resetOnDefaultValuesChange defaultValues={dv}>
<FormField<any[]> path="people">
{({ value }) => (
<>
{value.map((person: any, index) => (
<FormField key={person} path={`people[${index}]`}>
{() => null}
</FormField>
))}
</>
)}
</FormField>
</Form>,
);
// @ts-ignore because form should indeed be set here
if (!form) {
throw new Error('form instance should be set here!');
}
const nextDv: DV = {
people: ['Foo'],
};
rerender(
<Form resetOnDefaultValuesChange defaultValues={nextDv}>
<FormField<any[]> path="people">
{({ value }) => (
<>
{value.map((person: any, index) => (
<FormField key={person} path={`people[${index}]`}>
{() => null}
</FormField>
))}
</>
)}
</FormField>
</Form>,
);
expect(form.state.values).toEqual(nextDv);
done();
});

and such behaviour is allowed by this segment:

values:
rest.value === undefined
? state.values
: setWith(() => undefined, path, rest.value, form.state.values),

react-form: number field does not reset

Expected Behaviour

Resetting the form after changing a number input, visually reverts the changes back.

Actual Behaviour

Resetting the form after changing a number input, resets the value but the input stays the same.

react-form: number input `min` ignored

Expected Behaviour

Setting the min prop to 1 on a FormNumberInput does not allow zeroes (0).

Actual Behaviour

Whatever value set on the min prop is ignored. No minimum is implied.

domonda-react-form: Expose `registerLocale` func from the date picker

Currently, if a user wants to use a different locale with the @domonda/react-form date picker, he has to install the react-datepicker lib just to use the registerLocale.

To avoid this unnecessary clutter, simply exporting the registerLocale from within the lib would suffice.

domonda-react-form: pasting a number with varying decimal separators

Expected Behaviour

Pasting a number which either contains a dot (.) or a comma (,) as a decimal separator to the number input correctly accepts the number both ways.

Example:

Pasting a number 824,20 in a number field with a decimal separator being dot (.) becomes: 824.20

Actual Behaviour

Pasting a number which either contains a dot (.) or a comma (,) as a decimal separator to the number input correctly accepts only numbers which have a matching decimal separator.

Example:

Pasting a number 824,20 in a number field with a decimal separator being dot (.) becomes: 82,420

domonda-ui: Flex `fill` prop does not consider margin for height

Expected Behaviour

When using fill prop on flex which has spacing defined, the height should be calculated considering the margin offsets.

Actual Behaviour

Using fill prop on Flex which has spacing defined is moved up by the margin offset. It does not fill the container correctly.

domonda-ui: Text does not inherit font-size

Expected Behaviour

Having a nested <Text /> component with the inherit prop, inherits the font-size from the parent <Text /> component.

Actual Behaviour

Having a nested <Text /> component with the inherit prop, does not inherit the font-size from the parent <Text /> component.

domonda-ui: `label` typography variant

Introduce a new variant: label in TypographyVariant.

This variant would be useful to mirror the label style currently seen in input/select elements. By simulating the label styles we can compose named values which are not meant to be changed.

domonda-react-form: `FormDateField` not updating value

Expected Behaviour

Every subsequent value change on the FormDateField should update the value in the related field.

Actual Behaviour

FormDateField changes the value of the related field only on first change. Subsequent changes are ignored.

domonda-ui: avoid dynamic rules

Using dynamic rules in JSS can be a performance bottleneck when many of the same items are rendered. Since the dynamic rules cannot be reused, they will be created for every component.

Instead, try putting the dynamic rules into the styles prop.

Query params allow mutating the resulting object

Expected Behaviour

Query params return an object which, when/if mutated, does not interfere with the internal workings.

Actual Behaviour

Query params returns an object which, when/if mutated, inteferes with the internal workings. For example: it can wrongly replace the URL with the mutated object without reporting the change.

Deep freezing query params result object should prevent this behaviour.

query-params: call replace for query params once per model

Expected Behaviour

Regardless of the number of query param hooks rendered, the history.replace is called once per model.

Actual Behaviour

Number of query param hooks rendered is directly proportional to amount of history.replace calls.

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.