@procore/labs-field-configurator

0.12.1 • Public • Published

Field Configurator

Components to interact with a Configurable Fieldset, an experience around a visibility toggle for a row and potential actions like required or an overflow menu. Please add yourself to the team-config slack channel and ask to be subscribed to bug fixes.

Installation

yarn add -E @procore/labs-field-configurator

Importable Components

  • ConfigurationViewer
  • Section
  • FieldConfigurator
  • SectionDraggingContextProvider

Basic Implementation

ConfigurationViewer is used to provide edit/read view context for Section and FieldConfigurator. Section and FieldConfigurator can be used standalone but generally Section will have many FieldConfigurator as children, with each corresponding to a field from a Configurable FieldSet. SectionDraggingContextProvider manages dragging section's id state. See DragDrop page for usage.

() => {
  const initialValues = {
    normalField: {
      visible: true,
      required: false,
    },
  };

  const [fields, setField] = React.useState(initialValues);

  const setRequired = (title) => {
    setField({
      ...fields,
      [title]: {
        ...fields[title],
        required: !fields[title].required,
      },
    });
  };

  const setVisible = (title) => {
    setField({
      ...fields,
      [title]: {
        ...fields[title],
        visible: !fields[title].visible,
      },
    });
  };

  const [showEdit, toggleEdit] = React.useState(false);

  return (
    <ConfigurationViewer view={showEdit ? 'edit' : 'show'}>
      <Section
        initialIsOpen
        id="demo"
        title="Adjustable Section inheriting from ConfigurationViewer context"
        additionalActions={[
          {
            label: 'test section',
            onClick: () => alert('test section clicked!'),
          },
          {
            label: 'hello section',
            onClick: () => alert('hello section clicked!'),
          },
        ]}
      >
        <FieldConfigurator
          title="Adjustable FieldConfigurator"
          required={fields.normalField.required}
          visible={fields.normalField.visible}
          description="Section and FieldConfigurator inherits from ConfigurationViewer context"
          additionalActions={[
            {
              label: 'test field',
              onClick: () => alert('test field clicked!'),
            },
            {
              label: 'hello field',
              onClick: () => alert('hello field clicked!'),
            },
          ]}
          onRequiredChange={() => setRequired('normalField')}
          onVisibilityChange={() => setVisible('normalField')}
        />
      </Section>
      <Flex paddingTop="lg" style={{ width: '100%' }} justifyContent="flex-end">
        <Button onClick={() => toggleEdit(!showEdit)}>Toggle View</Button>
      </Flex>
    </ConfigurationViewer>
  );
};

Readme

Keywords

none

Package Sidebar

Install

npm i @procore/labs-field-configurator

Weekly Downloads

2

Version

0.12.1

License

SEE LICENSE IN LICENSE

Unpacked Size

1.16 MB

Total Files

6

Last publish

