// Generated by tools/generate.R - DO NOT EDIT BY HAND
// Edit tools/component-registry.yaml instead and re-run the generator.
// Generator version: 1.0.0
// Generated: 2026-06-02 17:19:58

// Designsystemet Shiny Input Bindings
// =====================================

// button binding
var dsButtonBinding = new Shiny.InputBinding();
$.extend(dsButtonBinding, {
  find: function(scope) {
    return $(scope).find('.ds-button.ds-shiny-input');
  },

  getId: function(el) {
    return el.id;
  },

  getValue: function(el) {
return $(el).data('val') || 0;

  },

  setValue: function(el, value) {
    el.value = value;
  },

  subscribe: function(el, callback) {
    $(el).on('click.dsButtonBinding', function(e) {
      var val = $(el).data('val') || 0;
      $(el).data('val', val + 1);
      callback(true);
    });
  },

  unsubscribe: function(el) {
    $(el).off('.dsButtonBinding');
  },

  receiveMessage: function(el, data) {
    // action button: value managed client-side
  }
});
Shiny.inputBindings.register(dsButtonBinding, 'designsystemet.button');

// input binding
var dsInputBinding = new Shiny.InputBinding();
$.extend(dsInputBinding, {
  find: function(scope) {
    return $(scope).find('.ds-input.ds-shiny-input');
  },

  getId: function(el) {
    return el.id;
  },

  getValue: function(el) {
return el.value;

  },

  setValue: function(el, value) {
    el.value = value;
  },

  subscribe: function(el, callback) {
    $(el).on('input change.dsInputBinding', function(e) {
      callback(true);
    });
  },

  unsubscribe: function(el) {
    $(el).off('.dsInputBinding');
  },

  receiveMessage: function(el, data) {
    if (data.value !== undefined) this.setValue(el, data.value);
    $(el).trigger('change');
  }
});
Shiny.inputBindings.register(dsInputBinding, 'designsystemet.input');

// textarea binding
var dsTextareaBinding = new Shiny.InputBinding();
$.extend(dsTextareaBinding, {
  find: function(scope) {
    return $(scope).find('.ds-input.ds-shiny-input');
  },

  getId: function(el) {
    return el.id;
  },

  getValue: function(el) {
return el.value;

  },

  setValue: function(el, value) {
    el.value = value;
  },

  subscribe: function(el, callback) {
    $(el).on('input change.dsTextareaBinding', function(e) {
      callback(true);
    });
  },

  unsubscribe: function(el) {
    $(el).off('.dsTextareaBinding');
  },

  receiveMessage: function(el, data) {
    if (data.value !== undefined) this.setValue(el, data.value);
    $(el).trigger('change');
  }
});
Shiny.inputBindings.register(dsTextareaBinding, 'designsystemet.textarea');

// checkbox binding
var dsCheckboxBinding = new Shiny.InputBinding();
$.extend(dsCheckboxBinding, {
  find: function(scope) {
    return $(scope).find('.ds-input.ds-shiny-input');
  },

  getId: function(el) {
    return el.id;
  },

  getValue: function(el) {
return el.checked;

  },

  setValue: function(el, value) {
    el.value = value;
  },

  subscribe: function(el, callback) {
    $(el).on('change.dsCheckboxBinding', function(e) {
      callback(true);
    });
  },

  unsubscribe: function(el) {
    $(el).off('.dsCheckboxBinding');
  },

  receiveMessage: function(el, data) {
    if (data.value !== undefined) this.setValue(el, data.value);
    $(el).trigger('change');
  }
});
Shiny.inputBindings.register(dsCheckboxBinding, 'designsystemet.checkbox');

// select binding
var dsSelectBinding = new Shiny.InputBinding();
$.extend(dsSelectBinding, {
  find: function(scope) {
    return $(scope).find('.ds-input.ds-shiny-input');
  },

  getId: function(el) {
    return el.id;
  },

  getValue: function(el) {
return el.value;

  },

  setValue: function(el, value) {
    el.value = value;
  },

  subscribe: function(el, callback) {
    $(el).on('change.dsSelectBinding', function(e) {
      callback(true);
    });
  },

  unsubscribe: function(el) {
    $(el).off('.dsSelectBinding');
  },

  receiveMessage: function(el, data) {
    if (data.value !== undefined) this.setValue(el, data.value);
    $(el).trigger('change');
  }
});
Shiny.inputBindings.register(dsSelectBinding, 'designsystemet.select');

// tabs binding
var dsTabsBinding = new Shiny.InputBinding();
$.extend(dsTabsBinding, {
  find: function(scope) {
    return $(scope).find('ds-tabs.ds-shiny-input');
  },

  getId: function(el) {
    return el.id;
  },

  getValue: function(el) {
var selected = el.querySelector('ds-tab[aria-selected=&quot;true&quot;]');
return selected ? selected.getAttribute('data-value') : null;

  },

  setValue: function(el, value) {
    el.value = value;
  },

  subscribe: function(el, callback) {
    $(el).on('click.dsTabsBinding', 'ds-tab', function(e) {
      callback(true);
    });
  },

  unsubscribe: function(el) {
    $(el).off('.dsTabsBinding');
  },

  receiveMessage: function(el, data) {
    if (data.value !== undefined) this.setValue(el, data.value);
    $(el).trigger('change');
  }
});
Shiny.inputBindings.register(dsTabsBinding, 'designsystemet.tabs');

// pagination binding
var dsPaginationBinding = new Shiny.InputBinding();
$.extend(dsPaginationBinding, {
  find: function(scope) {
    return $(scope).find('ds-pagination.ds-shiny-input');
  },

  getId: function(el) {
    return el.id;
  },

  getValue: function(el) {
return parseInt(el.getAttribute('data-current')) || 1;

  },

  setValue: function(el, value) {
    el.value = value;
  },

  subscribe: function(el, callback) {
    $(el).on('click.dsPaginationBinding', 'button, a', function(e) {
      callback(true);
    });
  },

  unsubscribe: function(el) {
    $(el).off('.dsPaginationBinding');
  },

  receiveMessage: function(el, data) {
    if (data.value !== undefined) this.setValue(el, data.value);
    $(el).trigger('change');
  }
});
Shiny.inputBindings.register(dsPaginationBinding, 'designsystemet.pagination');

// suggestion binding
var dsSuggestionBinding = new Shiny.InputBinding();
$.extend(dsSuggestionBinding, {
  find: function(scope) {
    return $(scope).find('ds-suggestion.ds-shiny-input');
  },

  getId: function(el) {
    return el.id;
  },

  getValue: function(el) {
var input = el.querySelector('input');
return input ? input.value : null;

  },

  setValue: function(el, value) {
    el.value = value;
  },

  subscribe: function(el, callback) {
    $(el).on('input.dsSuggestionBinding', 'input', function(e) {
      callback(true);
    });
  },

  unsubscribe: function(el) {
    $(el).off('.dsSuggestionBinding');
  },

  receiveMessage: function(el, data) {
    if (data.value !== undefined) this.setValue(el, data.value);
    $(el).trigger('change');
  }
});
Shiny.inputBindings.register(dsSuggestionBinding, 'designsystemet.suggestion');
