Sha256: c577b1c5791dcce2d2b2cfc5a4abefb8839b1bd3bc55879d524559a950415846

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

const classes = {
  root: "select",
  input: "select__input"
};

const states = {
  root: { focused: `${classes.root}--is-focused` }
};

var Select, focus_or_blur_select;

//*
// Translates the `focus`/ `blur` events on the actual `select` node into the
// appropriate addition/ removal of the focused state on the base node of the
// component. This has to be done because most of the visual styling for the
// component is placed on the container, so any adjustments to those styles on
// focus require that container to be aware of the state of its contained
// `select`.
//
// @param {Object} event - The `focus`/ `blur` event on the `select`.
// @private

focus_or_blur_select = (event) => {
  var method = event.type === "focusin" ? "add" : "remove";
  $(event.target).closest(".#{CLASSES.BASE}")[0].classList[method](states.root.focused);
};

Select = {
  init() {
    $(document).on("focus blur", `.${classes.input}`, focus_or_blur_select);
  }
};

export { classes };
export default Select;

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
docks_theme_api-1.0.3 source/components/select/select.js
docks_theme_api-1.0.2 source/components/select/select.js