Collaborators

  • yzhou2024
  • alyelashram_procore
  • melch-procore
  • peterknif
  • moaz-ashraf
  • attachi
  • a.elbadawei
  • hyogman
  • dmitri_wm
  • stephanie.brereton
  • procore-oss-user
  • stevenkang3
  • max.helmetag
  • codyrobertsprocore
  • miguel.garcia-procore
  • magdyyx
  • atoaima
  • mustafa-abdelrahman
  • elewando-procore
  • ahmed.ghorab
  • lnspatz914
  • richard.bunn
  • omar.wagdy
  • mona.khairbek
  • mbartlett413
  • cody_schindler_procore
  • yoasyo25
  • ritchlee
  • andersontr15
  • steven.hinkle
  • jamie-dugan-procore
  • hgouhierprocore
  • denzylbalram
  • sarah.freitas
  • alan.bresani
  • amyprocore
  • yoyis3000
  • elijah.procore
  • mike-arndt-procore
  • jnhoang1
  • pam-whisenhunt
  • shradha.khard
  • david-christensen-procore
  • javio-procore
  • chance.eakin.procore
  • gideon-procore
  • ihor.diachenko_procore
  • justinmwatts
  • tedyang
  • jyang-procore
  • pwhisenhunt-procore
  • fairchild
  • rodayna.ehab
  • neil1023
  • scottstern
  • brian.smith1
  • g2mitchell
  • dlameter-procore
  • kylepietz
  • abhijit-procore
  • lhuang325
  • jake-pitkin
  • erikthoreson
  • simona.iancu
  • decha-sanson
  • aberkowitz
  • asamay
  • mustafa-u-abdelrahman
  • rajatmenhdiratta
  • jacksonleach-procore
  • pmfrawley
  • phunguyen-pcor
  • tatsiana.clifton
  • deiab
  • srichaitanya.peddinti
  • kenny.foisy
  • matheusprocore
  • jgreene_procore
  • hectorthiele
  • etokarev
  • daniel.ferreira-contractor
  • dmccraw-procore
  • cyrille.bai
  • greg.sparks
  • fabiomelo513
  • phil.custer
  • bbreyel921
  • amir-iskander
  • neil.mckeeman
  • nickprocore
  • lzhou888
  • davidshure
  • stevenliprocore
  • ramysaid2
  • refaiepcn
  • jgentes
  • faraz.hanif
  • mostafaeltazy
  • agamaleldin
  • andrew.isaac
  • saranahal2
  • rodrigo.dejuana
  • kellen.stewart
  • bill-wagner
  • ezrasimeloff
  • jeffgiaquinto
  • gturkadze
  • sean.spearman.procore
  • kylemartinez-procore
  • roobo-romeski
  • andres-mendez-procore
  • gaurav.sharma.procore
  • tracy.otto
  • sarah.heredia
  • victorbendeck-pc
  • cbathgate
  • davidkangpro
  • kyle.liu
  • amin.jaipuri
  • grafffffff
  • mishaelowoyemi
  • evan.cerwonka.procore
  • ilya.dryha-contractor
  • varomir
  • yogevfine1
  • timofeee
  • matt.harris0223
  • winson.chu
  • andersonbispoprocore
  • scorgiat-procore
  • ladavarga
  • procore_halzy
  • enyaga
  • willpankonien
  • sateesh-kadiyala-procore
  • chris.berber
  • txin1
  • epalinprocore
  • mehrdad-panahandeh
  • tyler.wasden.procore
  • jeremy.lund
  • dineshkumar.jayak
  • ryanfuentesprocore
  • stajics
  • brocktillotsonprocore
  • kyle.williams
  • dtorres-procore
  • noor.ali
  • ari-procore
  • alanprocore
  • jl4ever
  • james.lawson
  • ajaykumar-procore
  • dennis.heckman
  • tara.chambers
  • lalovar-procore
  • james.cleary
  • chadryder
  • devin.cunningham.procore
  • abhijit.patwardhan
  • lydiahara
  • sherylnapigkit
  • changprocore
  • apcarroll_procore
  • andy.mayer
  • bob.laskowski
  • vinaya-procore
  • kahliholmes
  • andrew.wheeler
  • leandro-proc
  • yadhu.prakash
  • jason-kaye
  • jesse.olsen
  • patrick.lardin
  • brad.urani
  • allenanle.procore
  • brookyboy009
  • uddhavjoglekar
  • dancingshell
  • rysmithprocore
  • robbiegprocore
  • jadamsss
  • jeremy.bouzigard
  • timdoherty
  • b.bookout
  • jalyng
  • htael
  • dev-account-admin
  • sseanwang
  • bhargavrnd
  • farismmk
  • dannyporrello
  • danny.ou
  • messanjah
  • eyvettesou
  • jgee67
  • cagmz
  • mariah_delaney
  • lukenispel
  • kimhin267
  • juliana.hernandez
  • judy-lu-pc
  • procore-it-support
  • andrewburke-pc
  • jkleintech
  • rachel.arkebauer
  • procore-npm-bot
  • james.dabbs-procore
  • laurenbrandsteinprocore
  • scottbieser-procore
  • zach.mckenzie.procore
  • shayonj_procore
  • heplayskeys
  • mike.south
  • thomasoboyle
  • dischorde
  • derek-carter-procore
  • dlgasser
  • cfprocore
  • evan.waits
  • jeremy-marcus
  • jmejia-fsl
  • ersgonzalo
  • stephan-procore
  • aleclarsenprocore
  • yihai.zweifel
  • jay-rajan
  • jacky-lei
  • peter.jin